Bug 28723: Replace "No title" by an empty string
[srvgit] / koha-tmpl / intranet-tmpl / prog / js / holds.js
index 110d142..964528a 100644 (file)
@@ -3,7 +3,7 @@ function display_pickup_location (state) {
     if ( state.needs_override === true ) {
         $text = $(
             '<span>' + state.text + '</span> <span style="float:right;" title="' +
-            _("This pickup location is not allowed according to circulation rules") +
+            __("This pickup location is not allowed according to circulation rules") +
             '"><i class="fa fa-exclamation-circle" aria-hidden="true"></i></span>'
         );
     }
@@ -48,7 +48,7 @@ function display_pickup_location (state) {
             url = '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations';
         }
 
-        select.select2({
+        select.kohaSelect({
             width: 'style',
             allowClear: false,
             ajax: {
@@ -82,8 +82,7 @@ function display_pickup_location (state) {
                         );
                     });
                     return { "results": results, "pagination": { "more": data.pagination.more } };
-                },
-                transport: kohaSelect2Transport,
+                }
             },
             templateResult: display_pickup_location
         });
@@ -139,7 +138,7 @@ $(document).ready(function() {
                             title = "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber="
                                   + oObj.biblionumber
                                   + "'>"
-                                  + oObj.title.escapeHtml();
+                                  + (oObj.title ? oObj.title.escapeHtml() : '');
 
                             $.each(oObj.subtitle, function( index, value ) {
                                 title += " " + value.escapeHtml();
@@ -176,6 +175,15 @@ $(document).ready(function() {
                     {
                         "mDataProp": function( oObj ) {
                             var data = "";
+                            if ( oObj.itemtype ) {
+                                data += oObj.itemtype_description;
+                            }
+                            return data;
+                        }
+                    },
+                    {
+                        "mDataProp": function( oObj ) {
+                            var data = "";
                             if ( oObj.barcode ) {
                                 data += " <a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="
                                   + oObj.biblionumber
@@ -330,7 +338,7 @@ $(document).ready(function() {
                             alert(__("Unable to resume, hold not found"));
                         }
                         else {
-                            alert(_("Your request could not be processed. Check the logs"));
+                            alert(__("Your request could not be processed. Check the logs"));
                         }
                         holdsTable.api().ajax.reload();
                     });
@@ -384,7 +392,7 @@ $(document).ready(function() {
                     <input type='hidden' id='suspend-modal-reserve_id' name='reserve_id' />\
 \
                     <label for='suspend-modal-until'>" + __("Suspend until:") + "</label>\
-                    <input name='suspend_until' id='suspend-modal-until' class='suspend-until' size='10' />\
+                    <input name='suspend_until' id='suspend-modal-until' class='suspend-until flatpickr' data-flatpickr-futuredate='true' size='10' />\
 \
                     <p><a class='btn btn-link' id='suspend-modal-clear-date' >" + __("Clear date to suspend indefinitely") + "</a></p>\
 \
@@ -400,9 +408,6 @@ $(document).ready(function() {
         </div>\
     ");
 
-    $("#suspend-modal-until").flatpickr({
-        minDate: new Date().fp_incr(1) // Require that "until date" be in the future
-    });
     $("#suspend-modal-clear-date").on( "click", function() { $("#suspend-modal-until").val(""); } );
 
     $("#suspend-modal-submit").on( "click", function( e ) {
@@ -419,7 +424,7 @@ $(document).ready(function() {
                 alert(__("Unable to suspend, hold not found"));
             }
             else {
-                alert(_("Your request could not be processed. Check the logs"));
+                alert(__("Your request could not be processed. Check the logs"));
             }
             holdsTable.api().ajax.reload();
         }).done(function() {
@@ -427,4 +432,13 @@ $(document).ready(function() {
             $('#suspend-modal').modal('hide');
         });
     });
+
+    $(".toggle-suspend").on('click', function(e) {
+        e.preventDefault();
+        let reserve_id     = $(this).data('reserve-id');
+        let biblionumber   = $(this).data('biblionumber');
+        let suspend_until  = $('#suspend_until_' + reserve_id).val();
+        window.location.href='request.pl?action=toggleSuspend&amp;reserve_id=' + reserve_id + '&amp;biblionumber=' + biblionumber + '&amp;suspend_until=' + suspend_until;
+        return false;
+    });
 });