diff --git a/css/backoffice/components/_datatable.scss b/css/backoffice/components/_datatable.scss index ecb49bd87..d4e794109 100644 --- a/css/backoffice/components/_datatable.scss +++ b/css/backoffice/components/_datatable.scss @@ -126,24 +126,30 @@ $ibo-datatable--selection-validation-buttons-toolbar--margin-top: 10px !default; padding-left: $ibo-datatable--paginate--padding-left; } .paginate_button { - display: inline-block; - box-sizing: border-box; + display: inline-block; + box-sizing: border-box; } .paginate_button a{ @extend %ibo-font-ral-med-100; color: $ibo-datatable--paginate-button--link--color; } + .paginate_button a:hover { - color: $ibo-datatable--paginate-button--link--hover--color; + color: $ibo-datatable--paginate-button--link--hover--color; } + +.paginate_button.disabled a:hover { + cursor: default; +} + .paginate_button.active a { - @extend %ibo-font-ral-med-100; - - color: $ibo-datatable--paginate-button-active--link--color; - background-color: $ibo-datatable--paginate-button-active--link--background-color; - padding: $ibo-datatable--paginate-button-active--link--padding-y $ibo-datatable--paginate-button-active--link--padding-x; - box-shadow: $ibo-datatable--paginate-button-active--link--box-shadow; - border-radius: $ibo-border-radius-300; + @extend %ibo-font-ral-med-100; + + color: $ibo-datatable--paginate-button-active--link--color; + background-color: $ibo-datatable--paginate-button-active--link--background-color; + padding: $ibo-datatable--paginate-button-active--link--padding-y $ibo-datatable--paginate-button-active--link--padding-x; + box-shadow: $ibo-datatable--paginate-button-active--link--box-shadow; + border-radius: $ibo-border-radius-300; } .ibo-datatable thead tr th{ position: relative; @@ -178,4 +184,4 @@ $ibo-datatable--selection-validation-buttons-toolbar--margin-top: 10px !default; .ibo-datatable--selection-validation-buttons-toolbar { clear: both; margin-top: $ibo-datatable--selection-validation-buttons-toolbar--margin-top; -} \ No newline at end of file +} diff --git a/css/backoffice/components/_field.scss b/css/backoffice/components/_field.scss index 4d4c186d8..fba918d35 100644 --- a/css/backoffice/components/_field.scss +++ b/css/backoffice/components/_field.scss @@ -109,8 +109,16 @@ $ibo-field--value--padding-bottom--is-fullscreen: $ibo-field--label--padding-y-- display: table-cell; vertical-align: top; padding-right: 10px; + + > input[type="checkbox"] { + margin-left: 5px; + } } +.multi_values, .mono_value { + display: inline-block; + padding-left: 5px; +} /* Fullscreen mode */ .ibo-field-large { &.ibo-is-fullscreen { diff --git a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php index d387d955d..f1111a2b0 100644 --- a/datamodels/2.x/itop-attachments/renderers.itop-attachments.php +++ b/datamodels/2.x/itop-attachments/renderers.itop-attachments.php @@ -428,16 +428,17 @@ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer 'uploader' => array('label' => $sFileUploader, 'description' => $sFileUploader), 'type' => array('label' => $sFileType, 'description' => $sFileType), ); - - if($bWithDeleteButton) - { - $aAttribs['delete'] = array('label' => '', 'description' => ''); - } - - $oAttachmentTableBlock = DataTableUIBlockFactory::MakeForStaticData('',$aAttribs, $aData); + + if ($bWithDeleteButton) { + $aAttribs['delete'] = array('label' => '', 'description' => ''); + } + + $oAttachmentTableBlock = DataTableUIBlockFactory::MakeForStaticData('', $aAttribs, $aData); $oAttachmentTableBlock->AddCSSClass('ibo-attachment--datatable'); $this->oPage->AddUiBlock($oAttachmentTableBlock); - + foreach ($aData as $aRow) { + $this->oPage->add_ready_script($aRow['js']); + } } /** @@ -525,7 +526,8 @@ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer 'formatted-size' => $sFileFormattedSize, 'upload-date' => $sAttachmentDateFormatted, 'uploader' => $sAttachmentUploader, - 'type' => $sFileType + 'type' => $sFileType, + 'js' => 'CombodoGlobalToolbox.InitTooltipFromMarkup($("#$sTrId [data-tooltip-content]"));', ); if ($bWithDeleteButton) @@ -536,11 +538,7 @@ class TableDetailsAttachmentsRenderer extends AbstractAttachmentsRenderer $this->oPage->add_ready_script($oBlockRenderer->RenderJsInline($sDeleteButton::ENUM_JS_TYPE_ON_INIT)); $aAttachmentLine['delete'] = $oBlockRenderer->RenderHtml(); } - $this->oPage->add_ready_script( - << all the row are display + if (requestLength == -1) { + requestLength = cacheLastJson.recordsTotal; + if (cacheLower != 0 || cacheLastJson.recordsTotal > cacheUpper) { + //new server request is mandatory + ajax = true; + } + } + + if (settings.clearCache) { // API requested that the cache be cleared ajax = true; settings.clearCache = false; - } - else if ( cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper ) { + } else if (cacheLower < 0 || requestStart < cacheLower || requestEnd > cacheUpper) { // outside cached data - need to make a request ajax = true; - } - else if ( JSON.stringify( request.order ) !== JSON.stringify( cacheLastRequest.order ) || - JSON.stringify( request.columns ) !== JSON.stringify( cacheLastRequest.columns ) || - JSON.stringify( request.search ) !== JSON.stringify( cacheLastRequest.search ) + } else if (JSON.stringify(request.order) !== JSON.stringify(cacheLastRequest.order) || + JSON.stringify(request.columns) !== JSON.stringify(cacheLastRequest.columns) || + JSON.stringify(request.search) !== JSON.stringify(cacheLastRequest.search) ) { // properties changed (ordering, columns, searching) ajax = true; - } - else if(cacheLastJson == undefined || cacheLastJson.length==0) - { + } else if (cacheLastJson == undefined || cacheLastJson.length == 0) { ajax = true; } @@ -97,13 +101,13 @@ $.fn.dataTable.pipeline = function ( opts ) { "success": function ( json ) { cacheLastJson = $.extend(true, {}, json); - if ( cacheLower != drawStart ) { - json.data.splice( 0, drawStart-cacheLower ); + if (cacheLower != drawStart && requestLength != -1) { + json.data.splice(0, drawStart-cacheLower); } - if ( requestLength >= -1 ) { - json.data.splice( requestLength, json.data.length ); + if (requestLength >= -1) { + json.data.splice(requestLength, json.data.length); } - drawCallback( json ); + drawCallback(json); } } ); } diff --git a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index e4123ab86..ac40a347d 100644 --- a/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -316,7 +316,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory 'attribute_code' => $sAttCode, 'attribute_type' => '_key_', 'attribute_label' => $aData['alias'], - "render" => "return ''+row['".$sClassAlias."/friendlyname']+'' ;", + "render" => "let displayField = ''+row['".$sClassAlias."/friendlyname']+''; if (row['".$sClassAlias."/obsolescence_flag'].indexOf('no') == -1){displayField = ''+row['".$sClassAlias."/friendlyname']+'';} return displayField;", ]; } } else { @@ -542,7 +542,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory 'attribute_code' => $sAttCode, 'attribute_type' => '_key_', 'attribute_label' => $aData['alias'], - "render" => "return ''+row['".$sClassAlias."/friendlyname']+'' ;", + "render" => "let displayField = ''+row['".$sClassAlias."/friendlyname']+''; if (row['".$sClassAlias."/obsolescence_flag'].indexOf('no') == -1){displayField = ''+row['".$sClassAlias."/friendlyname']+'';} return displayField;", ]; } } else { @@ -669,7 +669,7 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory ]; $aColumnDefinition["data"] = $sClassAlias."/".$sAttCode; $aColumnDefinition["render"] = [ - "display" => "return ''+row['".$sClassAlias."/friendlyname']+'' ;", + "display" => "let displayField = ''+row['".$sClassAlias."/friendlyname']+''; if (row['".$sClassAlias."/obsolescence_flag'].indexOf('no') == -1){displayField = ''+row['".$sClassAlias."/friendlyname']+'';} return displayField;", "_" => $sClassAlias."/".$sAttCode, ]; } else { diff --git a/templates/base/components/datatable/layout.ready.js.twig b/templates/base/components/datatable/layout.ready.js.twig index 3ad9ebec2..a786e52d4 100644 --- a/templates/base/components/datatable/layout.ready.js.twig +++ b/templates/base/components/datatable/layout.ready.js.twig @@ -22,17 +22,21 @@ var maxHeight{{ sListId }} = 300; if ($('#{{ oUIBlock.GetId() }}').closest('.ui-dialog').length > 0) { //we are in dialogbox - maxHeight{{ sListId }} = $('#{{ oUIBlock.GetId() }}').closest('.ui-dialog').height(); - a + maxHeight{{ sListId }} = $('#{{ oUIBlock.GetId() }}').closest('.ui-dialog-content').height(); } else { maxHeight{{ sListId }} = $(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) { //we are in dialogbox - maxHeight{{ sListId }} = maxHeight{{ sListId }}-$('#{{ oUIBlock.GetId() }}').closest('[data-target=search_results]').parent().find('.ibo-search-form-panel').height(); + maxHeight{{ sListId }} = maxHeight{{ sListId }}-$('#{{ oUIBlock.GetId() }}').closest('[data-target=search_results]').parent().find('.ibo-search-form-panel').outerHeight(); +} +if ($('#{{ oUIBlock.GetId() }}').closest('.ibo-panel--header').length > 0) +{ + maxHeight{{ sListId }} = maxHeight{{ sListId }}-$('#{{ oUIBlock.GetId() }}').closest('.ibo-panel--header').outerHeight(); } if (maxHeight{{ sListId }} < 300) { @@ -42,7 +46,7 @@ else { maxHeight{{ sListId }} = maxHeight{{ sListId }} -50; } - +console.warn(maxHeight{{ sListId }}); var oTable{{ sListId }} = $('#{{ oUIBlock.GetId() }}').DataTable({ language: { processing: "{{ 'UI:Datatables:Language:Processing'|dict_s }}", @@ -182,93 +186,109 @@ var oTable{{ sListId }} = $('#{{ oUIBlock.GetId() }}').DataTable({ } }); - +$('#{{ oUIBlock.GetId() }}').closest(".dataTables_scrollBody").css('max-height', maxHeight{{ sListId }}-100); {% if oUIBlock.GetOption("select_mode") is not empty %} - {% if oUIBlock.GetOption("select_mode") != "single" %} - oTable{{ sListId }}.off('select').on('select', function (oEvent, dt, type, indexes) { - let aData = oTable{{ sListId }}.rows(indexes).data().toArray(); - if( $(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") - { - // Checking input - $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true); - // Saving values in temp array - for (let i in aData) { - let iItemId = aData[i].id; - if (oSelectedItems{{ sListId }}.indexOf(iItemId) > -1) { - oSelectedItems{{ sListId }}.splice(oSelectedItems{{ sListId }}.indexOf(iItemId), 1); - updateDataTableSelection('{{ sListId }}'); - } - } - } - else { - // Checking input - $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true); - // Saving values in temp array - for (let i in aData) { - let iItemId = aData[i].id; - if (oSelectedItems{{ sListId }}.indexOf(iItemId) === -1) { - oSelectedItems{{ sListId }}.push(iItemId); - updateDataTableSelection('{{ sListId }}'); - } - } - } - }); +{% if oUIBlock.GetOption("select_mode") != "single" %} +oTable{{ sListId }}.off('select').on('select', function (oEvent, dt, type, indexes) { + let aData = oTable{{ sListId }}.rows(indexes).data().toArray(); + if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") + { + // Checking input + $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true); + // Saving values in temp array + for (let i in aData) + { + let iItemId = aData[i].id; + if (oSelectedItems{{ sListId }}.indexOf(iItemId) > -1) + { + oSelectedItems{{ sListId }}.splice(oSelectedItems{{ sListId }}.indexOf(iItemId), 1); + updateDataTableSelection('{{ sListId }}'); + } + } + } + else + { + // Checking input + $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true); + // Saving values in temp array + for (let i in aData) + { + let iItemId = aData[i].id; + if (oSelectedItems{{ sListId }}.indexOf(iItemId) === -1) + { + oSelectedItems{{ sListId }}.push(iItemId); + updateDataTableSelection('{{ sListId }}'); + } + } + } +}); - oTable{{ sListId }}.off('deselect').on('deselect', function (oEvent, dt, type, indexes) { - let aData = oTable{{ sListId }}.rows(indexes).data().toArray(); +oTable{{ sListId }}.off('deselect').on('deselect', function (oEvent, dt, type, indexes) { + let aData = oTable{{ sListId }}.rows(indexes).data().toArray(); - // Checking input - $('#{{ oUIBlock.GetId() }} tr[role="row"]:not(.selected) td:first-child input').prop('checked', false); - // Saving values in temp array - if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") { - for (let i in aData) { - let iItemId = aData[i].id; - if (oSelectedItems{{ sListId }}.indexOf(iItemId) === -1) { - oSelectedItems{{ sListId }}.push(iItemId); - updateDataTableSelection('{{ sListId }}'); - } - } - } else { - for (let i in aData) { - let iItemId = aData[i].id; - if (oSelectedItems{{ sListId }}.indexOf(iItemId) > -1) { - oSelectedItems{{ sListId }}.splice(oSelectedItems{{ sListId }}.indexOf(iItemId), 1); - updateDataTableSelection('{{ sListId }}'); - } - } - } - }); - {% else %} - oTable{{ sListId }}.off('select').on('select', function (oEvent, dt, type, indexes) { - let aData = oTable{{ sListId }}.rows(indexes).data().toArray(); - // Checking input - $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true); - // Saving values in temp array - for (let i in aData) { - let iItemId = aData[i].id; - if (oSelectedItems{{ sListId }}.indexOf(iItemId) === -1) { - oSelectedItems{{ sListId }}.push(iItemId); - updateDataTableSelection('{{ sListId }}'); - } - } - }); + // Checking input + $('#{{ oUIBlock.GetId() }} tr[role="row"]:not(.selected) td:first-child input').prop('checked', false); + // Saving values in temp array + if ($(this).closest('.ibo-panel--body').find('[name=selectionMode]').val() === "negative") + { + for (let i in aData) + { + let iItemId = aData[i].id; + if (oSelectedItems{{ sListId }}.indexOf(iItemId) === -1) + { + oSelectedItems{{ sListId }}.push(iItemId); + updateDataTableSelection('{{ sListId }}'); + } + } + } + else + { + for (let i in aData) + { + let iItemId = aData[i].id; + if (oSelectedItems{{ sListId }}.indexOf(iItemId) > -1) + { + oSelectedItems{{ sListId }}.splice(oSelectedItems{{ sListId }}.indexOf(iItemId), 1); + updateDataTableSelection('{{ sListId }}'); + } + } + } +}); +{% else %} +oTable{{ sListId }}.off('select').on('select', function (oEvent, dt, type, indexes) { + let aData = oTable{{ sListId }}.rows(indexes).data().toArray(); + // Checking input + $('#{{ oUIBlock.GetId() }} tr[role="row"].selected td:first-child input').prop('checked', true); + // Saving values in temp array + for (let i in aData) + { + let iItemId = aData[i].id; + if (oSelectedItems{{ sListId }}.indexOf(iItemId) === -1) + { + oSelectedItems{{ sListId }}.push(iItemId); + updateDataTableSelection('{{ sListId }}'); + } + } +}); - oTable{{ sListId }}.off('deselect').on('deselect', function (oEvent, dt, type, indexes) { - let aData = oTable{{ sListId }}.rows(indexes).data().toArray(); +oTable{{ sListId }}.off('deselect').on('deselect', function (oEvent, dt, type, indexes) { + let aData = oTable{{ sListId }}.rows(indexes).data().toArray(); - // Checking input - $('#{{ oUIBlock.GetId() }} tr[role="row"]:not(.selected) td:first-child input').prop('checked', false); - // Saving values in temp array - for (let i in aData) { - let iItemId = aData[i].id; - if (oSelectedItems{{ sListId }}.indexOf(iItemId) > -1) { - oSelectedItems{{ sListId }}.splice(oSelectedItems{{ sListId }}.indexOf(iItemId), 1); - updateDataTableSelection('{{ sListId }}'); - } - } - }); - {% endif %} + // Checking input + $('#{{ oUIBlock.GetId() }} tr[role="row"]:not(.selected) td:first-child input').prop('checked', false); + // Saving values in temp array + for (let i in aData) + { + let iItemId = aData[i].id; + if (oSelectedItems{{ sListId }}.indexOf(iItemId) > -1) + { + oSelectedItems{{ sListId }}.splice(oSelectedItems{{ sListId }}.indexOf(iItemId), 1); + updateDataTableSelection('{{ sListId }}'); + } + } +}); +{% endif %} {% if oUIBlock.GetOption('sCountSelector') is not empty %} $('#{{ sListId }} [name="selectionCount"]').bind('change', function() { diff --git a/templates/base/components/field/layout.html.twig b/templates/base/components/field/layout.html.twig index 57047b24e..386126b91 100644 --- a/templates/base/components/field/layout.html.twig +++ b/templates/base/components/field/layout.html.twig @@ -25,6 +25,6 @@ {% endfor %} {% if oUIBlock.GetComments() %} -
{{ oUIBlock.GetComments() }}
- {% endif %} +
{{ oUIBlock.GetComments()|raw }}
+ {% endif %} \ No newline at end of file