mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 06:28:46 +02:00
N°2677 - Add style definition for classes
This commit is contained in:
@@ -20,19 +20,21 @@ class FieldBadgeFactory
|
||||
*/
|
||||
public static function MakeForField(string $sValue, ?ormStyle $oStyle)
|
||||
{
|
||||
$oBadge = null;
|
||||
if ($oStyle) {
|
||||
$sStyleClass = $oStyle->GetStyleClass();
|
||||
$sPrimaryColor = $oStyle->GetMainColor();
|
||||
$oBadge = new FieldBadge(null, $sStyleClass.' ibo-field-badge');
|
||||
$sComplementaryColor = $oStyle->GetComplementaryColor();
|
||||
$sDecorationClasses = $oStyle->GetDecorationClasses();
|
||||
if ($sDecorationClasses != '') {
|
||||
$oBadge->AddHtml("<i class=\"$sDecorationClasses\"></i> ");
|
||||
}
|
||||
$oBadge->AddHtml("<span>$sValue</span>");
|
||||
// Add custom style
|
||||
// TODO 3.0 To be removed when compilation supports generated CSS
|
||||
$oBadge->AddHtml(<<<HTML
|
||||
if (!is_null($sPrimaryColor) && !is_null($sComplementaryColor)) {
|
||||
$oBadge = new FieldBadge(null, $sStyleClass.' ibo-field-badge');
|
||||
$sDecorationClasses = $oStyle->GetDecorationClasses();
|
||||
if (!is_null($sDecorationClasses)) {
|
||||
$oBadge->AddHtml("<i class=\"$sDecorationClasses\"></i> ");
|
||||
}
|
||||
$oBadge->AddHtml("<span>$sValue</span>");
|
||||
// Add custom style
|
||||
// TODO 3.0 To be removed when compilation supports generated CSS
|
||||
$oBadge->AddHtml(<<<HTML
|
||||
<style>
|
||||
.$sStyleClass {
|
||||
color: $sComplementaryColor;
|
||||
@@ -40,8 +42,10 @@ class FieldBadgeFactory
|
||||
}
|
||||
</style>
|
||||
HTML
|
||||
);
|
||||
} else {
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!$oBadge) {
|
||||
$oBadge = new FieldBadge();
|
||||
$oBadge->AddHtml("<span>$sValue</span>");
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Panel;
|
||||
|
||||
use MetaModel;
|
||||
use ormStyle;
|
||||
|
||||
/**
|
||||
* Class PanelFactory
|
||||
*
|
||||
@@ -163,8 +166,7 @@ class PanelFactory
|
||||
public static function MakeForClass(string $sClass, string $sTitle)
|
||||
{
|
||||
$oPanel = new Panel($sTitle);
|
||||
// TODO 3.0.0: Change this to class color when done
|
||||
$oPanel->SetColor(Panel::ENUM_COLOR_BLUE);
|
||||
self::SetClassColor($sClass, $oPanel);
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
@@ -185,4 +187,24 @@ class PanelFactory
|
||||
|
||||
return $oPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sClass
|
||||
* @param \Combodo\iTop\Application\UI\Base\Component\Panel\Panel $oPanel
|
||||
*
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public static function SetClassColor(string $sClass, Panel $oPanel): void
|
||||
{
|
||||
/** @var ormStyle $oStyle */
|
||||
$sColor = null;
|
||||
$oStyle = MetaModel::GetClassStyle($sClass);
|
||||
if ($oStyle) {
|
||||
$sColor = $oStyle->GetMainColor();
|
||||
}
|
||||
if (strlen($sColor) == 0) {
|
||||
$sColor = Panel::ENUM_COLOR_BLUE;
|
||||
}
|
||||
$oPanel->SetColor($sColor);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user