diff --git a/css/backoffice/vendors/_datatables.scss b/css/backoffice/vendors/_datatables.scss index d6d575646..b6f897843 100644 --- a/css/backoffice/vendors/_datatables.scss +++ b/css/backoffice/vendors/_datatables.scss @@ -36,6 +36,16 @@ $ibo-vendors-datatables--columns-header--border-bottom: 1px solid $ibo-color-gre $ibo-vendors-datatables--row--background-color--is-odd: $ibo-color-white-100 !default; $ibo-vendors-datatables--row--background-color--is-even: $ibo-color-white-200 !default; +$ibo-vendors-datatables--row-highlight--colors:( + 'red': ($ibo-color-red-100), + 'danger': ($ibo-color-red-200), + 'alert': ($ibo-color-red-200), + 'orange': ($ibo-color-orange-100), + 'warning': ($ibo-color-orange-200), + 'blue': ($ibo-color-blue-200), + 'info': ($ibo-color-blue-200), +) !default; + .dataTables_paginate { @extend %ibo-vertically-centered-content; color: $ibo-vendors-datatables--pagination--color; @@ -140,4 +150,10 @@ $ibo-vendors-datatables--row--background-color--is-even: $ibo-color-white-200 !d tr:nth-child(even) { background-color: $ibo-vendors-datatables--row--background-color--is-even; } + @each $sColorLabel, $aAttributes in $ibo-vendors-datatables--row-highlight--colors { + $sBgColor: nth($aAttributes, 1); + tr.ibo-is-#{$sColorLabel}{ + background-color: $sBgColor; + } + } } \ No newline at end of file diff --git a/sources/Controller/AjaxRenderController.php b/sources/Controller/AjaxRenderController.php index ca494bb72..19e257346 100644 --- a/sources/Controller/AjaxRenderController.php +++ b/sources/Controller/AjaxRenderController.php @@ -319,6 +319,10 @@ class AjaxRenderController foreach ($aObject[$sAlias]->GetLoadedAttributes() as $sAttCode) { $aObj[$sAlias."/".$sAttCode] = $aObject[$sAlias]->GetAsHTML($sAttCode); } + $sObjHighlightClass = $aObject[$sAlias]->GetHilightClass(); + if (!empty($sObjHighlightClass)){ + $aObj['@class'] = 'ibo-is-'.$sObjHighlightClass; + } } } if ($sIdName != "") { diff --git a/templates/base/components/datatable/layout.ready.js.twig b/templates/base/components/datatable/layout.ready.js.twig index c21d7993f..8bbee1c9f 100644 --- a/templates/base/components/datatable/layout.ready.js.twig +++ b/templates/base/components/datatable/layout.ready.js.twig @@ -165,6 +165,11 @@ var oTable{{ sListIfForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ method: "post", pages: 1 // number of pages to cache }), + createdRow: function( row, data, dataIndex ) { + if (data['@class'] !== undefined) { + $(row).addClass(data['@class']); + } + }, initComplete: function () { this.api().columns.adjust().draw(); if (this.api().page.info().pages < 2) diff --git a/templates/base/components/datatable/static/formtable/layout.ready.js.twig b/templates/base/components/datatable/static/formtable/layout.ready.js.twig index bc1acfba9..9429451cd 100644 --- a/templates/base/components/datatable/static/formtable/layout.ready.js.twig +++ b/templates/base/components/datatable/static/formtable/layout.ready.js.twig @@ -31,7 +31,12 @@ var table{{ sListIDForVarSuffix }} = $('#{{ oUIBlock.GetId() }}').DataTable({ } else { $(this).closest('.dataTables_wrapper').find('.dataTables_paginate, .dataTables_info').show(); } - } + }, + createdRow: function( row, data, dataIndex ) { + if (data['@class'] !== undefined) { + $(row).addClass(data['@class']); + } + }, }); if ($('#{{ oUIBlock.GetId() }}').find('thead').is(':visible')) { table{{ sListIDForVarSuffix }}.columns.adjust().draw();