From e409ee833733bc0aee97133bee7c787b8be43aee Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Wed, 24 Apr 2024 10:34:44 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B06438=20-=20Reloading=20all=20displayed?= =?UTF-8?q?=20tickets=20when=20display=20the=20ticket=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/datatable.class.inc.php | 2 +- core/config.class.inc.php | 8 ++++++++ core/htmlbulkexport.class.inc.php | 3 ++- core/metamodel.class.php | 21 +++++++++++++++++++++ sources/Controller/AjaxRenderController.php | 2 +- 5 files changed, 33 insertions(+), 3 deletions(-) diff --git a/application/datatable.class.inc.php b/application/datatable.class.inc.php index 9de50ee04..e426b9694 100644 --- a/application/datatable.class.inc.php +++ b/application/datatable.class.inc.php @@ -566,7 +566,7 @@ EOF; { if (is_object($aObjects[$sAlias])) { - $sHilightClass = $aObjects[$sAlias]->GetHilightClass(); + $sHilightClass = MetaModel::GetHilightClass($sClassName, $aObjects[$sAlias]); if ($sHilightClass != '') { $aRow['@class'] = $sHilightClass; diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 1491c6ab1..87fe5e0a6 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -560,6 +560,14 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => true, ], + 'list.highlight_abstract_class' => [ + 'type' => 'bool', + 'description' => 'Compute highlight row colors for lists of abstract objects. Mind that setting this to true has a negative impact on performances.', + 'default' => false, + 'value' => false, + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ], 'tag_set_item_separator' => [ 'type' => 'string', 'description' => 'Tag set from string: tag label separator', diff --git a/core/htmlbulkexport.class.inc.php b/core/htmlbulkexport.class.inc.php index 3c27daae7..624db1fcb 100644 --- a/core/htmlbulkexport.class.inc.php +++ b/core/htmlbulkexport.class.inc.php @@ -129,6 +129,7 @@ class HTMLBulkExport extends TabularBulkExport $this->OptimizeColumnLoad($oSet); $sFirstAlias = $this->oSearch->GetClassAlias(); + $sClass = $this->oSearch->GetClass(); $iCount = 0; $sData = ''; @@ -141,7 +142,7 @@ class HTMLBulkExport extends TabularBulkExport $sHilightClass = ''; if ($oMainObj) { - $sHilightClass = $aRow[$sFirstAlias]->GetHilightClass(); + $sHilightClass = MetaModel::GetHilightClass($sClass, $aRow[$sFirstAlias]); } if ($sHilightClass != '') { diff --git a/core/metamodel.class.php b/core/metamodel.class.php index dca1855e1..458fa8e50 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -3697,6 +3697,27 @@ abstract class MetaModel self::$m_aHighlightScales[$sTargetClass] = $aHighlightScale; } + /** + * Get the HTML class to apply to the object in the datatables + * + * @param string $sClass requested for the list (can be abstract) + * @param \DBObject $oObject the object to display + * + * @return string the class to apply to the object + * @throws \ArchivedObjectException + * @throws \CoreException + * + * @since 3.2.0 + */ + final public static function GetHilightClass(string $sClass, DBObject $oObject): string + { + if (self::IsAbstract($sClass) && self::GetConfig()->Get('list.highlight_abstract_class') === false) { + return ''; + } + + return $oObject->GetHilightClass(); + } + /** * @param string $sTargetClass * diff --git a/sources/Controller/AjaxRenderController.php b/sources/Controller/AjaxRenderController.php index 89488a5bc..4572f4ec2 100644 --- a/sources/Controller/AjaxRenderController.php +++ b/sources/Controller/AjaxRenderController.php @@ -117,7 +117,7 @@ class AjaxRenderController } } } - $sObjHighlightClass = $aObject[$sAlias]->GetHilightClass(); + $sObjHighlightClass = MetaModel::GetHilightClass($sClass, $aObject[$sAlias]); if (!empty($sObjHighlightClass)) { $aObj['@class'] = 'ibo-is-'.$sObjHighlightClass; }