From a89ebc8530c7b0a7e5018059becfd3016e00aaed Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 26 Mar 2025 11:56:47 +0000 Subject: [PATCH] Bug 39323: Print dropdown in members toolbar should auto close The upgrade to Bootstrap 5 broke some code which was designed to close a dropdown menu: $(".btn-group").removeClass("open"); This doesn't work in Bootstrap 5. You have to use: $(".dropdown-menu").removeClass("show"); However, I found that in most cases this extra code wasn't needed if we adjust the way we do the click handlers. Using "e.preventDefault()" instead of "return false" seems to be the preferred practice. This patch also makes a minor change to CSS to fix a display issue with dropdown menus. To test apply the patch and rebuild the staff interface CSS. - Clear your browser cache if necessary. - Search the catalog and click "Edit record" on one of the results. - In the basic MARC editor click the dropdown menu on the "Save" button. - Test the three options there: "Save and view record", "Save and edit items", and "Save and continue editing". - In each case clicking one of those options should result in the menu closing before the page redirects. - The main "Save" button should still work correctly. - Perform a patron search which will return results. - Check one or more patrons in the result and then click the "Add to patron list" button. The dropdown menu should look consistent with other dropdowns. - View the detail page for one of the patron in your results. - Test each of the options under the "Print" dropdown menu. In each case the menu should close itself when you click one of the menu items. - Test the "Renew patron" and "Update child to adult patron" - Click "Search to hold" and perform a catalog search which will return results. - Check one or more results and test the "Place hold" dropdown menu items. Sponsored-by: Athens County Public Libraries --- .../prog/css/src/staff-global.scss | 18 ------------- .../prog/en/modules/cataloguing/addbiblio.tt | 21 +++++++--------- .../prog/en/modules/members/member.tt | 3 +-- koha-tmpl/intranet-tmpl/prog/js/catalog.js | 5 ---- .../intranet-tmpl/prog/js/members-menu.js | 25 ++++++++----------- .../intranet-tmpl/prog/js/pages/results.js | 20 ++++++--------- 6 files changed, 28 insertions(+), 64 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss index d8a1d8aca37..8135263fe94 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -2053,24 +2053,6 @@ li { } } } - - .dropdown-menu { - background-color: #FFFFFF; - color: #000; - height: fit-content; - top: 100%; - - a { - color: #000; - - &:hover { - background-color: #FFFFFF; - background-image: none; - color: #000; - text-decoration: underline; - } - } - } } .searchheader { 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 ad4d899fa63..d64d6b0bb7b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -130,29 +130,26 @@ AutomaticLinker(); }); - $("#saverecord").click(function(){ - $(".btn-group").removeClass("open"); + $("#saverecord").click(function(e){ + e.preventDefault(); onOption(); - return false; }); - $("#saveandview").click(function(){ - $(".btn-group").removeClass("open"); + $("#saveandview").click(function(e){ + e.preventDefault(); redirect("view"); - return false; }); - $("#saveanditems").click(function(){ - $(".btn-group").removeClass("open"); + $("#saveanditems").click(function(e){ + e.preventDefault(); redirect("items"); - return false; }); - $("#saveandcontinue").click(function(){ - $(".btn-group").removeClass("open"); + + $("#saveandcontinue").click(function(e){ + e.preventDefault(); var tab = $("#addbibliotabs div.active:first").attr('id'); $("#current_tab").val(tab); redirect("just_save", tab); - return false; }); $( '#toggleEditor' ).change( function() { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt index 318f56a6885..2f4fb0cdc60 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt @@ -242,7 +242,7 @@ var patron_search_selections = JSON.parse(localStorage.getItem("patron_search_selections")) || []; if (patron_search_selections.length == 0) { alert(_("You have not selected any patrons to add to a list!")); - $(".btn-group").removeClass("open"); /* Close button menu */ + $(".dropdown-menu").removeClass("show"); return false; } @@ -253,7 +253,6 @@ $("#new-patron-list").modal("show"); } else { /* Ajax submit the patrons to list */ - patronListAdd(); } }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/catalog.js b/koha-tmpl/intranet-tmpl/prog/js/catalog.js index bbd96152dd6..4669cea90c3 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/catalog.js +++ b/koha-tmpl/intranet-tmpl/prog/js/catalog.js @@ -171,11 +171,6 @@ $(document).ready(function () { ); }); - $("#addtoshelf").click(function () { - addToShelf(); - $(".btn-group").removeClass("open"); - return false; - }); $("#export").remove(); // Hide embedded export form if JS menus available $(".addtolist").on("click", function (e) { diff --git a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js index 8a6a9415b89..f47b5c2e38a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members-menu.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members-menu.js @@ -23,18 +23,17 @@ $(document).ready(function () { }); } if (CAN_user_borrowers_edit_borrowers) { - $("#renewpatron").click(function () { + $("#renewpatron").click(function (e) { + e.preventDefault(); confirm_reregistration(); - $(".btn-group").removeClass("open"); - return false; }); + $("#updatechild").click(function (e) { + e.preventDefault(); if ($(this).data("toggle") == "tooltip") { // Disabled menu option has tooltip attribute - e.preventDefault(); } else { update_child(); - $(".btn-group").removeClass("open"); } }); } @@ -47,21 +46,20 @@ $(document).ready(function () { ); }); - $("#exportcheckins").click(function () { + $("#exportcheckins").click(function (e) { + e.preventDefault(); export_barcodes(); - $(".btn-group").removeClass("open"); - return false; }); - $("#print_overdues").click(function () { + $("#print_overdues").click(function (e) { + e.preventDefault(); window.open( "/cgi-bin/koha/members/print_overdues.pl?borrowernumber=" + borrowernumber, "printwindow" ); - $(".btn-group").removeClass("open"); - return false; }); - $(".printslip").click(function () { + $(".printslip").click(function (e) { + e.preventDefault(); let slip_code = $(this).data("code"); let clear_screen = $(this).data("clear"); if (slip_code == "printsummary") { @@ -81,9 +79,6 @@ $(document).ready(function () { } if (clear_screen) { window.location.replace("/cgi-bin/koha/circ/circulation.pl"); - } else { - $(".btn-group").removeClass("open"); - return false; } }); $("#searchtohold").click(function () { diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js b/koha-tmpl/intranet-tmpl/prog/js/pages/results.js index 6e49c7dc2e5..cfe0cd88ba8 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/results.js @@ -199,30 +199,26 @@ $(document).ready(function () { return false; }); - $("#searchheader").on("click", ".placehold", function () { + $("#searchheader").on("click", ".placehold", function (e) { + e.preventDefault(); $("#holdFor").val(""); $("#holdForClub").val(""); placeHold(); - $(".btn-group").removeClass("open"); - return false; }); - $(".placeholdfor").click(function () { + $(".placeholdfor").click(function (e) { + e.preventDefault(); holdForPatron(); - $(".btn-group").removeClass("open"); - return false; }); - $(".placeholdforclub").click(function () { + $(".placeholdforclub").click(function (e) { + e.preventDefault(); holdForClub(); - $(".btn-group").removeClass("open"); - return false; }); - $("#forgetholdfor, #forgetholdforclub").click(function () { + $("#forgetholdfor, #forgetholdforclub").click(function (e) { + e.preventDefault(); forgetPatronAndClub(); - $(".btn-group").removeClass("open"); - return false; }); $(".selection").show(); -- 2.39.5