From e98c202bc3a91b40c2652c356b15c435b67bc00b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 18 Apr 2023 09:57:03 +0200 Subject: [PATCH] Bug 33568: Item groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FIXME - we need tests, but I'd like to make sure there is no an easier way to do this many to many things. Tomas? Filter on the "Item group" column needs to be tested! Signed-off-by: Owen Leonard Signed-off-by: Laurence Rault Signed-off-by: Emily Lamancusa Signed-off-by: Tomás Cohen Arazi --- Koha/Biblio/ItemGroup/Item.pm | 14 ++++++++++++++ Koha/Item.pm | 8 ++++++++ api/v1/swagger/definitions/item.yaml | 4 ++++ api/v1/swagger/paths/biblios.yaml | 1 + .../prog/en/modules/catalogue/detail.tt | 13 ++++++++++--- 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Koha/Biblio/ItemGroup/Item.pm b/Koha/Biblio/ItemGroup/Item.pm index 67eca6e6a61..5e4a55e8bb8 100644 --- a/Koha/Biblio/ItemGroup/Item.pm +++ b/Koha/Biblio/ItemGroup/Item.pm @@ -19,12 +19,26 @@ use Modern::Perl; use base qw(Koha::Object); +use Koha::Biblio::ItemGroup; + =head1 NAME Koha::Biblio::ItemGroup::Item - Koha ItemGroup Item Object class =head1 API +=head2 Class methods + +=head3 item_group + +=cut + +sub item_group { + my ($self) = @_; + my $rs = $self->_result->item_group; + return Koha::Biblio::ItemGroup->_new_from_dbic($rs); +} + =head2 Internal methods =head3 _type diff --git a/Koha/Item.pm b/Koha/Item.pm index ba261bfa006..6fa6bd7ae43 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -465,6 +465,14 @@ sub item_group { return $item_group; } +sub item_group_item { + my ( $self ) = @_; + my $rs = $self->_result->item_group_item; + return unless $rs; + return Koha::Biblio::ItemGroup::Item->_new_from_dbic($rs); +} + + =head3 return_claims my $return_claims = $item->return_claims; diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml index 6f4a9d12e80..5c9a0d230d4 100644 --- a/api/v1/swagger/definitions/item.yaml +++ b/api/v1/swagger/definitions/item.yaml @@ -234,6 +234,10 @@ properties: type: - array - "null" + item_group_item: + type: + - object + - "null" _strings: type: - object diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index 1277166a8b8..ff3edf6093a 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -424,6 +424,7 @@ enum: - +strings - cover_image_ids + - item_group_item.item_group.description collectionFormat: csv - $ref: "../swagger.yaml#/parameters/match" - $ref: "../swagger.yaml#/parameters/order_by" diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index f850a1df93b..ca5b0eddec3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -2495,6 +2495,9 @@ [% IF Koha.Preference('LocalCoverImages') %] embed.push('cover_image_ids'); [% END %] + [% IF Koha.Preference('EnableItemGroups') %] + embed.push('item_group_item.item_group.description'); + [% END %] let table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %]; var items_table = $("#table_items").kohaTable({ ajax: { url: table_url }, @@ -2605,12 +2608,16 @@ }, [% IF Koha.Preference('EnableItemGroups') %] { - data: "", + data: "item_group_item.item_group.description", className: "item_group", - searchable: false, // FIXME + searchable: true, orderable: true, render: function (data, type, row, meta) { - return "item.item_group.description";// FIXME item.item_group.description + if ( row.item_group_item ) { + return row.item_group_item.item_group.description; + } else { + return ""; + } } }, [% END %] -- 2.34.1