From 46e6df4d2240c1695d0f58de01d4e4d1b5962f9c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 17 Aug 2020 12:58:10 +0000 Subject: [PATCH] Bug 25727: Do not open options on clear 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 Signed-off-by: Jonathan Druart --- koha-tmpl/intranet-tmpl/prog/en/includes/select2.inc | 12 ++++++++++++ .../prog/en/modules/authorities/authorities.tt | 7 +------ .../prog/en/modules/cataloguing/addbiblio.tt | 7 +------ .../prog/en/modules/cataloguing/additem.tt | 4 ++-- .../prog/en/modules/serials/serials-edit.tt | 2 +- .../intranet-tmpl/prog/js/cataloging_additem.js | 1 - 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/select2.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/select2.inc index dd1df60214..4d0aed87ca 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/select2.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/select2.inc @@ -31,5 +31,17 @@ 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"); + }); + }); + }); + diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt index 3fcb56cb77..961b4b25e6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt @@ -168,11 +168,6 @@ function confirmnotdup(redirect){ [% Asset.css("css/addbiblio.css") | $raw %] [% INCLUDE 'select2.inc' %] - @@ -375,7 +370,7 @@ function confirmnotdup(redirect){ [% SET mv = subfield_loo.marc_value %] [% IF ( mv.type == 'select' ) %] - [% FOREACH aval IN mv.values %] [% IF aval == mv.default %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index 77f851e9a5..ba0a120302 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -483,11 +483,6 @@ [% Asset.css("css/addbiblio.css") | $raw %] [% INCLUDE 'select2.inc' %] - @@ -852,7 +847,7 @@ [% ELSIF ( mv.type == 'textarea' ) %] [% ELSIF ( mv.type == 'select' ) %] - [% FOREACH aval IN mv.values %] [% IF aval == mv.default %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index c31441b3b5..5ae41036a5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -158,9 +158,9 @@ [% ELSIF ( mv.type == 'select' ) %] [% IF ( mv.readonly || ite.IS_RETURN_CLAIM ) %] - [% ELSE %] - [% END %] [% FOREACH aval IN mv.values %] [% IF aval == mv.default %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt index 8fe16b99fb..bcad4da652 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt @@ -234,7 +234,7 @@ $(document).ready(function() { [% END %] [% IF ( iteminformatio.marc_value.type == 'select' ) %] - [% FOREACH value IN iteminformatio.marc_value.values %] [% IF ( value == iteminformatio.marc_value.default ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js index a453411506..22badd189d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js @@ -69,7 +69,6 @@ $(document).ready(function(){ multiCopyControl.toggle(); }); - $('.subfield_line select').select2(); }); function Check(f) { -- 2.39.5