Bugzilla – Attachment 189092 Details for
Bug 17387
Add an undelete feature for items/biblios
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17387: add modal warning for items with deleted biblios
Bug-17387-add-modal-warning-for-items-with-deleted.patch (text/plain), 5.41 KB, created by
Jacob O'Mara
on 2025-11-05 15:39:44 UTC
(
hide
)
Description:
Bug 17387: add modal warning for items with deleted biblios
Filename:
MIME Type:
Creator:
Jacob O'Mara
Created:
2025-11-05 15:39:44 UTC
Size:
5.41 KB
patch
obsolete
>From 91af9d0cd090b61dacc550cac75be92b8968c688 Mon Sep 17 00:00:00 2001 >From: Jacob O'Mara <Jacob.omara@openfifth.co.uk> >Date: Thu, 30 Oct 2025 11:29:56 +0000 >Subject: [PATCH] Bug 17387: add modal warning for items with deleted biblios > >--- > .../prog/en/modules/tools/restore-records.tt | 80 +++++++++++++++++++ > 1 file changed, 80 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt >index 49d20120246..c0b48b85070 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/restore-records.tt >@@ -77,6 +77,34 @@ > </div> > [% END #/ WRAPPER main-container.inc %] > >+<!-- Modal for deleted biblio warning --> >+<div class="modal" id="deletedBiblioModal" tabindex="-1" role="dialog" aria-labelledby="deletedBiblioModalLabel"> >+ <div class="modal-dialog" role="document"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h4 class="modal-title" id="deletedBiblioModalLabel">Bibliographic record deleted</h4> >+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> >+ </div> >+ <div class="modal-body"> >+ <p>This item belongs to a deleted bibliographic record:</p> >+ <dl> >+ <dt>Biblio ID:</dt> >+ <dd id="modal-biblio-id"></dd> >+ <dt>Title:</dt> >+ <dd id="modal-biblio-title"></dd> >+ <dt>Author:</dt> >+ <dd id="modal-biblio-author"></dd> >+ </dl> >+ <p><strong>You must restore the bibliographic record before restoring this item.</strong></p> >+ </div> >+ <div class="modal-footer"> >+ <button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button> >+ <button type="button" class="btn btn-primary" id="restore-biblio-button">Restore bibliographic record</button> >+ </div> >+ </div> >+ </div> >+</div> >+ > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/tools-menu.js") | $raw %] > [% INCLUDE 'datatables.inc' %] >@@ -165,6 +193,7 @@ > ajax: { > url: "/api/v1/deleted/items", > }, >+ embed: "biblio", > order: [[5, "desc"]], > columns: [ > { >@@ -288,6 +317,24 @@ > var button = $(this); > var item_id = button.data("item-id"); > var barcode = button.data("barcode"); >+ var row = items_table_api.row(button.closest("tr")).data(); >+ >+ // Check if biblio is deleted >+ if (row.biblio && row.biblio.deleted_on) { >+ // Show modal with biblio info >+ $("#modal-biblio-id").text(row.biblio.biblio_id); >+ $("#modal-biblio-title").text(row.biblio.title || _("(No title)")); >+ $("#modal-biblio-author").text(row.biblio.author || _("(No author)")); >+ >+ // Store the item and biblio data for later >+ $("#restore-biblio-button").data("biblio-id", row.biblio.biblio_id); >+ $("#restore-biblio-button").data("item-id", item_id); >+ $("#restore-biblio-button").data("item-button", button); >+ >+ var modal = new bootstrap.Modal(document.getElementById("deletedBiblioModal")); >+ modal.show(); >+ return; >+ } > > if (!confirm(_("Are you sure you want to restore item %s (%s)?").format(item_id, barcode))) { > return; >@@ -315,6 +362,39 @@ > }, > }); > }); >+ >+ // Restore biblio from modal >+ $("#restore-biblio-button").on("click", function () { >+ var button = $(this); >+ var biblio_id = button.data("biblio-id"); >+ var item_id = button.data("item-id"); >+ var item_button = button.data("item-button"); >+ >+ button.prop("disabled", true); >+ >+ $.ajax({ >+ url: "/api/v1/deleted/biblios/" + biblio_id, >+ type: "PUT", >+ headers: { >+ "x-koha-request-id": Math.random(), >+ }, >+ success: function (data) { >+ showMessage(_("Bibliographic record %s restored successfully").format(biblio_id), "success"); >+ bootstrap.Modal.getInstance(document.getElementById("deletedBiblioModal")).hide(); >+ biblios_table_api.ajax.reload(); >+ items_table_api.ajax.reload(); >+ button.prop("disabled", false); >+ }, >+ error: function (xhr) { >+ var error_msg = _("Error restoring bibliographic record %s").format(biblio_id); >+ if (xhr.responseJSON && xhr.responseJSON.error) { >+ error_msg += ": " + xhr.responseJSON.error; >+ } >+ showMessage(error_msg, "danger"); >+ button.prop("disabled", false); >+ }, >+ }); >+ }); > }); > </script> > [% END %] >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17387
:
188670
|
188671
|
188672
|
188673
|
188674
|
188675
|
188676
|
188677
|
188678
|
188679
|
188680
|
188681
|
188682
|
188683
|
188684
|
188685
|
188686
|
188687
|
188688
|
188689
|
188690
|
188691
|
188692
|
188693
|
188694
|
188695
|
188696
|
188697
|
188698
|
188699
|
188700
|
188701
|
188780
|
188781
|
188782
|
188783
|
188784
|
188785
|
188786
|
188787
|
188788
|
188789
|
188790
|
188791
|
188792
|
188793
|
188794
|
188795
|
189046
|
189047
|
189048
|
189049
|
189050
|
189051
|
189052
|
189053
|
189054
|
189055
|
189056
|
189057
|
189058
|
189059
|
189060
|
189061
|
189062
|
189082
|
189083
|
189084
|
189085
|
189086
|
189087
|
189088
|
189089
|
189090
|
189091
|
189092
|
189093
|
189094
|
189095
|
189096
|
189097
|
189098
|
189099
|
189100
|
189101
|
189102
|
189103
|
189104
|
189105
|
189106
|
189107
|
189108
|
189109
|
189110
|
189111
|
189112
|
189113
|
189114
|
189115
|
189116
|
189117
|
189118
|
189119