From 1f5e3b66f8a69b10cca12e0a1f8b0bc02f01431e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 7 Nov 2024 09:40:03 +0100 Subject: [PATCH] Bug 38130: Allow sorting and filtering on library id and name On the item list of the bib detail page and the patron search we want the library columns ('holding library', 'home library' and 'library') to be sorted by library names and to make them searchable on library id and name. Concerns about this approach (comment #8): """ If we do it for the library names on this view, we need to do it for all the library columns (thinking about patrons right now but I am sure there are others). And to be consistent, for all the other coded values: "special AVs" (item types, cn source), regular AVs, patron category codes, etc. We will introduce additional JOINs and so maybe performance problems. This needs to be investigated before we take this route IMO. """ Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- Koha/Patron.pm | 2 +- Koha/Schema/Result/Borrower.pm | 7 +++++++ .../html_helpers/tables/items/catalogue_detail.inc | 4 ++-- .../intranet-tmpl/prog/en/includes/patron-search.inc | 9 ++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index bc031f8bcf..26ba7a24df 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -505,7 +505,7 @@ Returns a Koha::Library object representing the patron's home library. sub library { my ( $self ) = @_; - return Koha::Library->_new_from_dbic($self->_result->branchcode); + return Koha::Library->_new_from_dbic($self->_result->library); } =head3 sms_provider diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index bf8ba36030..fddaf77201 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -2191,6 +2191,13 @@ __PACKAGE__->many_to_many("permissions", "user_permissions", "permission"); # Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-05-02 11:36:36 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jUOMoSonNmA3KwtZKVxqOA +__PACKAGE__->belongs_to( + "library", + "Koha::Schema::Result::Branch", + { branchcode => "branchcode" }, + { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" }, +); + __PACKAGE__->has_many( "restrictions", "Koha::Schema::Result::BorrowerDebarment", 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 eb7ac8e0ea..c115c12322 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 @@ -372,7 +372,7 @@ }, [% END %] { - data: "me.holding_library_id:holding_library.name", + data: "holding_library.name:me.holding_library_id", className: "location", searchable: true, orderable: true, @@ -381,7 +381,7 @@ } }, { - data: "me.home_library_id:home_library.name", + data: "home_library.name:me.home_library_id", className: "homebranch", searchable: true, orderable: true, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc index 857ea3fc3f..5a0fa0d13d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc @@ -574,15 +574,14 @@ } [% CASE 'branch' %] { - "data": "library_id", + "data": "library.name:me.library_id", "searchable": true, "orderable": true, "render": function( data, type, row, meta ) { - let library_name = libraries_map[data].branchname - if( !singleBranchMode && data == logged_in_library_id ) { - return "" + escape_str(library_name) + ""; + if( !singleBranchMode && row.library.library_id == logged_in_library_id ) { + return "" + escape_str(row.library.name) + ""; } else { - return escape_str(library_name); + return escape_str(row.library.name); } } } -- 2.39.5