N°3882 - Header dynamic: Pills now shows the real color from the DM

This commit is contained in:
Molkobain
2021-09-23 09:25:16 +02:00
parent 197864ff83
commit 1cb100b010
13 changed files with 139 additions and 74 deletions

View File

@@ -9,6 +9,7 @@ namespace Combodo\iTop\Application\UI\Base\Component\Pill;
use Combodo\iTop\Application\UI\Helper\UIHelper;
use MetaModel;
/**
* Class PillFactory
@@ -25,12 +26,21 @@ class PillFactory
* @param string $sStateCode
*
* @return \Combodo\iTop\Application\UI\Base\Component\Pill\Pill
* @throws \CoreException
*/
public static function MakeForState(string $sClass, string $sStateCode)
{
$sColor = UIHelper::GetColorFromStatus($sClass, $sStateCode);
$oPill = new Pill();
return new Pill($sColor);
// First we try to apply style defined in the DM if any, otherwise we fallback on the default colors
$oStyle = MetaModel::GetEnumStyle($sClass, MetaModel::GetStateAttributeCode($sClass), $sStateCode);
if ($oStyle !== null) {
$oPill->SetCSSColorClass($oStyle->GetStyleClass());
} else {
$oPill->SetSemanticColor(UIHelper::GetColorFromStatusCode($sStateCode));
}
return $oPill;
}
}