From a5ace06893bc60fa324bf5ba4cec1a8b8f6171d6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 Oct 2023 16:50:10 +0200 Subject: [PATCH] Bug 33568: Follow-up for 29523 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- .../html_helpers/tables/items/catalogue_detail.inc | 14 ++++++++++++-- .../prog/en/includes/js-patron-format.inc | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) 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 9ff4e401fb..42dcfe3487 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 @@ -172,6 +172,7 @@ e["_str"] = e["branchname"]; return e; }); + const libraries_names = new Map(all_libraries.map( l => [l.branchcode, l.branchname] )); const all_item_types = [% To.json(ItemTypes.Get) | $raw %]; const item_types_filters = all_item_types.map(e => { e["_id"] = e["itemtype"]; @@ -437,13 +438,16 @@ render: function (data, type, row, meta) { let nodes = ""; if ( row.checkout ) { + [%# Hacky for patron_to_html in case we simply want to display the patron's library name %] + row.checkout.patron.library = { name: libraries_names.get(row.checkout.patron.library_id) }; + nodes += ''; if ( row.checkout.onsite_checkout ) { - let patron_to_html = $patron_to_html(row.checkout.patron); [%# FIXME What about hide_patron_infos_if_needed?? %] + let patron_to_html = $patron_to_html(row.checkout.patron); nodes += _("Currently in local use by %s").format(patron_to_html); } else { nodes += ''; - let patron_to_html = $patron_to_html(row.checkout.patron); [%# FIXME What about hide_patron_infos_if_needed?? %] + let patron_to_html = $patron_to_html(row.checkout.patron); nodes += _("Checked out to %s").format(patron_to_html); } nodes += ': '; @@ -486,6 +490,9 @@ } [% IF Koha.Preference('canreservefromotherbranches') %] if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) { + [%# Hacky for patron_to_html in case we simply want to display the patron's library name %] + row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) }; + let patron_to_html = $patron_to_html(row.first_hold.patron); [%# FIXME What about hide_patron_infos_if_needed?? %] nodes += ' %s'.format(_("Hold for: %s").format(patron_to_html)); } @@ -500,6 +507,9 @@ if ( row.recall.waiting_date ) { nodes += '%s'.format(_("Waiting at %s since %s").format(escape_str(row.recall.pickup_library_id.str), $date(row.recall.waiting_date))); } else { + [%# Hacky for patron_to_html in case we simply want to display the patron's library name %] + row.recall.patron.library = { name: libraries_names.get(row.recall.patron.library_id) }; + let patron_to_html = $patron_to_html(row.recall.patron); nodes += '%s'.format(_("recalled by %s on %s").format(patron_to_html, $date(row.recall.created_date))) } diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc index 3f8cb940ee..a7fb8ad49b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc @@ -49,6 +49,10 @@ } } + if ( name.replace(' ', '').length == 0 ) { + name = _("A patron from library %s".format(patron.library.name)); + } + return name; }; })(); -- 2.39.5