|
Lines 190-195
Link Here
|
| 190 |
} |
190 |
} |
| 191 |
|
191 |
|
| 192 |
$(document).ready(function () { |
192 |
$(document).ready(function () { |
|
|
193 |
var librariesWhereCanEdit = [% libraries_where_can_edit_json | $raw %]; |
| 194 |
var canEditAnyLibrary = librariesWhereCanEdit.length === 0; |
| 195 |
|
| 196 |
function canEditItem(homebranch) { |
| 197 |
if (canEditAnyLibrary) { |
| 198 |
return true; |
| 199 |
} |
| 200 |
return librariesWhereCanEdit.includes(homebranch); |
| 201 |
} |
| 202 |
|
| 193 |
var oneYearAgo = new Date(); |
203 |
var oneYearAgo = new Date(); |
| 194 |
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1); |
204 |
oneYearAgo.setFullYear(oneYearAgo.getFullYear() - 1); |
| 195 |
var today = new Date(); |
205 |
var today = new Date(); |
|
Lines 365-381
Link Here
|
| 365 |
{ |
375 |
{ |
| 366 |
data: function (row, type) { |
376 |
data: function (row, type) { |
| 367 |
if (type === "display") { |
377 |
if (type === "display") { |
| 368 |
return ( |
378 |
var canEdit = canEditItem(row.home_library_id); |
| 369 |
'<button class="btn btn-sm btn-default restore-item" data-item-id="' + |
379 |
var disabled = canEdit ? '' : ' disabled'; |
|
|
380 |
var button = '<button class="btn btn-sm btn-default restore-item" data-item-id="' + |
| 370 |
row.item_id + |
381 |
row.item_id + |
| 371 |
'" data-barcode="' + |
382 |
'" data-barcode="' + |
| 372 |
$("<div/>") |
383 |
$("<div/>") |
| 373 |
.text(row.external_id || row.item_id) |
384 |
.text(row.external_id || row.item_id) |
| 374 |
.html() + |
385 |
.html() + |
| 375 |
'"><i class="fa fa-undo" aria-hidden="true"></i> ' + |
386 |
'"' + disabled + '><i class="fa fa-undo" aria-hidden="true"></i> ' + |
| 376 |
_("Restore") + |
387 |
_("Restore") + |
| 377 |
"</button>" |
388 |
"</button>"; |
| 378 |
); |
389 |
|
|
|
390 |
if (!canEdit) { |
| 391 |
return '<span title="' + _("You do not have permission to restore items from this library") + '" style="cursor: not-allowed;">' + button + '</span>'; |
| 392 |
} |
| 393 |
return button; |
| 379 |
} |
394 |
} |
| 380 |
return ""; |
395 |
return ""; |
| 381 |
}, |
396 |
}, |
|
Lines 422-428
Link Here
|
| 422 |
{ |
437 |
{ |
| 423 |
data: function (row, type) { |
438 |
data: function (row, type) { |
| 424 |
if (type === "display") { |
439 |
if (type === "display") { |
| 425 |
return '<input type="checkbox" class="item-checkbox" data-item-id="' + row.item_id + '">'; |
440 |
var canEdit = canEditItem(row.home_library_id); |
|
|
441 |
var disabled = canEdit ? '' : ' disabled'; |
| 442 |
var checkbox = '<input type="checkbox" class="item-checkbox" data-item-id="' + row.item_id + '"' + disabled + '>'; |
| 443 |
|
| 444 |
if (!canEdit) { |
| 445 |
return '<span title="' + _("You do not have permission to restore items from this library") + '">' + checkbox + '</span>'; |
| 446 |
} |
| 447 |
return checkbox; |
| 426 |
} |
448 |
} |
| 427 |
return ""; |
449 |
return ""; |
| 428 |
}, |
450 |
}, |
|
Lines 462-468
Link Here
|
| 462 |
orderable: true, |
484 |
orderable: true, |
| 463 |
render: function (data, type, row) { |
485 |
render: function (data, type, row) { |
| 464 |
if (type === "display") { |
486 |
if (type === "display") { |
| 465 |
return data ? $("<div/>").text(data).html() : ""; |
487 |
var text = data ? $("<div/>").text(data).html() : ""; |
|
|
488 |
var canEdit = canEditItem(data); |
| 489 |
if (!canEdit) { |
| 490 |
text += ' <span class="badge bg-warning text-dark">' + _("No permission") + '</span>'; |
| 491 |
} |
| 492 |
return text; |
| 466 |
} |
493 |
} |
| 467 |
return data || ""; |
494 |
return data || ""; |
| 468 |
}, |
495 |
}, |
|
Lines 570-576
Link Here
|
| 570 |
// Select all items checkbox |
597 |
// Select all items checkbox |
| 571 |
$("#select-all-items").on("change", function () { |
598 |
$("#select-all-items").on("change", function () { |
| 572 |
var checked = $(this).prop("checked"); |
599 |
var checked = $(this).prop("checked"); |
| 573 |
$(".item-checkbox").prop("checked", checked); |
600 |
$(".item-checkbox:not(:disabled)").prop("checked", checked); |
| 574 |
}); |
601 |
}); |
| 575 |
|
602 |
|
| 576 |
// Restore biblio with items |
603 |
// Restore biblio with items |