From bfdb4961d9e57a22a3e7dc6cdc10e86c5ff32e9e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 13 Apr 2021 15:47:30 +0200 Subject: [PATCH] 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 Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- Koha/Template/Plugin/Branches.pm | 29 +++++++------------ .../prog/en/modules/admin/categories.tt | 2 +- .../prog/en/modules/admin/itemtypes.tt | 2 +- .../en/modules/admin/patron-attr-types.tt | 2 +- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index c2da80d8d6..58b84d18e0 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -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; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index b8ea9b1fc8..768d1259fb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -218,7 +218,7 @@
  • Select All libraries if this category type must to be displayed all the time. Otherwise select libraries you want to associate with this value. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index 5f6b5603bf..cef07a000a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -376,7 +376,7 @@ Item types › Administration › Koha
  • Select 'All libraries' if all libraries use this item type. Otherwise, select the specific libraries that use this item type.
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index 91c2ef6603..04cf5ca8b6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -214,7 +214,7 @@ Patron attribute types › Administration › Koha
  • Select "All libraries" if this attribute type should always be displayed. Otherwise select libraries you want to associate with this value.
    -- 2.39.5