From 690560c42bae439334ea961cd26aaf047fa5f3d7 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 2 Nov 2023 22:24:03 +0000 Subject: [PATCH] Bug 34234: Add sub for count and logic to additem page To Test: 1. EnableItemGroups 2. Find a record and add some new item groups with different display orders 3. Now edit an item on the record and scroll down to the dropdown underneath "+ Add to item group" 4. Notice that the values in the dropdown do not respect the display order. 5. Apply patch and restart_all 6. The display order should now be respected Signed-off-by: Owen Leonard --- Koha/Template/Plugin/ItemGroups.pm | 15 +++++++++++++++ cataloguing/additem.pl | 3 --- .../prog/en/modules/cataloguing/additem.tt | 10 +++++----- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Koha/Template/Plugin/ItemGroups.pm b/Koha/Template/Plugin/ItemGroups.pm index eda845d154..47844478d6 100644 --- a/Koha/Template/Plugin/ItemGroups.pm +++ b/Koha/Template/Plugin/ItemGroups.pm @@ -50,4 +50,19 @@ sub listGroups { ); } +=head3 count + +[% ItemGroups.count %] + +returns count of item groups on a particular bibliographic record + +=cut + +sub count { + my ( $self, $biblionumber ) = @_; + return Koha::Biblio::ItemGroups->search( + { biblio_id => $biblionumber }, + )->count; +} + 1; diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 1e397a0de2..a9fc80646f 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -752,14 +752,11 @@ if( my $default_location = C4::Context->preference('NewItemsDefaultLocation') ) $location_field->{marc_value}->{value} ||= $default_location; } -my @ig = Koha::Biblio::ItemGroups->search({ biblio_id => $biblionumber })->as_list(); #sort by display order -my @sorted_ig = sort { $a->display_order <=> $b->display_order } @ig; # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. $template->param( biblio => $biblio, items => \@items, - item_groups => \@sorted_ig, item_header_loop => \@header_value_loop, subfields => $subfields, itemnumber => $itemnumber, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index 6fe0ec6cdc..8014325538 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -4,6 +4,7 @@ [% USE Branches %] [% USE KohaDates %] [% USE Price %] +[% USE ItemGroups %] [% USE TablesSettings %] [% PROCESS 'i18n.inc' %] [% INCLUDE 'doc-head-open.inc' %] @@ -36,7 +37,7 @@ [% INCLUDE 'str/cataloging_additem.inc' %] [% Asset.js("js/cataloging_additem.js") | $raw %] @@ -249,18 +250,17 @@ [% IF op != 'add_item' %] [% END %] - -[% IF item_groups.size && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %] +[% IF ItemGroups.count(biblio.biblionumber) && op != 'saveitem' && CAN_user_editcatalogue_manage_item_groups %]
Add to item group - [% FOREACH ig IN item_groups %] + [% FOREACH ig IN ItemGroups.listGroups(biblio.biblionumber) %] [% END %]