mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-27 14:14:11 +01:00
* datatable row actions
Below is a sample of extra param to enable feature:
$aExtraParams['row_actions'] = [
[
'tooltip' => 'add an element',
'icon_css_class' => 'fa-plus',
'css_class' => 'ibo-is-success',
'level' => 'secondary',
'on_action_js' => 'console.log(aData);',
],
[
'tooltip' => 'remove an element',
'icon_css_class' => 'fa-minus',
'css_class' => 'ibo-is-danger',
'level' => 'secondary',
'on_action_js' => 'console.log("You clicked the remove button");',
],
[
'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);',
],
];
* datatable row actions (update)
* datatable row actions (update)
* datatable row actions (add template role)
* datatable row actions (align actions)
* datatable row actions (change template factory make to make standard)
* datatable row actions (use trait to handle row actions)
* datatable row actions (row actions templates)
* datatable row actions (row actions templates)
* datatable row actions (row actions templates)
* datatable row actions (extends to static and form)
* datatable row actions (extends to static and form)
* datatable row actions (code review S)
* datatable row actions (code review S)
* datatable row actions (code review S)
* Update js/dataTables.main.js
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update js/dataTables.main.js
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update templates/base/components/datatable/row-actions/handler.js.twig
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* datatable row actions (code review M)
* Update js/dataTables.main.js
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update js/dataTables.main.js
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update js/dataTables.main.js
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update js/dataTables.main.js
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update sources/Application/UI/Base/Component/DataTable/StaticTable/StaticTable.php
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* Update application/utils.inc.php
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
* datatable row actions (code review M2)
* datatable row actions (code review M3)
Co-authored-by: Molkobain <lajarige.guillaume@free.fr>
131 lines
5.4 KiB
Twig
131 lines
5.4 KiB
Twig
{% set sListId = oUIBlock.GetId() %}
|
|
{% set sListIDForVarSuffix = ('' ~ sListId)|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %}
|
|
|
|
var oTable{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
|
|
language: {
|
|
emptyTable: "{{ 'UI:Message:EmptyList:UseAdd'|dict_s }}"
|
|
},
|
|
scrollX: true,
|
|
scrollCollapse: true,
|
|
paging: false,
|
|
filter: false,
|
|
search: false,
|
|
dom: "t",
|
|
"order": [],
|
|
{% if oUIBlock.GetOption("select_mode") is not empty %}
|
|
{% if oUIBlock.GetOption("select_mode") != "custom" %}
|
|
select: {
|
|
style: "{% if oUIBlock.GetOption("select_mode") == "multiple" %}multi{% else %}single{% endif %}",
|
|
info: false
|
|
},
|
|
{% endif %}
|
|
columnDefs: [
|
|
{orderable: false, targets: 0},
|
|
{% if oUIBlock.HasRowActions() %}
|
|
getRowActionsColumnDefinition('{{ oUIBlock.GetId() }}', {{ oUIBlock.GetColumnsCount() - 1 }}),
|
|
{% endif %}
|
|
],
|
|
{% endif %}
|
|
drawCallback: function (settings) {
|
|
if(settings.json)
|
|
{
|
|
$(this).closest('.ibo-panel').find('.ibo-datatable--result-count').html(settings.json.recordsTotal);
|
|
}
|
|
// Hiding pagination if only one page
|
|
if ($(this).closest('.dataTables_wrapper').find('.dataTables_paginate:last .paginate_button:not(.previous):not(.next)').length < 2)
|
|
{
|
|
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').hide();
|
|
}
|
|
else
|
|
{
|
|
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show();
|
|
}
|
|
|
|
// Disable hyperlinks if necessary
|
|
{% if oUIBlock.GetOption("disable_hyperlinks") is same as true or (oUIBlock.GetOption("select_mode") is not empty and oUIBlock.GetOption("disable_hyperlinks") is not same as false) %}
|
|
$("#{{ oUIBlock.GetId() }} a").on('click', function (e) {
|
|
e.preventDefault();
|
|
});
|
|
{% endif %}
|
|
},
|
|
createdRow: function (row, data, dataIndex) {
|
|
if (data['@class'] !== undefined)
|
|
{
|
|
$(row).addClass(data['@class']);
|
|
}
|
|
},
|
|
|
|
initComplete: function () {
|
|
if (this.api().page.info().pages < 2)
|
|
{
|
|
this.closest('.dataTables_wrapper').find('.dataTables_length').hide();
|
|
}
|
|
|
|
// Set header and body datatables status as loaded
|
|
this.attr('data-status', 'loaded');
|
|
this.closest('.dataTables_scroll').find('.dataTables_scrollHead .ibo-datatable').attr('data-status', 'loaded');
|
|
},
|
|
});
|
|
|
|
{% if (oUIBlock.GetOption('bFullscreen')) %}
|
|
var heightS{{ sListIDForVarSuffix }} = 0;
|
|
var heightD{{ sListIDForVarSuffix }} = 0;
|
|
if ($("#{{ oUIBlock.GetId() }}").height() > 0)
|
|
{
|
|
heightD{{ sListIDForVarSuffix }} = $("#ibo-main-content").height()-$("#ibo-main-content")[0].scrollHeight+$("#{{ oUIBlock.GetId() }}").height();
|
|
heightS{{ sListIDForVarSuffix }} = $("#ibo-main-content").height();
|
|
if (heightD{{ sListIDForVarSuffix }} > 200)
|
|
{
|
|
$("#{{ oUIBlock.GetId() }}_wrapper").find(".dataTables_scrollBody").height(heightD{{ sListIDForVarSuffix }});
|
|
}
|
|
}
|
|
{% endif %}
|
|
|
|
if (window.ResizeObserver)
|
|
{
|
|
let oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = null;
|
|
const oFromTable{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function () {
|
|
clearTimeout(oFromTable{{ sListIDForVarSuffix }}ResizeTimeout);
|
|
oFromTable{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function () {
|
|
$('#{{ oUIBlock.GetId() }}').DataTable().columns.adjust();
|
|
}, 120);
|
|
});
|
|
oFromTable{{ sListIDForVarSuffix }}Resize.observe($('#{{ oUIBlock.GetId() }}')[0]);
|
|
|
|
{% if (oUIBlock.GetOption('bFullscreen')) %}
|
|
let heightScreen{{ sListIDForVarSuffix }} = heightS{{ sListIDForVarSuffix }};
|
|
let heightDatatable{{ sListIDForVarSuffix }} = heightD{{ sListIDForVarSuffix }};
|
|
let oFromScreen{{ sListIDForVarSuffix }}ResizeTimeout = null;
|
|
const oFromScreen{{ sListIDForVarSuffix }}Resize = new ResizeObserver(function () {
|
|
clearTimeout(oFromScreen{{ sListIDForVarSuffix }}ResizeTimeout);
|
|
oFromScreen{{ sListIDForVarSuffix }}ResizeTimeout = setTimeout(function () {
|
|
if ($("#{{ oUIBlock.GetId() }}_wrapper").height() > 0)
|
|
{
|
|
if (heightDatatable{{ sListIDForVarSuffix }}> 0)
|
|
{
|
|
let calcul = $("#ibo-main-content").height()+heightDatatable{{ sListIDForVarSuffix }}-heightScreen{{ sListIDForVarSuffix }};
|
|
if (calcul > 200)
|
|
{
|
|
$("#{{ oUIBlock.GetId() }}_wrapper").find(".dataTables_scrollBody").height(calcul);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
heightDatatable{{ sListIDForVarSuffix }} = $("#ibo-main-content").height()-$("#ibo-main-content")[0].scrollHeight+$("#{{ oUIBlock.GetId() }}_wrapper").height();
|
|
heightScreen{{ sListIDForVarSuffix }} = $("#ibo-main-content").height();
|
|
if (heightDatatable{{ sListIDForVarSuffix }} > 200)
|
|
{
|
|
$("#{{ oUIBlock.GetId() }}_wrapper").find(".dataTables_scrollBody").height(heightDatatable{{ sListIDForVarSuffix }});
|
|
}
|
|
}
|
|
|
|
}
|
|
}, 120);
|
|
});
|
|
oFromScreen{{ sListIDForVarSuffix }}Resize.observe($('#ibo-main-content')[0]);
|
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
{% include 'base/components/datatable/row-actions/handler.js.twig' %} |