mirror of
https://github.com/Combodo/iTop.git
synced 2026-08-17 03:08:18 +02:00
50 lines
2.1 KiB
Twig
50 lines
2.1 KiB
Twig
{# @copyright Copyright (C) 2010-2022 Combodo SARL #}
|
|
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
|
|
|
// for each row action...
|
|
{% for aAction in oUIBlock.GetRowActions() %}
|
|
|
|
// register action buttons click
|
|
$('body').on('click', 'button[data-table-id="{{ oUIBlock.GetId() }}"][data-action-id="{{ loop.index0 }}"]', function() {
|
|
|
|
// variables accessible from action row js
|
|
let oDatatable = $('#{{ oUIBlock.GetId() }}').DataTable();
|
|
let oTrElement = $(this).closest('tr');
|
|
let iActionId = $(this).data('action-id');
|
|
let aRowData = oDatatable.row(oTrElement).data();
|
|
|
|
{% if aAction.confirmation is defined %}
|
|
|
|
// Prepare confirmation message
|
|
let sMessage = '{{ 'UI:Datatables:RowActions:ConfirmationMessage'|dict_s }}';
|
|
{% if aAction.confirmation.message is defined %}
|
|
sMessage = '{{ aAction.confirmation.message|dict_s|raw }}';
|
|
{% endif %}
|
|
|
|
// Handle action row with confirmation modal
|
|
CombodoModal.OpenConfirmationModal({
|
|
title: '{{ 'UI:Datatables:RowActions:ConfirmationDialog'|dict_s }}',
|
|
content: sMessage.replaceAll('{item}', aRowData['{{ aAction.confirmation.message_row_data }}']),
|
|
callback_on_confirm: ActionRowFunction{{ oUIBlock.GetId() }}{{ loop.index0 }},
|
|
{% if aAction.confirmation.do_not_show_again_pref_key is defined %}
|
|
do_not_show_again_pref_key: '{{ aAction.confirmation.do_not_show_again_pref_key }}',
|
|
{% endif %}
|
|
}, [oDatatable, oTrElement, iActionId, aRowData]);
|
|
|
|
{% else %}
|
|
|
|
// Handle action row without confirmation
|
|
ActionRowFunction{{ oUIBlock.GetId() }}{{ loop.index0 }}(oDatatable, oTrElement, iActionId, aRowData);
|
|
|
|
{% endif %}
|
|
|
|
});
|
|
|
|
// action row function declaration
|
|
function ActionRowFunction{{ oUIBlock.GetId() }}{{ loop.index0 }}(oDatatable, oTrElement, iActionId, aRowData){
|
|
{{ aAction.js_row_action|raw }};
|
|
return true;
|
|
}
|
|
|
|
{% endfor %}
|