|
Lines 77-82
Link Here
|
| 77 |
</div> |
77 |
</div> |
| 78 |
[% END #/ WRAPPER main-container.inc %] |
78 |
[% END #/ WRAPPER main-container.inc %] |
| 79 |
|
79 |
|
|
|
80 |
<!-- Modal for deleted biblio warning --> |
| 81 |
<div class="modal" id="deletedBiblioModal" tabindex="-1" role="dialog" aria-labelledby="deletedBiblioModalLabel"> |
| 82 |
<div class="modal-dialog" role="document"> |
| 83 |
<div class="modal-content"> |
| 84 |
<div class="modal-header"> |
| 85 |
<h4 class="modal-title" id="deletedBiblioModalLabel">Bibliographic record deleted</h4> |
| 86 |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> |
| 87 |
</div> |
| 88 |
<div class="modal-body"> |
| 89 |
<p>This item belongs to a deleted bibliographic record:</p> |
| 90 |
<dl> |
| 91 |
<dt>Biblio ID:</dt> |
| 92 |
<dd id="modal-biblio-id"></dd> |
| 93 |
<dt>Title:</dt> |
| 94 |
<dd id="modal-biblio-title"></dd> |
| 95 |
<dt>Author:</dt> |
| 96 |
<dd id="modal-biblio-author"></dd> |
| 97 |
</dl> |
| 98 |
<p><strong>You must restore the bibliographic record before restoring this item.</strong></p> |
| 99 |
</div> |
| 100 |
<div class="modal-footer"> |
| 101 |
<button type="button" class="btn btn-default" data-bs-dismiss="modal">Cancel</button> |
| 102 |
<button type="button" class="btn btn-primary" id="restore-biblio-button">Restore bibliographic record</button> |
| 103 |
</div> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
</div> |
| 107 |
|
| 80 |
[% MACRO jsinclude BLOCK %] |
108 |
[% MACRO jsinclude BLOCK %] |
| 81 |
[% Asset.js("js/tools-menu.js") | $raw %] |
109 |
[% Asset.js("js/tools-menu.js") | $raw %] |
| 82 |
[% INCLUDE 'datatables.inc' %] |
110 |
[% INCLUDE 'datatables.inc' %] |
|
Lines 165-170
Link Here
|
| 165 |
ajax: { |
193 |
ajax: { |
| 166 |
url: "/api/v1/deleted/items", |
194 |
url: "/api/v1/deleted/items", |
| 167 |
}, |
195 |
}, |
|
|
196 |
embed: "biblio", |
| 168 |
order: [[5, "desc"]], |
197 |
order: [[5, "desc"]], |
| 169 |
columns: [ |
198 |
columns: [ |
| 170 |
{ |
199 |
{ |
|
Lines 288-293
Link Here
|
| 288 |
var button = $(this); |
317 |
var button = $(this); |
| 289 |
var item_id = button.data("item-id"); |
318 |
var item_id = button.data("item-id"); |
| 290 |
var barcode = button.data("barcode"); |
319 |
var barcode = button.data("barcode"); |
|
|
320 |
var row = items_table_api.row(button.closest("tr")).data(); |
| 321 |
|
| 322 |
// Check if biblio is deleted |
| 323 |
if (row.biblio && row.biblio.deleted_on) { |
| 324 |
// Show modal with biblio info |
| 325 |
$("#modal-biblio-id").text(row.biblio.biblio_id); |
| 326 |
$("#modal-biblio-title").text(row.biblio.title || _("(No title)")); |
| 327 |
$("#modal-biblio-author").text(row.biblio.author || _("(No author)")); |
| 328 |
|
| 329 |
// Store the item and biblio data for later |
| 330 |
$("#restore-biblio-button").data("biblio-id", row.biblio.biblio_id); |
| 331 |
$("#restore-biblio-button").data("item-id", item_id); |
| 332 |
$("#restore-biblio-button").data("item-button", button); |
| 333 |
|
| 334 |
var modal = new bootstrap.Modal(document.getElementById("deletedBiblioModal")); |
| 335 |
modal.show(); |
| 336 |
return; |
| 337 |
} |
| 291 |
|
338 |
|
| 292 |
if (!confirm(_("Are you sure you want to restore item %s (%s)?").format(item_id, barcode))) { |
339 |
if (!confirm(_("Are you sure you want to restore item %s (%s)?").format(item_id, barcode))) { |
| 293 |
return; |
340 |
return; |
|
Lines 315-320
Link Here
|
| 315 |
}, |
362 |
}, |
| 316 |
}); |
363 |
}); |
| 317 |
}); |
364 |
}); |
|
|
365 |
|
| 366 |
// Restore biblio from modal |
| 367 |
$("#restore-biblio-button").on("click", function () { |
| 368 |
var button = $(this); |
| 369 |
var biblio_id = button.data("biblio-id"); |
| 370 |
var item_id = button.data("item-id"); |
| 371 |
var item_button = button.data("item-button"); |
| 372 |
|
| 373 |
button.prop("disabled", true); |
| 374 |
|
| 375 |
$.ajax({ |
| 376 |
url: "/api/v1/deleted/biblios/" + biblio_id, |
| 377 |
type: "PUT", |
| 378 |
headers: { |
| 379 |
"x-koha-request-id": Math.random(), |
| 380 |
}, |
| 381 |
success: function (data) { |
| 382 |
showMessage(_("Bibliographic record %s restored successfully").format(biblio_id), "success"); |
| 383 |
bootstrap.Modal.getInstance(document.getElementById("deletedBiblioModal")).hide(); |
| 384 |
biblios_table_api.ajax.reload(); |
| 385 |
items_table_api.ajax.reload(); |
| 386 |
button.prop("disabled", false); |
| 387 |
}, |
| 388 |
error: function (xhr) { |
| 389 |
var error_msg = _("Error restoring bibliographic record %s").format(biblio_id); |
| 390 |
if (xhr.responseJSON && xhr.responseJSON.error) { |
| 391 |
error_msg += ": " + xhr.responseJSON.error; |
| 392 |
} |
| 393 |
showMessage(error_msg, "danger"); |
| 394 |
button.prop("disabled", false); |
| 395 |
}, |
| 396 |
}); |
| 397 |
}); |
| 318 |
}); |
398 |
}); |
| 319 |
</script> |
399 |
</script> |
| 320 |
[% END %] |
400 |
[% END %] |
| 321 |
- |
|
|