From 7babc31202ab74a3c68a34c5a1d1a5dc921f5149 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 --- 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 1a5faa0b6c..08c2e5c3f6 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 67392d31c3..c882c8f9f5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -377,7 +377,7 @@ Data deleted
  • 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 f87e9cf4d8..23b8a27e35 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 @@
  • Select "All libraries" if this attribute type should always be displayed. Otherwise select libraries you want to associate with this value.
    -- 2.24.3 (Apple Git-128)