diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index ff2a4c7653..d0aaebcb04 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -396,7 +396,7 @@ EOF $sTags = ''; } - $oPage->AddUiBlock(TitleFactory::MakeForObjectDetails($sClassName, $sObjectName, $sObjectIcon)); + $oPage->AddUiBlock(TitleFactory::MakeForObjectDetails($this)); } /** diff --git a/css/backoffice/components/_title.scss b/css/backoffice/components/_title.scss index 157a69b9b9..42a1864af5 100644 --- a/css/backoffice/components/_title.scss +++ b/css/backoffice/components/_title.scss @@ -3,25 +3,67 @@ * license http://opensource.org/licenses/AGPL-3.0 */ +$ibo-title--text-color: $ibo-color-grey-900 !default; + +$ibo-title--medallion--size: 90px !default; +$ibo-title--medallion--background-color: $ibo-color-grey-100 !default; +$ibo-title--medallion--border: 2px solid $ibo-color-blue-grey-300 !default; +$ibo-title--medallion--border-radius: $ibo-border-radius-full !default; + +$ibo-title--icon--size: 66.67% !default; + +$ibo-title--status-dot--size: 10px !default; +$ibo-title--status-dot--spacing: 8px !default; +$ibo-title--status-dot--border-radius: $ibo-border-radius-full !default; + .ibo-title { + @extend %ibo-baseline-centered-content; - color: $ibo-color-grey-900; + color: $ibo-title--text-color; +} - .ibo-title--icon { - display: inline-block; - vertical-align: middle; - } +.ibo-title--medallion { + @extend %ibo-fully-centered-content; + width: $ibo-title--medallion--size; + height: $ibo-title--medallion--size; + overflow: hidden; - .ibo-title--content { - display: inline-block; - vertical-align: middle; - } + background-color: $ibo-title--medallion--background-color; + border: $ibo-title--medallion--border; + border-radius: $ibo-title--medallion--border-radius; +} +.ibo-title--icon { + width: $ibo-title--icon--size; + height: auto; + max-width: 100%; + max-height: 100%; +} - .ibo-title--emphasis { +.ibo-title--emphasis { - } +} - .ibo-title--for-object-details { - @extend %ibo-font-ral-nor-350; - } +.ibo-title--for-object-details { + @extend %ibo-font-ral-nor-350; +} + +.ibo-title--status { + @extend %ibo-baseline-centered-content; + @extend %ibo-font-ral-nor-100; +} +.ibo-title--status-dot { + @extend %ibo-fully-centered-content; + + width: $ibo-title--status-dot--size; + height: $ibo-title--status-dot--size; + min-width: $ibo-title--status-dot--size; + min-height: $ibo-title--status-dot--size; + + border-radius: $ibo-title--status-dot--border-radius; +} +.ibo-title--status-label { + +} +.ibo-title--status-dot + .ibo-title--status-label { + margin-left: $ibo-title--status-dot--spacing; } \ No newline at end of file diff --git a/sources/application/UI/Component/Title/TitleFactory.php b/sources/application/UI/Component/Title/TitleFactory.php index 7462de2ce3..6c660d486d 100644 --- a/sources/application/UI/Component/Title/TitleFactory.php +++ b/sources/application/UI/Component/Title/TitleFactory.php @@ -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; } diff --git a/sources/application/UI/Component/Title/TitleForObjectDetails.php b/sources/application/UI/Component/Title/TitleForObjectDetails.php index a29a367fd1..8ee4c57636 100644 --- a/sources/application/UI/Component/Title/TitleForObjectDetails.php +++ b/sources/application/UI/Component/Title/TitleForObjectDetails.php @@ -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; + } } \ No newline at end of file diff --git a/templates/components/title/layout.html.twig b/templates/components/title/layout.html.twig index 2bd51eddc8..7b65d2f67f 100644 --- a/templates/components/title/layout.html.twig +++ b/templates/components/title/layout.html.twig @@ -1,8 +1,8 @@ {% apply spaceless %}
{% if oUIBlock.HasIcon() %} -
- {{ oUIBlock.GetIcon()|raw }} +
+
{% endif %}
diff --git a/templates/components/title/titleforobjectdetails.html.twig b/templates/components/title/titleforobjectdetails.html.twig index 61694a4bd7..9cdb2f743f 100644 --- a/templates/components/title/titleforobjectdetails.html.twig +++ b/templates/components/title/titleforobjectdetails.html.twig @@ -4,4 +4,8 @@ {% block iboPageTitleText %}

{{ oUIBlock.GetClassName() }} {{ oUIBlock.GetObjectName()|raw }}

+
+ + {{ oUIBlock.GetStatusLabel() }} +
{% endblock %} \ No newline at end of file