N°2847 - Prepare object details header for demo (will be reworked)

This commit is contained in:
Molkobain
2020-09-29 14:45:06 +02:00
parent 40f3d6efbe
commit f25ef7f5ac
6 changed files with 113 additions and 20 deletions

View File

@@ -396,7 +396,7 @@ EOF
$sTags = '';
}
$oPage->AddUiBlock(TitleFactory::MakeForObjectDetails($sClassName, $sObjectName, $sObjectIcon));
$oPage->AddUiBlock(TitleFactory::MakeForObjectDetails($this));
}
/**

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -1,8 +1,8 @@
{% apply spaceless %}
<div class="ibo-title">
{% if oUIBlock.HasIcon() %}
<div class="ibo-title--icon">
{{ oUIBlock.GetIcon()|raw }}
<div class="ibo-title--medallion">
<img class="ibo-title--icon" src="{{ oUIBlock.GetIcon() }}" />
</div>
{% endif %}
<div class="ibo-title--content">

View File

@@ -4,4 +4,8 @@
{% block iboPageTitleText %}
<h1 class="ibo-title--for-object-details">{{ oUIBlock.GetClassName() }} <span class="ibo-title--emphasis">{{ oUIBlock.GetObjectName()|raw }}</span></h1>
<div class="ibo-title--status">
<span class="ibo-title--status-dot" style="background-color: {{ oUIBlock.GetStatusColor() }}"></span>
<span class="ibo-title--status-label">{{ oUIBlock.GetStatusLabel() }}</span>
</div>
{% endblock %}