mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 06:28:46 +02:00
N°2847 - Prepare object details header for demo (will be reworked)
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
namespace Combodo\iTop\Application\UI\Component\Title;
|
||||
|
||||
|
||||
use DBObject;
|
||||
use MetaModel;
|
||||
|
||||
class TitleFactory
|
||||
{
|
||||
|
||||
@@ -16,10 +19,26 @@ class TitleFactory
|
||||
return new Title($sTitle, 1, $sId);
|
||||
}
|
||||
|
||||
public static function MakeForObjectDetails(string $sClassName, string $sObjectName, string $sIconHtml, ?string $sId = null)
|
||||
public static function MakeForObjectDetails(DBObject $oObject, ?string $sId = null)
|
||||
{
|
||||
$oTitle = new TitleForObjectDetails($sClassName, $sObjectName, $sId);
|
||||
$oTitle->SetIcon($sIconHtml);
|
||||
// TODO 2.8.0: Refactor all of this
|
||||
$sObjIconUrl = $oObject->GetIcon(false);
|
||||
$sObjClass = get_class($oObject);
|
||||
$sObjClassName = MetaModel::GetName($sObjClass);
|
||||
$sObjName = $oObject->GetName();
|
||||
|
||||
$oTitle = new TitleForObjectDetails($sObjClassName, $sObjName, $sId);
|
||||
$oTitle->SetIcon($sObjIconUrl);
|
||||
|
||||
$sStatusAttCode = MetaModel::GetStateAttributeCode($sObjClass);
|
||||
if(!empty($sStatusAttCode))
|
||||
{
|
||||
$sStatusLabel = $oObject->GetStateLabel();
|
||||
// TODO 2.8.0 : Dehardcode this
|
||||
$sStatusColor = 'green';
|
||||
|
||||
$oTitle->SetStatus($sStatusAttCode, $sStatusLabel, $sStatusColor);
|
||||
}
|
||||
|
||||
return $oTitle;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,18 @@ class TitleForObjectDetails extends Title
|
||||
protected $sClassName;
|
||||
/** @var string */
|
||||
protected $sObjectName;
|
||||
protected $sStatusCode;
|
||||
protected $sStatusLabel;
|
||||
protected $sStatusColor;
|
||||
|
||||
public function __construct(string $sClassName, string $sObjectName, ?string $sId = null)
|
||||
{
|
||||
parent::__construct('', 2, $sId);
|
||||
$this->sClassName = $sClassName;
|
||||
$this->sObjectName = $sObjectName;
|
||||
$this->sStatusCode = null;
|
||||
$this->sStatusLabel = null;
|
||||
$this->sStatusColor = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,5 +46,27 @@ class TitleForObjectDetails extends Title
|
||||
return $this->sObjectName;
|
||||
}
|
||||
|
||||
public function SetStatus($sCode, $sLabel, $sColor)
|
||||
{
|
||||
$this->sStatusCode = $sColor;
|
||||
$this->sStatusLabel = $sLabel;
|
||||
$this->sStatusColor = $sColor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetStatusCode()
|
||||
{
|
||||
return $this->sStatusCode;
|
||||
}
|
||||
|
||||
public function GetStatusLabel()
|
||||
{
|
||||
return $this->sStatusLabel;
|
||||
}
|
||||
|
||||
public function GetStatusColor()
|
||||
{
|
||||
return $this->sStatusColor;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user