Bug 23271: Remove 'selecteds' from Branches

Restoring the first version of this from the first patch and reverting
what hit master first.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-04-13 15:47:30 +02:00
parent 10b82a72fa
commit bfdb4961d9
4 changed files with 13 additions and 22 deletions

View file

@ -58,8 +58,7 @@ sub GetURL {
sub all {
my ( $self, $params ) = @_;
my $selected = $params->{selected};
my $selecteds = $params->{selecteds};
my $selected = $params->{selected} || ();
my $unfiltered = $params->{unfiltered} || 0;
my $search_params = $params->{search_params} || {};
my $do_not_select_my_library = $params->{do_not_select_my_library} || 0; # By default we select the library of the logged in user if no selected passed
@ -77,26 +76,18 @@ sub all {
? Koha::Libraries->search( $search_params, { order_by => ['branchname'] } )->unblessed
: Koha::Libraries->search_filtered( $search_params, { order_by => ['branchname'] } )->unblessed;
if (defined $selecteds) {
# For a select multiple, must be a Koha::Libraries
my @selected_branchcodes = $selecteds ? $selecteds->get_column( ['branchcode'] ) : ();
$libraries = [ map {
my $l = $_;
$l->{selected} = 1
if grep { $_ eq $l->{branchcode} } @selected_branchcodes;
$l;
} @$libraries ];
}
else {
for my $l ( @$libraries ) {
if ( defined $selected and $l->{branchcode} eq $selected
or not defined $selected and C4::Context->userenv and $l->{branchcode} eq ( C4::Context->userenv->{branch} // q{} )
) {
$l->{selected} = 1;
}
for my $l (@$libraries) {
if ( grep { $l->{branchcode} eq $_ } @selected
or not @selected
and not $do_not_select_my_library
and C4::Context->userenv
and $l->{branchcode} eq ( C4::Context->userenv->{branch} // q{} ) )
{
$l->{selected} = 1;
}
}
return $libraries;
}

View file

@ -218,7 +218,7 @@
<li><label for="branches">Library limitations: </label>
<select id="branches" name="branches" multiple size="10">
<option value="">All libraries</option>
[% PROCESS options_for_libraries libraries => Branches.all( selecteds => category.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
[% PROCESS options_for_libraries libraries => Branches.all( selected => category.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
</select>
<span>Select <em>All libraries</em> if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value.
</span>

View file

@ -376,7 +376,7 @@ Item types &rsaquo; Administration &rsaquo; Koha
<li><label for="branches">Library limitation: </label>
<select id="branches" name="branches" multiple size="10">
<option value="">All libraries</option>
[% PROCESS options_for_libraries libraries => Branches.all( selecteds => itemtype.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
[% PROCESS options_for_libraries libraries => Branches.all( selected => itemtype.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %]
</select>
<span class="hint">Select 'All libraries' if all libraries use this item type. Otherwise, select the specific libraries that use this item type.</span>
</li>

View file

@ -214,7 +214,7 @@ Patron attribute types &rsaquo; Administration &rsaquo; Koha
<li><label for="branches">Library limitation: </label>
<select id="branches" name="branches" multiple size="10">
<option value="">All libraries</option>
[% PROCESS options_for_libraries libraries => Branches.all( selecteds => attribute_type.library_limits ) %]
[% PROCESS options_for_libraries libraries => Branches.all( selected => attribute_type.library_limits ) %]
</select>
<div class="hint">Select "All libraries" if this attribute type should always be displayed. Otherwise select libraries you want to associate with this value.
</div>