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 { sub all {
my ( $self, $params ) = @_; my ( $self, $params ) = @_;
my $selected = $params->{selected}; my $selected = $params->{selected} || ();
my $selecteds = $params->{selecteds};
my $unfiltered = $params->{unfiltered} || 0; my $unfiltered = $params->{unfiltered} || 0;
my $search_params = $params->{search_params} || {}; 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 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( $search_params, { order_by => ['branchname'] } )->unblessed
: Koha::Libraries->search_filtered( $search_params, { order_by => ['branchname'] } )->unblessed; : Koha::Libraries->search_filtered( $search_params, { order_by => ['branchname'] } )->unblessed;
if (defined $selecteds) { for my $l (@$libraries) {
# For a select multiple, must be a Koha::Libraries if ( grep { $l->{branchcode} eq $_ } @selected
my @selected_branchcodes = $selecteds ? $selecteds->get_column( ['branchcode'] ) : (); or not @selected
$libraries = [ map { and not $do_not_select_my_library
my $l = $_; and C4::Context->userenv
$l->{selected} = 1 and $l->{branchcode} eq ( C4::Context->userenv->{branch} // q{} ) )
if grep { $_ eq $l->{branchcode} } @selected_branchcodes; {
$l; $l->{selected} = 1;
} @$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;
}
} }
} }
return $libraries; return $libraries;
} }

View file

@ -218,7 +218,7 @@
<li><label for="branches">Library limitations: </label> <li><label for="branches">Library limitations: </label>
<select id="branches" name="branches" multiple size="10"> <select id="branches" name="branches" multiple size="10">
<option value="">All libraries</option> <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> </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>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> </span>

View file

@ -376,7 +376,7 @@ Item types &rsaquo; Administration &rsaquo; Koha
<li><label for="branches">Library limitation: </label> <li><label for="branches">Library limitation: </label>
<select id="branches" name="branches" multiple size="10"> <select id="branches" name="branches" multiple size="10">
<option value="">All libraries</option> <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> </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> <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> </li>

View file

@ -214,7 +214,7 @@ Patron attribute types &rsaquo; Administration &rsaquo; Koha
<li><label for="branches">Library limitation: </label> <li><label for="branches">Library limitation: </label>
<select id="branches" name="branches" multiple size="10"> <select id="branches" name="branches" multiple size="10">
<option value="">All libraries</option> <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> </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 class="hint">Select "All libraries" if this attribute type should always be displayed. Otherwise select libraries you want to associate with this value.
</div> </div>