From eec3b92712d8504ee6a3351cf3d324d96c3a4bf3 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 23 Apr 2025 13:44:57 +0000 Subject: [PATCH] Bug 38395: Display bibliographic data for deleted biblios in holds history This patch adds deleted_biblio to the patron holds api and adjsuts the display to shwo the data for deleted items To test: - place a hold - cancel the hold - look in patron hold history, see the title - delete the biblio - reload patron hold history - you see a line with no title or author - apply patch, yarn build, restart_all - reload patron hold history - success, you see deleted title info - enable OPACHoldsHistory preference - sign in to OPAC as patron - confirm holds history shows deleted title info Signed-off-by: Roman Dolny Signed-off-by: Matt Blenkinsop --- Koha/Old/Hold.pm | 13 +++++++++++++ api/v1/swagger/definitions/hold.yaml | 5 +++++ api/v1/swagger/paths/holds.yaml | 1 + api/v1/swagger/paths/patrons_holds.yaml | 1 + .../prog/en/includes/js-biblio-format.inc | 3 +++ .../prog/en/modules/members/holdshistory.tt | 11 ++++++++--- .../bootstrap/en/includes/biblio-title.inc | 2 ++ .../bootstrap/en/modules/opac-holdshistory.tt | 9 +++++++-- 8 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Koha/Old/Hold.pm b/Koha/Old/Hold.pm index 8f97163c6eb..3d461e82a95 100644 --- a/Koha/Old/Hold.pm +++ b/Koha/Old/Hold.pm @@ -23,6 +23,7 @@ use base qw(Koha::Hold); use C4::Context; use Koha::Exceptions::SysPref; +use Koha::Old::Biblios; =head1 NAME @@ -47,6 +48,18 @@ sub biblio { return Koha::Biblio->_new_from_dbic($rs); } +=head3 deleted_biblio + +Returns the related Koha::Deletedbiblio object for this old hold + +=cut + +sub deleted_biblio { + my ($self) = @_; + my $db = $self->_result->deleted_biblionumber; + return Koha::Old::Biblios->find($db); +} + =head3 item Returns the related Koha::Item object for this old Hold diff --git a/api/v1/swagger/definitions/hold.yaml b/api/v1/swagger/definitions/hold.yaml index 48dadf8a5fb..810f2647db0 100644 --- a/api/v1/swagger/definitions/hold.yaml +++ b/api/v1/swagger/definitions/hold.yaml @@ -120,6 +120,11 @@ properties: - object - "null" description: Bibliographic record + deleted_biblio: + type: + - object + - "null" + description: Deleted bibliographic record item: type: - object diff --git a/api/v1/swagger/paths/holds.yaml b/api/v1/swagger/paths/holds.yaml index a6aff1b75c2..cac66270182 100644 --- a/api/v1/swagger/paths/holds.yaml +++ b/api/v1/swagger/paths/holds.yaml @@ -103,6 +103,7 @@ enum: - cancellation_requested - biblio + - deleted_biblio - pickup_library collectionFormat: csv produces: diff --git a/api/v1/swagger/paths/patrons_holds.yaml b/api/v1/swagger/paths/patrons_holds.yaml index 1915f427343..827cffd8bb8 100644 --- a/api/v1/swagger/paths/patrons_holds.yaml +++ b/api/v1/swagger/paths/patrons_holds.yaml @@ -30,6 +30,7 @@ enum: - cancellation_requested - biblio + - deleted_biblio - item - pickup_library - pickup_library.branchname diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js-biblio-format.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js-biblio-format.inc index 8a5dfee946a..e3cbd9c8507 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/js-biblio-format.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js-biblio-format.inc @@ -19,6 +19,9 @@ title = escape_str(biblio.biblio_id); } else { title = ''; + if (config && config.deleted) { + title += _("(Bibliographic record deleted) "); + } if (biblio.title != null && biblio.title != "") { title += escape_str(biblio.title); } else { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt index c92931f13d3..57d9ff16dde 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt @@ -207,14 +207,18 @@ url: table_url, }, order: [], - embed: ['biblio', 'item', 'pickup_library', 'pickup_library.branchname'], + embed: ['biblio', 'deleted_biblio', 'item', 'pickup_library', 'pickup_library.branchname'], columns: [ { data: "biblio.title:biblio.subtitle:biblio.medium", searchable: true, orderable: true, render: function (data, type, row, meta) { - return $biblio_to_html(row.biblio, { link: 1 }); + if( row.biblio ){ + return $biblio_to_html(row.biblio, { link: 1 }); + } else { + return $biblio_to_html(row.deleted_biblio, { link: 0, deleted: 1 }); + } } }, { @@ -222,7 +226,8 @@ searchable: true, orderable: true, render: function (data, type, row, meta) { - return row.biblio ? row.biblio.author : "" ; + let biblio = row.biblio ? row.biblio : row.deleted_biblio; + return biblio ? biblio.author : ""; } }, { diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc index b98c02b9090..d37640599f1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/biblio-title.inc @@ -1,6 +1,8 @@ [%- IF link && ! biblio %][% link = 0 %][% END %] [%- IF ( link ) -%] [% PROCESS 'show-biblio-title' %] +[%- ELSIF (deleted) -%] + (Deleted bibliographic record) [%- PROCESS 'show-biblio-title' -%] [%- ELSE -%] [%- PROCESS 'show-biblio-title' -%] [%- END -%] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt index 2ee1960b2f5..42aca8193ac 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-holdshistory.tt @@ -107,8 +107,13 @@ [% FOREACH hold IN holds %] - [% INCLUDE 'biblio-title.inc' biblio=hold.biblio link=>1 %] - [% hold.biblio.author | html %] + [% IF hold.biblio %] + [% INCLUDE 'biblio-title.inc' biblio=hold.biblio link=>1 %] + [% hold.biblio.author | html %] + [% ELSE %] + [% INCLUDE 'biblio-title.inc' biblio=hold.deleted_biblio link=>0 deleted=>1 %] + [% hold.deleted_biblio.author | html %] + [% END %] [% hold.item.barcode | html %] [% Branches.GetName( hold.branchcode ) | html %] [% hold.reservedate | $KohaDates %] -- 2.48.1