Bug 28847: Cleanup of branch limitsand fix OPAC_SEARCH_LIMIT

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 <andrew@bywatersolutions.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Nick Clemens 2021-08-12 11:13:46 +00:00 committed by Jonathan Druart
parent d8b86ac693
commit 065ec4e726
4 changed files with 46 additions and 18 deletions

View File

@ -559,7 +559,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') ) {

View File

@ -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 ) %]
</select></p>
<!-- <input type="hidden" name="limit" value="branch: MAIN" /> -->
[% IF search_groups %]
<p>OR</p> <!-- should addjs to grey out group pulldown if a library is selected. -->
<p>OR</p>
<p>
<label for="categoryloop">Groups of libraries: </label>
<select name="multibranchlimit" id="categoryloop">
<select name="limit" id="categoryloop">
<option value=""> -- none -- </option>
[% FOREACH sg IN search_groups %]
[% UNLESS sg.branchcode %]
<option value="[% sg.id | html %]">[% sg.title | html %]</option>
<option value="multibranchlimit:[% sg.id | html %]">[% sg.title | html %]</option>
[% END %]
[% END %]
</select>
@ -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 %]');

View File

@ -234,7 +234,7 @@
[% IF ( Koha.Preference( 'OpacAddMastheadLibraryPulldown' ) == 1 ) %]
<div class="col-sm col-md-3 col-lg-2 order-3 order-sm-4">
<select name="branch_group_limit" id="select_library" class="form-control">
<select name="limit" id="select_library" class="form-control">
<option value="">All libraries</option>
[% IF LibrarySearchGroups %]<optgroup label="Libraries">[% END %]
@ -252,9 +252,9 @@
<optgroup label="Groups">
[% FOREACH lsg IN LibrarySearchGroups %]
[% IF 'multibranchlimit-' _ lsg.id == opac_name || lsg.id == opac_name %]
<option selected="selected" value="multibranchlimit-[% lsg.id | html %]">[% lsg.title | html %]</option>
<option selected="selected" value="multibranchlimit:[% lsg.id | html %]">[% lsg.title | html %]</option>
[% ELSE %]
<option value="multibranchlimit-[% lsg.id | html %]">[% lsg.title | html %]</option>
<option value="multibranchlimit:[% lsg.id | html %]">[% lsg.title | html %]</option>
[% END # / bc.selected %]
[% END %]
</optgroup>
@ -267,8 +267,8 @@
[% ELSE %]
[% IF ( opac_limit_override ) %]
[% IF ( opac_search_limit ) %]
[% IF ( multibranchlimit = opac_search_limit.match( 'branch:(multibranchlimit-\d+)' ) ) %]
<input name="branch_group_limit" value="[% multibranchlimit.0 | html %]" type="hidden" />
[% IF ( multibranchlimit = opac_search_limit.match( 'branch:multibranchlimit-(\d+)' ) ) %]
<input name="limit" value="multibranchlimit:[% multibranchlimit.0 | html %]" type="hidden" />
[% ELSE %]
<input name="limit" value="[% opac_search_limit | html %]" type="hidden" />
[% END %]

View File

@ -244,10 +244,10 @@
[% IF search_groups %]
<p>OR</p>
<label for="categoryloop">Groups of libraries</label>
<select name="multibranchlimit" id="categoryloop">
<select name="limit" id="categoryloop">
<option value=""> -- none -- </option>
[% FOREACH sg IN search_groups %]
<option value="[% sg.id | html %]">[% sg.title | html %]</option>
<option value="multibranchlimit:[% sg.id | html %]">[% sg.title | html %]</option>
[% END %]
</select>
[% 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 %]
<script>
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);
}
}
$(document).ready(function() {
branch_limit();
$("#branchloop,#categoryloop").on("change",function(){
branch_limit();
});
$('#advsearches').tabs();
jQuery.cookie.json = true;
//$('#advsearches > ul').tabs();