From f2003766a3670c64bfaa9b655f8c61ee5f87ee6f Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 22 Oct 2024 13:47:20 +0000 Subject: [PATCH] Bug 38227: Collapse authority popup search form when showing results This patch takes the collapsing-panel functionality of the patron entry form and generalizes it so that it can be used on the authority search popup window in cataloging. To test, apply the patch and rebuild the staff interface CSS. - Go to Cataloging -> New record (basic MARC editor) - Switch to tab 1 and click the tag editor link next to tag 100 subfield a. - The search form should be expanded in the pop-up window. - Perform a search. When the window reloads with search results the search form should be collapsed. - Confirm that clicking the "Search options" legend works correctly to expand and collapse the form. - Collapse the form and click the "Clear form" button. The form should expand -- This is based on the assumption that the "Clear form" button would be used when the user wants to initiate a new search. - Go to Patrons -> New patron and confirm that collapsible sections still work correctly. Sponsored-by: Athens County Public Libraries Signed-off-by: Phil Ringnalda Signed-off-by: Jonathan Druart --- .../prog/css/src/staff-global.scss | 29 ++++++++++++++ .../prog/en/includes/auth-finder-search.inc | 6 ++- .../prog/en/modules/members/memberentrygen.tt | 39 ------------------- .../prog/js/auth-finder-search.js | 8 ++++ .../intranet-tmpl/prog/js/staff-global.js | 16 ++++++++ 5 files changed, 57 insertions(+), 41 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 878634a08a4..bbd2fab827d 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -1237,6 +1237,35 @@ fieldset { } } +legend { + &.collapsed, + &.expanded { + border: 1px solid #FFF; + margin-left: -.7em; + margin-top: -.7em; + padding: .7em; + + &:hover { + border: 1px solid #6FAF44; + cursor: pointer; + } + + i { + color: #4C7AA8; + font-size: 80%; + padding-right: .2rem; + } + } + + &.collapsed { + margin-bottom: -.5em; + + i.fa.fa-caret-down::before { + content: "\f0da"; + } + } +} + details { > summary { cursor: pointer; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc index 9d4342cfc12..fa582bedd22 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc @@ -10,8 +10,10 @@ -
Search options -
  1. +
    + +
      +
    1. Authority type: [% authtypecode | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 65251c5b0f1..b49a1dc7b7a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -26,32 +26,6 @@ [% t("Koha") | html %] [% END %] [% INCLUDE 'doc-head-close.inc' %] - @@ -1871,18 +1845,6 @@ legend.collapsed i.fa.fa-caret-down::before { [% END %] } - function togglePanel( node ){ - var panel = node.nextAll(); - if(panel.is(":visible")){ - node.addClass("collapsed").removeClass("expanded").attr("title", _("Click to expand this section") ); - panel.hide(); - } else { - node.addClass("expanded").removeClass("collapsed").attr("title", _("Click to collapse this section") ); - panel.show(); - panel.find("input, select, textarea").eq(0).focus(); - } - } - $(document).ready(function() { showHideFields(); $("#toggle_hidden_fields").change(function(){ @@ -1890,7 +1852,6 @@ legend.collapsed i.fa.fa-caret-down::before { }); $(".collapsed,.expanded").on("click",function(){ - togglePanel( $(this) ); $("#messaging_prefs_loading").hide(); $("#guarantor_template").hide(); }); diff --git a/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js b/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js index 5bdf7db81a1..d5705272045 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js +++ b/koha-tmpl/intranet-tmpl/prog/js/auth-finder-search.js @@ -134,6 +134,10 @@ $(document).ready(function(){ minLength: 3, }); $("#clear-form").click(function(){ + let legend = $("legend"); + if( legend.hasClass("collapsed") ){ + legend.click(); + }; setTimeout(function(){ $(":input[type='text']").val(''); $("#mainmainentry").val("contains"); @@ -144,6 +148,10 @@ $(document).ready(function(){ }, 50); return true; }); + + if( $("#resultlist").length === 0 ){ + $("legend").click(); + } }); function finderjump(page, full){ diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index e76bf876f68..95a37800f13 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -59,6 +59,18 @@ $.fn.selectTabByID = function (tabID) { $("a[href='" + tabID + "']", $(this)).tab("show"); }; +function togglePanel( node ){ + var panel = node.nextAll(); + if(panel.is(":visible")){ + node.addClass("collapsed").removeClass("expanded").attr("title", __("Click to expand this section") ); + panel.hide(); + } else { + node.addClass("expanded").removeClass("collapsed").attr("title", __("Click to collapse this section") ); + panel.show(); + panel.find("input, select, textarea").eq(0).focus(); + } +} + $(document).ready(function () { //check if sticky element is stuck, if so add floating class if ( $('.sticky').length ) { @@ -392,6 +404,10 @@ $(document).ready(function () { $('[data-bs-toggle="tooltip"]').tooltip(); } + $(".collapsed,.expanded").on("click",function(e){ + e.preventDefault(); + togglePanel( $(this) ); + }); }); function removeLastBorrower() { -- 2.34.1