|
Lines 1251-1256
Link Here
|
| 1251 |
|
1251 |
|
| 1252 |
[% MACRO jsinclude BLOCK %] |
1252 |
[% MACRO jsinclude BLOCK %] |
| 1253 |
[% INCLUDE 'calendar.inc' %] |
1253 |
[% INCLUDE 'calendar.inc' %] |
|
|
1254 |
<script> |
| 1255 |
const logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]"; |
| 1256 |
const managedby_patron_borrowernumber = "[% suggestion.manager.borrowernumber | html %]"; |
| 1257 |
const op = "[% op | html %]"; |
| 1258 |
</script> |
| 1259 |
|
| 1254 |
<script> |
1260 |
<script> |
| 1255 |
function select_manager(borrowernumber, borrower) { |
1261 |
function select_manager(borrowernumber, borrower) { |
| 1256 |
let tab = $('#suggestiontabs .active table').data('tab-name'); |
1262 |
let tab = $('#suggestiontabs .active table').data('tab-name'); |
|
Lines 1272-1291
Link Here
|
| 1272 |
managedby.val(borrowernumber); |
1278 |
managedby.val(borrowernumber); |
| 1273 |
} |
1279 |
} |
| 1274 |
|
1280 |
|
| 1275 |
[% IF op == "save" %] |
1281 |
if (op == "save"){ |
| 1276 |
var notify = $('#notify'); |
1282 |
var notify = $('#notify'); |
| 1277 |
if ( notify.length ) { |
1283 |
if ( notify.length ) { |
| 1278 |
[% IF suggestion.manager %] |
1284 |
if ((managedby_patron_borrowernumber && (borrowernumber == logged_in_user_borrowernumber || borrowernumber == managedby_patron_borrowernumber )) || (!managedby_patron_borrowernumber && borrowernumber == logged_in_user_borrowernumber )){ |
| 1279 |
if ( borrowernumber == [% logged_in_user.borrowernumber | html %] || borrowernumber == [% suggestion.manager.borrowernumber | html %] ) { |
|
|
| 1280 |
[% ELSE %] |
| 1281 |
if ( borrowernumber == [% logged_in_user.borrowernumber | html %] ) { |
| 1282 |
[% END %] |
| 1283 |
$(notify).prop('checked', false).prop('disabled', true); |
1285 |
$(notify).prop('checked', false).prop('disabled', true); |
| 1284 |
} else { |
1286 |
} else { |
| 1285 |
$(notify).prop('disabled', false); |
1287 |
$(notify).prop('disabled', false); |
| 1286 |
} |
1288 |
} |
| 1287 |
} |
1289 |
} |
| 1288 |
[% END %] |
1290 |
} |
| 1289 |
} |
1291 |
} |
| 1290 |
|
1292 |
|
| 1291 |
function select_suggester(borrowernumber, borrower) { |
1293 |
function select_suggester(borrowernumber, borrower) { |
|
Lines 1335-1346
Link Here
|
| 1335 |
</script> |
1337 |
</script> |
| 1336 |
[% END %] |
1338 |
[% END %] |
| 1337 |
[% IF op == 'else' %] |
1339 |
[% IF op == 'else' %] |
|
|
1340 |
<script> |
| 1341 |
const has_suggestions = [% suggestions.size ? 1 : 0 | html %]; |
| 1342 |
let suggestionData = [% To.json(suggestions) | $raw %]; |
| 1343 |
var suggestions_table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %] |
| 1344 |
addPermissions({ |
| 1345 |
CAN_user_suggestions_suggestions_manage: [% CAN_user_suggestions_suggestions_manage ? 1 : 0 | html %], |
| 1346 |
CAN_user_suggestions_suggestions_delete: [% CAN_user_suggestions_suggestions_delete ? 1 : 0 | html %], |
| 1347 |
}); |
| 1348 |
</script> |
| 1349 |
|
| 1338 |
[% INCLUDE 'datatables.inc' %] |
1350 |
[% INCLUDE 'datatables.inc' %] |
| 1339 |
<script> |
1351 |
<script> |
| 1340 |
$(document).ready(function() { |
1352 |
$(document).ready(function() { |
| 1341 |
[% IF suggestions.size %] |
1353 |
if (has_suggestions){ |
| 1342 |
let suggestionData = [% To.json(suggestions) | $raw %]; |
|
|
| 1343 |
var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %] |
| 1344 |
function loadDatatable(tabName) { |
1354 |
function loadDatatable(tabName) { |
| 1345 |
let tabSuggestionData = suggestionData.find(s => s.suggestiontype === `${tabName}`) |
1355 |
let tabSuggestionData = suggestionData.find(s => s.suggestiontype === `${tabName}`) |
| 1346 |
$("#table_" + tabName).kohaTable( |
1356 |
$("#table_" + tabName).kohaTable( |
|
Lines 1526-1539
Link Here
|
| 1526 |
searchable: false, |
1536 |
searchable: false, |
| 1527 |
orderable: false, |
1537 |
orderable: false, |
| 1528 |
render: function (data, type, row, meta) { |
1538 |
render: function (data, type, row, meta) { |
| 1529 |
[% IF CAN_user_suggestions_suggestions_manage %] |
1539 |
if (permissions.CAN_user_suggestions_suggestions_manage){ |
| 1530 |
let node = '<div class="btn-group dropup">' |
1540 |
let node = '<div class="btn-group dropup">' |
| 1531 |
node += '<a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=%s&op=edit_form"><i class="fa-solid fa-pencil" aria-hidden="true"></i> %s</a>'.format(row.suggestion_id, _("Edit")) |
1541 |
node += '<a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=%s&op=edit_form"><i class="fa-solid fa-pencil" aria-hidden="true"></i> %s</a>'.format(row.suggestion_id, _("Edit")) |
| 1532 |
node += '<a class="btn btn-default btn-xs dropdown-toggle" id="more_actions_%s" role="button" data-bs-toggle="dropdown" href="#"><b class="caret"></b></a>'.format(row.suggestion_id) |
1542 |
node += '<a class="btn btn-default btn-xs dropdown-toggle" id="more_actions_%s" role="button" data-bs-toggle="dropdown" href="#"><b class="caret"></b></a>'.format(row.suggestion_id) |
| 1533 |
node += '<ul class="dropdown-menu" role="menu" aria-labelledby="more_actions_%s">'.format(row.suggestion_id) |
1543 |
node += '<ul class="dropdown-menu" role="menu" aria-labelledby="more_actions_%s">'.format(row.suggestion_id) |
| 1534 |
[% IF CAN_user_suggestions_suggestions_delete %] |
1544 |
if (permissions.CAN_user_suggestions_suggestions_delete){ |
| 1535 |
node += '<li><a href="#" data-op="cud-delete" data-suggestionid="%s" class="dropdown-item trigger_action">%s</a></li>'.format(row.suggestion_id, _("Delete")) |
1545 |
node += '<li><a href="#" data-op="cud-delete" data-suggestionid="%s" class="dropdown-item trigger_action">%s</a></li>'.format(row.suggestion_id, _("Delete")) |
| 1536 |
[% END %] |
1546 |
} |
| 1537 |
if (!row.archived){ |
1547 |
if (!row.archived){ |
| 1538 |
node += '<li><a href="#" class="dropdown-item trigger_action" data-op="cud-archive" data-suggestionid="%s">%s</a></li>'.format(row.suggestion_id, _("Archive")) |
1548 |
node += '<li><a href="#" class="dropdown-item trigger_action" data-op="cud-archive" data-suggestionid="%s">%s</a></li>'.format(row.suggestion_id, _("Archive")) |
| 1539 |
} else { |
1549 |
} else { |
|
Lines 1541-1549
Link Here
|
| 1541 |
} |
1551 |
} |
| 1542 |
node += '</ul></div>' |
1552 |
node += '</ul></div>' |
| 1543 |
return node |
1553 |
return node |
| 1544 |
[% ELSIF CAN_user_suggestions_suggestions_delete %] |
1554 |
} else if (permissions.CAN_user_suggestions_suggestions_delete){ |
| 1545 |
return '<button data-op="cud-delete" data-suggestionid="%s" class="btn btn-xs btn-default trigger_action"><i class="fa fa-trash-can"></i> %s</button>'.format(row.suggestion_id, _("Delete")) |
1555 |
return '<button data-op="cud-delete" data-suggestionid="%s" class="btn btn-xs btn-default trigger_action"><i class="fa fa-trash-can"></i> %s</button>'.format(row.suggestion_id, _("Delete")) |
| 1546 |
[% END %] |
1556 |
} |
| 1547 |
}, |
1557 |
}, |
| 1548 |
createdCell: function (cell, cellData, rowData, rowIndex, colIndex) { |
1558 |
createdCell: function (cell, cellData, rowData, rowIndex, colIndex) { |
| 1549 |
$(cell).find(".trigger_action").on("click", function(e) { |
1559 |
$(cell).find(".trigger_action").on("click", function(e) { |
|
Lines 1562-1568
Link Here
|
| 1562 |
}, |
1572 |
}, |
| 1563 |
] |
1573 |
] |
| 1564 |
}, |
1574 |
}, |
| 1565 |
table_settings |
1575 |
suggestions_table_settings |
| 1566 |
); |
1576 |
); |
| 1567 |
} |
1577 |
} |
| 1568 |
if( $("#suggestiontabs .tab-pane.active").length < 1 ){ |
1578 |
if( $("#suggestiontabs .tab-pane.active").length < 1 ){ |
|
Lines 1571-1589
Link Here
|
| 1571 |
$("#suggestiontabs a:first").attr("data-table_loaded", 'true') |
1581 |
$("#suggestiontabs a:first").attr("data-table_loaded", 'true') |
| 1572 |
} |
1582 |
} |
| 1573 |
|
1583 |
|
| 1574 |
[% FOREACH suggestion IN suggestions %] |
1584 |
suggestionData.forEach(suggestion => { |
| 1575 |
$("#suggestiontabs #[% suggestion.suggestiontype | html %]-tab").on("click", function() { |
1585 |
$(`#suggestiontabs #${suggestion.suggestiontype}-tab`).on("click", function() { |
| 1576 |
if(!$(this).data("table_loaded")) { |
1586 |
if(!$(this).data("table_loaded")) { |
| 1577 |
loadDatatable("[% suggestion.suggestiontype | html%]") |
1587 |
loadDatatable(`${suggestion.suggestiontype}`); |
| 1578 |
$(this).attr("data-table_loaded", "true") |
1588 |
$(this).attr("data-table_loaded", "true"); |
| 1579 |
} |
1589 |
} |
| 1580 |
}); |
1590 |
}); |
| 1581 |
[% END %] |
1591 |
}); |
| 1582 |
[% END %] |
1592 |
} |
| 1583 |
|
1593 |
|
| 1584 |
$("#branchcode").on('change',function(){ |
1594 |
$("#branchcode").on('change',function(){ |
| 1585 |
[%# Modify the hidden input in the filters block from the library %] |
1595 |
// Modify the hidden input in the filters block from the library |
| 1586 |
[%# dropdown list at the top of suggestion list %] |
1596 |
// dropdown list at the top of suggestion list |
| 1587 |
let branchcode = $(this).val(); |
1597 |
let branchcode = $(this).val(); |
| 1588 |
$('input[name="branchcode"]').val( branchcode ); |
1598 |
$('input[name="branchcode"]').val( branchcode ); |
| 1589 |
$('form[name="suggestionfilter"]').submit(); |
1599 |
$('form[name="suggestionfilter"]').submit(); |
| 1590 |
- |
|
|