mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-16 22:08:44 +02:00
* datatable row actions
Below is a sample of extra param to enable feature:
$aExtraParams['row_actions'] = [
[
'tooltip' => 'remove an element',
'icon_css_class' => 'fa-minus',
'js_row_action' => 'console.log("You clicked the remove button");',
'confirmation' => [
'message' => 'UI:ConfirmationMessage',
'message_row_data' => "name",
'remember_choice_pref_key' => 'remove_do_not_show_again',
],
],
[
'tooltip' => 'open in new tab',
'icon_css_class' => 'fa-external-link-square-alt',
'on_action_js' => 'window.open("http://localhost/itop-branchs/dev/pages/UI.php?operation=details&class=UserRequest&id=" + aData.id + "&c[menu]=UserRequest%3AOpenRequests");',
],
[
'tooltip' => 'other actions',
'icon_css_class' => 'fa-ellipsis-v',
'on_action_js' => 'console.log(event);',
],
];
* Contrôleur pour la suppression et le détachement de liens
* Block UI pour l'édition des relations
* Block UI pour la visualisation des relations
* Boutons d'actions pour la suppression et le détachement de liens
* Gestion dialogue de confirmation pour les row actions
52 lines
2.1 KiB
Twig
52 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
|
|
$('#{{ oUIBlock.GetId() }} tbody').on('click', 'button[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 %}
|
|
|
|
// Handle action row with confirmation
|
|
let sTitle = '{{ 'UI:Datatables:RowActions:ConfirmationDialog'|dict_s }}';
|
|
let sMessage = '{{ 'UI:Datatables:RowActions:ConfirmationMessage'|dict_s }}';
|
|
{% if aAction.confirmation.message is defined %}
|
|
sMessage = '{{ aAction.confirmation.message|dict_s|raw }}';
|
|
sMessage = sMessage.replaceAll('{item}', aRowData['{{ aAction.confirmation.message_row_data }}']);
|
|
{% endif %}
|
|
let sPrefKey = null;
|
|
{% if aAction.confirmation.remember_choice_pref_key is defined %}
|
|
sPrefKey = '{{ aAction.confirmation.remember_choice_pref_key }}';
|
|
{% endif %}
|
|
HandleActionRowConfirmation (sTitle, sMessage, sPrefKey, ActionRowFunction{{ oUIBlock.GetId() }}{{ loop.index0 }}, {
|
|
action_id: iActionId,
|
|
datatable: oDatatable,
|
|
tr_element: oTrElement,
|
|
row_data: 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 %}
|