Panel: Remove PanelEnhanced as the Panel now has all the necessary options

This commit is contained in:
Molkobain
2021-03-04 17:56:34 +01:00
parent 3bc130c802
commit 1e64e0c741
8 changed files with 59 additions and 152 deletions

View File

@@ -25,6 +25,8 @@ use Combodo\iTop\Application\UI\Base\iUIBlock;
use Combodo\iTop\Application\UI\Base\Layout\iUIContentBlock;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Application\UI\Base\tUIContentAreas;
use MetaModel;
use ormStyle;
/**
* Class Panel
@@ -92,6 +94,8 @@ class Panel extends UIContentBlock
/** @var string DEFAULT_COLOR */
public const DEFAULT_COLOR = self::ENUM_COLOR_NEUTRAL;
/** @var string Default color for a panel displaying info about a datamodel class */
public const DEFAULT_COLOR_FOR_CLASS = self::ENUM_COLOR_BLUE;
/** @var null */
public const DEFAULT_ICON_URL = null;
/** @var string */
@@ -244,6 +248,44 @@ class Panel extends UIContentBlock
return $this;
}
/**
* Set the panel's color from an ormStyle directly.
*
* Use cases:
* - Display information about a datamodel class
* - Display information about a particular enum value (linked objects)
*
* @param \ormStyle $oStyle
*
* @return $this
*/
public function SetColorFromOrmStyle(ormStyle $oStyle)
{
$sColor = empty($oStyle->GetMainColor()) ? static::DEFAULT_COLOR : $oStyle->GetMainColor();
$this->SetColor($sColor);
return $this;
}
/**
* Set the panel's color to the one corresponding to the $sClass datamodel class
*
* @param string $sClass
*
* @return $this
*/
public function SetColorFromClass(string $sClass)
{
$oStyle = MetaModel::GetClassStyle($sClass);
if (empty($oStyle)) {
$this->SetColor(static::DEFAULT_COLOR_FOR_CLASS);
} else {
$this->SetColorFromOrmStyle($oStyle);
}
return $this;
}
/**
* @see static::$oSubTitleBlock
* @return bool