Bug 25727: Do not open options on clear
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 17 Aug 2020 12:58:10 +0000 (12:58 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 24 Aug 2020 09:19:03 +0000 (11:19 +0200)
We want to restore the previous behaviour and keep the options closed when
clear is clicked

https://github.com/select2/select2/issues/3320#issuecomment-621662039

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/intranet-tmpl/prog/en/includes/select2.inc
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt
koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js

index dd1df60..4d0aed8 100644 (file)
       removeAllItems:function(){return _("Remove all items")},
       removeItem:function(){return _("Remove item")}
     });
+
+    $(document).ready(function(){
+        $(".select2").select2();
+        $(".select2").on("select2:clear", function (evt) {
+            $(this).on("select2:opening.cancelOpen", function (evt) {
+                evt.preventDefault();
+
+                $(this).off("select2:opening.cancelOpen");
+            });
+        });
+    });
+
 </script>
 <!-- / select2.inc -->
index 3fcb56c..961b4b2 100644 (file)
@@ -168,11 +168,6 @@ function confirmnotdup(redirect){
 [% Asset.css("css/addbiblio.css") | $raw %]
 
 [% INCLUDE 'select2.inc' %]
-<script>
-  $(document).ready(function() {
-    $('.subfield_line select').select2();
-  });
-</script>
 
 </head>
 <body id="auth_authorities" class="auth">
@@ -375,7 +370,7 @@ function confirmnotdup(redirect){
                 
                 [% SET mv = subfield_loo.marc_value %]
                 [% IF ( mv.type == 'select' ) %]
-                     <select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]">
+                     <select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
                      [% FOREACH aval IN mv.values %]
                          [% IF aval == mv.default %]
                          <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
index 77f851e..ba0a120 100644 (file)
 [% Asset.css("css/addbiblio.css") | $raw %]
 
 [% INCLUDE 'select2.inc' %]
-<script>
-  $(document).ready(function() {
-    $('.subfield_line select').select2();
-  });
-</script>
 
 </head>
 <body id="cat_addbiblio" class="cat">
                                                 [% ELSIF ( mv.type == 'textarea' ) %]
                                                     <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
                                                 [% ELSIF ( mv.type == 'select' ) %]
-                                                    <select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id | html -%]">
+                                                    <select name="[%- mv.name | html -%]" tabindex="1" size="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
                                                     [% FOREACH aval IN mv.values %]
                                                         [% IF aval == mv.default %]
                                                         <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
index c31441b..5ae4103 100644 (file)
                     <input type="hidden" id="[%- mv.id | html -%]" name="field_value" class="input_marceditor" size="50" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]">
                 [% ELSIF ( mv.type == 'select' ) %]
                     [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %]
-                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor" readonly="readonly" disabled="disabled">
+                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor select2" readonly="readonly" disabled="disabled">
                     [% ELSE %]
-                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor">
+                        <select name="field_value" id="[%- mv.id | html -%]" size="1" class="input_marceditor select2">
                     [% END %]
                     [% FOREACH aval IN mv.values %]
                         [% IF aval == mv.default %]
index 8fe16b9..bcad4da 100644 (file)
@@ -234,7 +234,7 @@ $(document).ready(function() {
                     <label>[% iteminformatio.subfield | html %] - [% iteminformatio.marc_lib | $raw %]</label>
                 [% END %]
                 [% IF ( iteminformatio.marc_value.type == 'select' ) %]
-                  <select name="field_value" size="1">
+                  <select name="field_value" size="1" class="select2">
                   [% FOREACH value IN iteminformatio.marc_value.values %]
                     [% IF ( value == iteminformatio.marc_value.default ) %]
                       <option value="[% value | html %]" selected="selected">[% iteminformatio.marc_value.labels.$value | html %]</option>
index a453411..22badd1 100644 (file)
@@ -69,7 +69,6 @@ $(document).ready(function(){
         multiCopyControl.toggle();
     });
 
-    $('.subfield_line select').select2();
 });
 
 function Check(f) {