Code format

This commit is contained in:
Molkobain
2021-05-21 10:35:18 +02:00
committed by Eric
parent 8df9afdce2
commit 3c20a417ad
4 changed files with 53 additions and 71 deletions

View File

@@ -1,8 +1,8 @@
{% if oUIBlock.GetOption("select_mode") is not empty %}
var oSelectedItems{{ oUIBlock.GetOption('sListId') }} = [];
{% if oUIBlock.GetOption("sSelectedRows") is not empty %}
oSelectedItems{{ oUIBlock.GetOption('sListId') }} = {{ oUIBlock.GetOption('sSelectedRows')|raw }};
{% endif %}
var oSelectedItems{{ oUIBlock.GetOption('sListId') }} = [];
{% if oUIBlock.GetOption("sSelectedRows") is not empty %}
oSelectedItems{{ oUIBlock.GetOption('sListId') }} = {{ oUIBlock.GetOption('sSelectedRows')|raw }};
{% endif %}
{% endif %}
var bSelectAllowed{{ oUIBlock.GetId() }} = false;

View File

@@ -3,9 +3,9 @@
{% set sListId = oUIBlock.GetOption('sListId') %}
{% set sListIDForVarSuffix = ('' ~ sListId)|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %}
{% if oUIBlock.GetOption("iPageSize") is not empty %}
{% set iPageSize = oUIBlock.GetOption("iPageSize") %}
{% set iPageSize = oUIBlock.GetOption("iPageSize") %}
{% else %}
{% set iPageSize = 10 %}
{% set iPageSize = 10 %}
{% endif %}
$('#{{ oUIBlock.GetId() }}').closest("[role=dialog]").on("dialogbeforeclose", function () {
@@ -14,37 +14,28 @@ $('#{{ oUIBlock.GetId() }}').closest("[role=dialog]").on("dialogbeforeclose", fu
$('#{{ sListId }}').data('target', 'ibo-datatables--outer');
if ($('#{{ oUIBlock.GetId() }}') != 'undefined' && $.fn.dataTable.isDataTable('#{{ oUIBlock.GetId() }}'))
{
if ($('#{{ oUIBlock.GetId() }}') != 'undefined' && $.fn.dataTable.isDataTable('#{{ oUIBlock.GetId() }}')) {
$('#{{ oUIBlock.GetId() }}').DataTable().destroy(false);
}
//define maxHeight for Datatable
var maxHeight{{ sListIDForVarSuffix }} = 300;
if ($('#{{ oUIBlock.GetId() }}').closest('.ui-dialog').length > 0)
{
if ($('#{{ oUIBlock.GetId() }}').closest('.ui-dialog').length > 0) {
//we are in dialogbox
maxHeight{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').closest('.ui-dialog-content').height();
}
else
{
} else {
maxHeight{{ sListIDForVarSuffix }} = $(window).height()-$('#ibo-top-container').outerHeight()+$('#ibo-main-content').height()-$('#ibo-main-content').outerHeight();
}
if ($('#{{ oUIBlock.GetId() }}').closest('[data-target=search_results]').parent().find('.ibo-search-form-panel').length > 0)
{
if ($('#{{ oUIBlock.GetId() }}').closest('[data-target=search_results]').parent().find('.ibo-search-form-panel').length > 0) {
//we are in dialogbox
maxHeight{{ sListIDForVarSuffix }} = maxHeight{{ sListIDForVarSuffix }}-$('#{{ oUIBlock.GetId() }}').closest('[data-target=search_results]').parent().find('.ibo-search-form-panel').outerHeight();
}
if ($('#{{ oUIBlock.GetId() }}').closest('.ibo-panel--header').length > 0)
{
if ($('#{{ oUIBlock.GetId() }}').closest('.ibo-panel--header').length > 0) {
maxHeight{{ sListIDForVarSuffix }} = maxHeight{{ sListIDForVarSuffix }}-$('#{{ oUIBlock.GetId() }}').closest('.ibo-panel--header').outerHeight();
}
if (maxHeight{{ sListIDForVarSuffix }} < 300)
{
if (maxHeight{{ sListIDForVarSuffix }} < 300) {
maxHeight{{ sListIDForVarSuffix }} = 250;
}
else
{
} else {
maxHeight{{ sListIDForVarSuffix }} = maxHeight{{ sListIDForVarSuffix }} -50;
}
@@ -75,51 +66,44 @@ var oTable{{ sListIfForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
lengthMenu: [[ {{ iPageSize }}, {{ iPageSize*2 }}, {{ iPageSize*3 }}, {{ iPageSize*4 }}, -1], [ {{ iPageSize }}, {{ iPageSize*2 }}, {{ iPageSize*3 }}, {{ iPageSize*4 }}, "{{ 'UI:Datatables:Language:DisplayLength:All'|dict_s }}"]],
dom: "<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>t<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>",
{% if( oUIBlock.GetOptions("sort")[0] is defined ) %}
order: [[{{ oUIBlock.GetOptions()["sort"][0] }}, '{{ oUIBlock.GetOptions()["sort"][1] }}']],
order: [[{{ oUIBlock.GetOptions()["sort"][0] }}, '{{ oUIBlock.GetOptions()["sort"][1] }}']],
{% else %}
order: [],
order: [],
{% endif %}
ordering: true,
{% if oUIBlock.GetOption("select_mode") is not empty %}
select: {
style: "{% if oUIBlock.GetOption("select_mode") == "multiple" %}multi{% else %}single{% endif %}",
info: false
},
rowCallback: function (oRow, oData) {
if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative")
{
if (oSelectedItems{{ sListId }}.indexOf(oData.id) === -1)
{
this.api().row($(oRow)).select();
// $(oRow).addClass('selected');
$(oRow).find('td:first-child input').prop('checked', true);
select: {
style: "{% if oUIBlock.GetOption("select_mode") == "multiple" %}multi{% else %}single{% endif %}",
info: false
},
rowCallback: function (oRow, oData) {
if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") {
if (oSelectedItems{{ sListId }}.indexOf(oData.id) === -1) {
this.api().row($(oRow)).select();
// $(oRow).addClass('selected');
$(oRow).find('td:first-child input').prop('checked', true);
}
} else {
if (oSelectedItems{{ sListId }}.indexOf(oData.id) > -1) {
this.api().row($(oRow)).select();
$(oRow).find('td:first-child input').prop('checked', true);
}
}
}
else
{
if (oSelectedItems{{ sListId }}.indexOf(oData.id) > -1)
{
this.api().row($(oRow)).select();
$(oRow).find('td:first-child input').prop('checked', true);
},
drawCallback: function () {
if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") {
$(this).closest('.dataTables_wrapper').find('.checkAll')[0].checked = true;
}
}
},
drawCallback: function () {
if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative")
{
$(this).closest('.dataTables_wrapper').find('.checkAll')[0].checked = true;
}
else
{
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show();
}
bSelectAllowed{{ oUIBlock.GetId() }} = true;
else {
$(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show();
}
bSelectAllowed{{ oUIBlock.GetId() }} = true;
$("#{{ oUIBlock.GetId() }} a").on('click', function (e) {
//disable select action when there is a link
e.stopPropagation();
});
},
$("#{{ oUIBlock.GetId() }} a").on('click', function (e) {
//disable select action when there is a link
e.stopPropagation();
});
},
{% endif %}
rowId: "id",
filter: false,
@@ -135,10 +119,10 @@ var oTable{{ sListIfForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({
sortable: false,
orderable: false,
title:
{% if oUIBlock.GetOption("select_mode") != "single" %}
'<span class="row_input"><input type="checkbox" onclick="checkAllDataTable(\'{{ oUIBlock.GetId() }}\',this.checked,\'{{ oUIBlock.GetOption("sListId") }}\');" class="checkAll" id="field_{{ oUIBlock.GetId() }}_check_all" name="field_{{ oUIBlock.GetId() }}_check_all" title="{{ 'UI:SearchValue:CheckAll'|dict_s }} / {{ 'UI:SearchValue:UncheckAll'|dict_s }}"/></span>'
{% if oUIBlock.GetOption("select_mode") != "single" %}
'<span class="row_input"><input type="checkbox" onclick="checkAllDataTable(\'{{ oUIBlock.GetId() }}\',this.checked,\'{{ oUIBlock.GetOption("sListId") }}\');" class="checkAll" id="field_{{ oUIBlock.GetId() }}_check_all" name="field_{{ oUIBlock.GetId() }}_check_all" title="{{ 'UI:SearchValue:CheckAll'|dict_s }} / {{ 'UI:SearchValue:UncheckAll'|dict_s }}"/></span>'
{% else %}
'<span class="row_input"><input type="checkbox" style="display: none;" onclick="checkAllDataTable(\'{{ oUIBlock.GetId() }}\',this.checked,\'{{ oUIBlock.GetOption("sListId") }}\');" class="checkAll" id="field_{{ oUIBlock.GetId() }}_check_all" name="field_{{ oUIBlock.GetId() }}_check_all" title="{{ 'UI:SearchValue:CheckAll'|dict_s }} / {{ 'UI:SearchValue:UncheckAll'|dict_s }}"/></span>'
'<span class="row_input"><input type="checkbox" style="display: none;" onclick="checkAllDataTable(\'{{ oUIBlock.GetId() }}\',this.checked,\'{{ oUIBlock.GetOption("sListId") }}\');" class="checkAll" id="field_{{ oUIBlock.GetId() }}_check_all" name="field_{{ oUIBlock.GetId() }}_check_all" title="{{ 'UI:SearchValue:CheckAll'|dict_s }} / {{ 'UI:SearchValue:UncheckAll'|dict_s }}"/></span>'
{% endif %},
type: "html",
data: "",
@@ -360,8 +344,7 @@ $aOptions = {
oLabels: {moveup: "{{ 'UI:Button:MoveUp'|dict_s }}", movedown: "{{ 'UI:Button:MoveDown'|dict_s }}"},
};
if ($('#datatable_dlg_{{ oUIBlock.GetId() }}').hasClass('itop-datatable'))
{
if ($('#datatable_dlg_{{ oUIBlock.GetId() }}').hasClass('itop-datatable')) {
$('#datatable_dlg_{{ oUIBlock.GetId() }}').DataTableSettings('destroy');
}

View File

@@ -22,7 +22,6 @@ var table{{ oUIBlock.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_
],
{% endif %}
});
if ($('#{{ oUIBlock.GetId() }}').find('thead').is(':visible'))
{
if ($('#{{ oUIBlock.GetId() }}').find('thead').is(':visible')) {
table{{ oUIBlock.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER')) }}.columns.adjust().draw();
}

View File

@@ -35,15 +35,15 @@ $('#{{ oUIBlock.GetId() }}').DataTable({
rowId: "id",
filter: false,
{% if oUIBlock.GetOption("pageLength") is not empty %}
pageLength: {{ oUIBlock.GetOption("pageLength") }},
pageLength: {{ oUIBlock.GetOption("pageLength") }},
{% endif %}
{% if oUIBlock.GetData()|length <= iPageSize %}
paging: false,
paging: false,
{% endif %}
{% if oUIBlock.GetOption("dom") is not empty %}
dom: "<'ibo-datatable-toolbar'{{ oUIBlock.GetOption("dom") }}>t",
dom: "<'ibo-datatable-toolbar'{{ oUIBlock.GetOption("dom") }}>t",
{% else %}
dom: "<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>t<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>",
dom: "<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>t<'ibo-datatable--toolbar'<'ibo-datatable--toolbar-left' pl><'ibo-datatable--toolbar-right' i>>",
{% endif %}
lengthMenu: [[ {{ iPageSize }}, {{ iPageSize*2 }}, {{ iPageSize*3 }}, {{ iPageSize*4 }}, -1], [ {{ iPageSize }}, {{ iPageSize*2 }}, {{ iPageSize*3 }}, {{ iPageSize*4 }}, "{{ 'UI:Datatables:Language:DisplayLength:All'|dict_s }}"]],
columns: [