From 67d480f625655becef388160f8afde0a06587b09 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 2 Jun 2023 09:36:11 +0200 Subject: [PATCH] Bug 33568: Add search on home and holding library's names MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit QUESTION - Do we prefer this or a dropdown list in the column filter header? 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/Item.pm | 25 ++++++++++++++++++- Koha/Schema/Result/Item.pm | 24 ++++++++++++++++++ api/v1/swagger/definitions/item.yaml | 8 ++++++ api/v1/swagger/paths/biblios.yaml | 2 ++ .../tables/items/catalogue_detail.inc | 5 ++-- 5 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Koha/Item.pm b/Koha/Item.pm index 17f4ebfe59..aa24218876 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -385,8 +385,19 @@ sub effective_itemtype { =cut sub home_branch { - my ($self) = @_; + return shift->home_library(@_); +} + +=head3 home_library + +my $library = $item->home_library +Return the Koha::Library object representing the home library + +=cut + +sub home_library { + my ($self) = @_; my $hb_rs = $self->_result->homebranch; return Koha::Library->_new_from_dbic( $hb_rs ); @@ -397,6 +408,18 @@ sub home_branch { =cut sub holding_branch { + return shift->home_library(@_); +} + +=head3 holding_library + +my $library = $item->holding_library + +Return the Koha::Library object representing the holding library + +=cut + +sub holding_library { my ($self) = @_; my $hb_rs = $self->_result->holdingbranch; diff --git a/Koha/Schema/Result/Item.pm b/Koha/Schema/Result/Item.pm index 8320ce4c76..84a0bb8405 100644 --- a/Koha/Schema/Result/Item.pm +++ b/Koha/Schema/Result/Item.pm @@ -995,6 +995,30 @@ __PACKAGE__->belongs_to( { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, ); +__PACKAGE__->belongs_to( + "holding_library", + "Koha::Schema::Result::Branch", + { branchcode => "holdingbranch" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "RESTRICT", + on_update => "CASCADE", + }, +); + +__PACKAGE__->belongs_to( + "home_library", + "Koha::Schema::Result::Branch", + { branchcode => "homebranch" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "RESTRICT", + on_update => "CASCADE", + }, +); + __PACKAGE__->add_columns( '+bookable' => { is_boolean => 1 }, '+exclude_from_local_holds_priority' => { is_boolean => 1 }, diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml index 5dbde98c70..e74dc1b90f 100644 --- a/api/v1/swagger/definitions/item.yaml +++ b/api/v1/swagger/definitions/item.yaml @@ -230,6 +230,14 @@ properties: type: - object - "null" + home_library: + type: + - object + - "null" + holding_library: + type: + - object + - "null" cover_image_ids: type: - array diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml index 4e94d04128..24d64d0ed4 100644 --- a/api/v1/swagger/paths/biblios.yaml +++ b/api/v1/swagger/paths/biblios.yaml @@ -423,6 +423,8 @@ type: string enum: - +strings + - home_library + - holding_library - biblio.title - checkout - checkout.patron diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index 5b389c90f6..c3d1092930 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -179,6 +179,7 @@ [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %] let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?"; let embed = ["+strings,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk,item_type"]; + embed.push('home_library', 'holding_library'); [% IF Koha.Preference('LocalCoverImages') %] embed.push('cover_image_ids'); [% END %] @@ -300,7 +301,7 @@ }, [% END %] { - data: "me.holding_library_id", + data: "me.holding_library_id:holding_library.name", className: "location", searchable: true, orderable: true, @@ -309,7 +310,7 @@ } }, { - data: "me.home_library_id", + data: "me.home_library_id:home_library.name", className: "homebranch", searchable: true, orderable: true, -- 2.39.5