From 869336f98e5cd34be799686618bbe6d7349f8044 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=utf8 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 Signed-off-by: Katrin Fischer --- 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 67eca6e6a6..5e4a55e8bb 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 ba261bfa00..6fa6bd7ae4 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 6f4a9d12e8..5c9a0d230d 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 1277166a8b..ff3edf6093 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 f850a1df93..ca5b0eddec 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.39.5