From 72d7261821387e6870150030fa49e93e17021704 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 --- .../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 6b6c5e7f0c..f8f015e1de 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss @@ -1208,6 +1208,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 f9ff82c907..7545e668b7 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 2ea5d5957f..06bb12835d 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' %] - @@ -1856,18 +1830,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(){ @@ -1875,7 +1837,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 5bdf7db81a..d570527204 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 73a4a0251e..f0cda8aecc 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.44.0