From 14a736a248e8fa4227cd80d4e6ac17c5e02dee91 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 12 Aug 2021 11:13:46 +0000 Subject: [PATCH] Bug 28847: Cleanup of branch limitsand fix OPAC_SEARCH_LIMIT MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The opac had 'branch_group_limit' parameters which can be simplified to more closely match intranet code. Adjust C4::Auth for chaneg above to ensure dropdowns correctly populate Expand JS to prevent selection of single and multibranch limits To test: 1 - Enable OpacAddMastheadLibraryPulldown system preference 2 - Ensure branches and groups show as before patch 3 - Ensure single and multibranch limits from masthead apply as expected 4 - Test advanced search page, ensure you cannot select both single and multibranch limit 5 - Follow test plan on 28845 - ensure multibranch limit still correctly pre-selected Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Joonas Kylmälä Signed-off-by: Kyle M Hall --- C4/Auth.pm | 2 +- .../prog/en/modules/catalogue/advsearch.tt | 31 +++++++++++++------ .../bootstrap/en/includes/masthead.inc | 10 +++--- .../bootstrap/en/modules/opac-advsearch.tt | 21 +++++++++++-- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index c98a65813a..f6a2e40c9a 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -561,7 +561,7 @@ sub get_template_and_user { if ( ( $opac_limit_override && $opac_search_limit && $opac_search_limit =~ /branch:([\w-]+)/ ) || ( $in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /branch:([\w-]+)/ ) || - ( $in->{'query'}->param('multibranchlimit') && $in->{'query'}->param('multibranchlimit') =~ /multibranchlimit-(\w+)/ ) + ( $in->{'query'}->param('limit') && $in->{'query'}->param('limit') =~ /multibranchlimit:(\w+)/ ) ) { $opac_name = $1; # opac_search_limit is a branch, so we use it. } elsif ( $in->{'query'}->param('multibranchlimit') ) { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index a4d7c6d9d7..f46e93a93c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -289,17 +289,16 @@ [%# FIXME Should not we filter the libraries displayed? %] [% PROCESS options_for_libraries prefix => "branch:" libraries => Branches.all( unfiltered => 1, do_not_select_my_library => 1 ) %]

- [% IF search_groups %] -

OR

+

OR

- [% FOREACH sg IN search_groups %] [% UNLESS sg.branchcode %] - + [% END %] [% END %] @@ -338,6 +337,7 @@ dad.appendChild(line.cloneNode(true)); line.removeChild(ButtonPlus); } + var Sticky; $(document).ready(function() { $("input[name=q]:eq(0)").focus(); @@ -347,13 +347,24 @@ stickTo: ".main", stickyClass: "floating" }); - $("#branchloop").on("change",function(){ - if( this.value != ""){ - document.getElementById("categoryloop").disabled=true; - } else { - document.getElementById("categoryloop").disabled=false; + [% IF search_groups %] + function branch_limit() { + if( $("#branchloop").val() != "" ){ + $("#categoryloop").val("").prop('disabled',true); + } else { + $("#categoryloop").prop('disabled',false); + } + if ( $("#categoryloop").val() != "" ){ + $("#branchloop").val("").prop('disabled',true); + } else { + $("#branchloop").prop('disabled',false); + } } - }); + branch_limit(); + $("#branchloop,#categoryloop").on("change",function(){ + branch_limit(); + }); + [% END %] [% IF searchid %] browser = KOHA.browser('[% searchid | html %]'); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 95b94932b1..9d661b8660 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -234,7 +234,7 @@ [% IF ( Koha.Preference( 'OpacAddMastheadLibraryPulldown' ) == 1 ) %]

- [% IF LibrarySearchGroups %][% END %] @@ -252,9 +252,9 @@ [% FOREACH lsg IN LibrarySearchGroups %] [% IF 'multibranchlimit-' _ lsg.id == opac_name || lsg.id == opac_name %] - + [% ELSE %] - + [% END # / bc.selected %] [% END %] @@ -267,8 +267,8 @@ [% ELSE %] [% IF ( opac_limit_override ) %] [% IF ( opac_search_limit ) %] - [% IF ( multibranchlimit = opac_search_limit.match( 'branch:(multibranchlimit-\d+)' ) ) %] - + [% IF ( multibranchlimit = opac_search_limit.match( 'branch:multibranchlimit-(\d+)' ) ) %] + [% ELSE %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index 273f19e070..7735d38b48 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -244,10 +244,10 @@ [% IF search_groups %]

OR

- [% FOREACH sg IN search_groups %] - + [% END %] [% END %] @@ -455,7 +455,24 @@ [% Asset.js("lib/jquery/plugins/jquery.deserialize.min.js") | $raw %] [% Asset.js("lib/jquery/plugins/jquery.cookie.min.js") | $raw %]