Bug 7825: (follow-up) do not preselect item when OpacItemHolds is 'force' - bootstrap
authorJonathan Druart <jonathan.druart@biblibre.com>
Mon, 20 Jan 2014 10:36:48 +0000 (11:36 +0100)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 26 May 2014 01:01:12 +0000 (01:01 +0000)
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Retested with all 3 themes, works as expected.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reserve.tt

index e82540c..0ed677b 100644 (file)
         var copiesRowId = null;
         var wasSpecific = false;
         var lastCopiesRowId = null;
+
+        $(".toggle-hold-options").show();
+        $(".hold-options").hide();
+        $(".holddatefrom,.holddateto").prop("readOnly", true);
+
         $(".checkitem").parent().click(function(e){
             if(e.target.tagName.toLowerCase() == 'td'){
                 $(this).find("input.checkitem").each( function() {
           }
         });
 
+        $(".toggle-hold-options").on("click",function(e){
+            e.preventDefault();
+            toggleLink = $(this);
+            var optionsID = this.id.replace("toggle-hold-options-","");
+            $("#hold-options-"+optionsID).toggle(0, function() {
+                toggleLink.text($(this).is(':visible') ? _("Hide options") : _("Show more options"));
+            });
+        });
+
         // Hides all 'specific copy' table rows on load.
         $(".copiesrow").hide();
 
-        [% FOREACH bibitemloo IN bibitemloop %]
-          [% IF bibitemloo.holdable %]
-            [% IF OPACItemHolds == 'force' %]
+        [% IF OPACItemHolds == 'force' %]
+          [% FOREACH bibitemloo IN bibitemloop %]
+            [% IF bibitemloo.holdable %]
+              $("#toggle-hold-options-[% bibitemloo.biblionumber %]").click();
               $("#copiesrow_[% bibitemloo.biblionumber %]").show();
             [% END %]
           [% END %]
             }
         });
 
-        $(".toggle-hold-options").show();
-        $(".hold-options").hide();
-        $(".holddatefrom,.holddateto").prop("readOnly", true);
-
         $(".date-format").each(function(){
             if($(this).hasClass("to")){ var op = "to"; }
             if($(this).hasClass("from")){ var op = "from"; }
             $(".selectany").attr("checked", "checked");
         [% END %]
 
-        // If we can choose a specific item, we preselect the first one
-        [% IF OPACItemHolds =="1" or OPACItemHolds == 'force' %]
+        // If the user is *allowed* to choose a specific item
+        // The first one is preselected
+        [% IF OPACItemHolds =="1" %]
             $("table.copiesrow").each(function(){
                 var id = suffixOf($(this).attr("id"), "_");
                 select_first_available(id);
             return true;
         });
 
-        $(".toggle-hold-options").on("click",function(e){
-            e.preventDefault();
-            toggleLink = $(this);
-            var optionsID = this.id.replace("toggle-hold-options-","");
-            $("#hold-options-"+optionsID).toggle(0, function() {
-                toggleLink.text($(this).is(':visible') ? _("Hide options") : _("Show more options"));
-            });
-        });
-
         [% FOREACH bibitemloo IN bibitemloop %]
             [% IF ( bibitemloo.holdable ) %]
                 // http://jqueryui.com/demos/datepicker/#date-range