From ecd5a7aadfbe475e83c4df49cf2ab9d06ec461b0 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 24 Sep 2020 10:45:14 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02847=20-=20FieldSet,=20MultiColumn,=20Ta?= =?UTF-8?q?b=20for=20object=20details=20CSS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/cmdbabstract.class.inc.php | 81 ++++++++----------- css/backoffice/components/_tabcontainer.scss | 7 +- css/backoffice/components/_title.scss | 23 ++++++ lib/composer/autoload_classmap.php | 1 + lib/composer/autoload_static.php | 1 + .../application/UI/Component/Title/Title.php | 20 +++++ .../UI/Component/Title/TitleFactory.php | 8 ++ .../Component/Title/TitleForObjectDetails.php | 44 ++++++++++ sources/application/WebPage/iTopWebPage.php | 7 +- templates/components/html/layout.html.twig | 4 +- templates/components/title/layout.html.twig | 17 +++- .../title/titleforobjectdetails.html.twig | 7 ++ .../layouts/tabcontainer/layout.html.twig | 2 +- 13 files changed, 168 insertions(+), 54 deletions(-) create mode 100644 sources/application/UI/Component/Title/TitleForObjectDetails.php create mode 100644 templates/components/title/titleforobjectdetails.html.twig diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 31cfe1fe4..0fc81015f 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -17,8 +17,10 @@ * You should have received a copy of the GNU Affero General Public License */ +use Combodo\iTop\Application\UI\Component\Alert\AlertFactory; use Combodo\iTop\Application\UI\Component\Field\Field; use Combodo\iTop\Application\UI\Component\FieldSet\FieldSet; +use Combodo\iTop\Application\UI\Component\Title\TitleFactory; use Combodo\iTop\Application\UI\Layout\Column\Column; use Combodo\iTop\Application\UI\Layout\MultiColumn\MultiColumn; @@ -215,46 +217,51 @@ EOF // Standard Header with name, actions menu and history block // - if (!$oPage->IsPrintableVersion()) - { + if (!$oPage->IsPrintableVersion()) { // Is there a message for this object ?? - $aMessages = array(); - $aRanks = array(); - if (MetaModel::GetConfig()->Get('concurrent_lock_enabled')) - { + $aMessages = []; + $aRanks = []; + if (MetaModel::GetConfig()->Get('concurrent_lock_enabled')) { $aLockInfo = iTopOwnershipLock::IsLocked(get_class($this), $this->GetKey()); - if ($aLockInfo['locked']) - { + if ($aLockInfo['locked']) { $aRanks[] = 0; $sName = $aLockInfo['owner']->GetName(); - if ($aLockInfo['owner']->Get('contactid') != 0) - { + if ($aLockInfo['owner']->Get('contactid') != 0) { $sName .= ' ('.$aLockInfo['owner']->Get('contactid_friendlyname').')'; } $aResult['message'] = Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName); - $aMessages[] = "
".Dict::Format('UI:CurrentObjectIsLockedBy_User', - $sName)."
"; + $aMessages[] = AlertFactory::MakeForDanger('', Dict::Format('UI:CurrentObjectIsLockedBy_User', $sName)); } } $sMessageKey = get_class($this).'::'.$this->GetKey(); if (array_key_exists('obj_messages', $_SESSION) && array_key_exists($sMessageKey, - $_SESSION['obj_messages'])) - { - foreach($_SESSION['obj_messages'][$sMessageKey] as $sMessageId => $aMessageData) - { - $sMsgClass = 'message_'.$aMessageData['severity']; - if(!in_array("
".$aMessageData['message']."
",$aMessages)) - { - $aMessages[] = "
".$aMessageData['message']."
"; + $_SESSION['obj_messages'])) { + $aReadMessages = []; + foreach ($_SESSION['obj_messages'][$sMessageKey] as $sMessageId => $aMessageData) { + if (!in_array($aMessageData['message'], $aReadMessages)) { + $aReadMessages[] = $aMessageData['message']; $aRanks[] = $aMessageData['rank']; + switch ($aMessageData['severity']) { + case 'info': + $aMessages[] = AlertFactory::MakeForInformation('', $aMessageData['message']); + break; + case 'ok': + $aMessages[] = AlertFactory::MakeForSuccess('', $aMessageData['message']); + break; + case 'warning': + $aMessages[] = AlertFactory::MakeForWarning('', $aMessageData['message']); + break; + case 'error': + $aMessages[] = AlertFactory::MakeForDanger('', $aMessageData['message']); + break; + } } } unset($_SESSION['obj_messages'][$sMessageKey]); } array_multisort($aRanks, $aMessages); - foreach($aMessages as $sMessage) - { - $oPage->add($sMessage); + foreach ($aMessages as $oMessage) { + $oPage->AddUiBlock($oMessage); } } @@ -364,14 +371,11 @@ EOF } } - if ($this->IsArchived()) - { + if ($this->IsArchived()) { $sLabel = htmlentities(Dict::S('Tag:Archived'), ENT_QUOTES, 'UTF-8'); $sTitle = htmlentities(Dict::S('Tag:Archived+'), ENT_QUOTES, 'UTF-8'); $aIcons[] = "
  $sLabel
"; - } - elseif ($this->IsObsolete()) - { + } elseif ($this->IsObsolete()) { $sLabel = htmlentities(Dict::S('Tag:Obsolete'), ENT_QUOTES, 'UTF-8'); $sTitle = htmlentities(Dict::S('Tag:Obsolete+'), ENT_QUOTES, 'UTF-8'); $aIcons[] = "
  $sLabel
"; @@ -380,28 +384,13 @@ EOF $sObjectIcon = $this->GetIcon(); $sClassName = MetaModel::GetName(get_class($this)); $sObjectName = $this->GetName(); - if (count($aIcons) > 0) - { + if (count($aIcons) > 0) { $sTags = '
'.implode(' ', $aIcons).'
'; - } - else - { + } else { $sTags = ''; } - $oPage->add( - << -
-
$sObjectIcon
-
-

$sClassName: $sObjectName

- $sTags -
-
- -EOF - ); + $oPage->AddUiBlock(TitleFactory::MakeForObjectDetails($sClassName, $sObjectName, $sObjectIcon)); } /** diff --git a/css/backoffice/components/_tabcontainer.scss b/css/backoffice/components/_tabcontainer.scss index f99572413..78392ccaa 100644 --- a/css/backoffice/components/_tabcontainer.scss +++ b/css/backoffice/components/_tabcontainer.scss @@ -4,8 +4,11 @@ */ .ibo-tab-container { - //border: 1px solid $ibo-color-grey-400; - //border-radius: 5px; + +} + +.ibo-tab-container-header { + background: $ibo-color-grey-100; } .ibo-tab-header { diff --git a/css/backoffice/components/_title.scss b/css/backoffice/components/_title.scss index 2b1c120e8..ddbbc5574 100644 --- a/css/backoffice/components/_title.scss +++ b/css/backoffice/components/_title.scss @@ -2,3 +2,26 @@ * copyright Copyright (C) 2010-2020 Combodo SARL * license http://opensource.org/licenses/AGPL-3.0 */ + +.ibo-title { + + color: $ibo-color-grey-900; + + .ibo-title--icon { + display: inline-block; + vertical-align: middle; + } + + .ibo-title--content { + display: inline-block; + vertical-align: middle; + } + + .ibo-title--emphasis { + + } + + .ibo-title--for-object-details { + @extend %ibo-font-ral-med-350; + } +} \ No newline at end of file diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index e45a082d9..c1d948bd8 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -183,6 +183,7 @@ return array( 'Combodo\\iTop\\Application\\UI\\Component\\QuickCreate\\QuickCreateHelper' => $baseDir . '/sources/application/UI/Component/QuickCreate/QuickCreateHelper.php', 'Combodo\\iTop\\Application\\UI\\Component\\Title\\Title' => $baseDir . '/sources/application/UI/Component/Title/Title.php', 'Combodo\\iTop\\Application\\UI\\Component\\Title\\TitleFactory' => $baseDir . '/sources/application/UI/Component/Title/TitleFactory.php', + 'Combodo\\iTop\\Application\\UI\\Component\\Title\\TitleForObjectDetails' => $baseDir . '/sources/application/UI/Component/Title/TitleForObjectDetails.php', 'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\ActivityEntry' => $baseDir . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php', 'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\ActivityEntryFactory' => $baseDir . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/ActivityEntryFactory.php', 'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\CMDBChangeOp\\CMDBChangeOpAttachmentAddedFactory' => $baseDir . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/CMDBChangeOp/CMDBChangeOpAttachmentAddedFactory.php', diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index b3aa92969..33f9177bd 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -413,6 +413,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b 'Combodo\\iTop\\Application\\UI\\Component\\QuickCreate\\QuickCreateHelper' => __DIR__ . '/../..' . '/sources/application/UI/Component/QuickCreate/QuickCreateHelper.php', 'Combodo\\iTop\\Application\\UI\\Component\\Title\\Title' => __DIR__ . '/../..' . '/sources/application/UI/Component/Title/Title.php', 'Combodo\\iTop\\Application\\UI\\Component\\Title\\TitleFactory' => __DIR__ . '/../..' . '/sources/application/UI/Component/Title/TitleFactory.php', + 'Combodo\\iTop\\Application\\UI\\Component\\Title\\TitleForObjectDetails' => __DIR__ . '/../..' . '/sources/application/UI/Component/Title/TitleForObjectDetails.php', 'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\ActivityEntry' => __DIR__ . '/../..' . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/ActivityEntry.php', 'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\ActivityEntryFactory' => __DIR__ . '/../..' . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/ActivityEntryFactory.php', 'Combodo\\iTop\\Application\\UI\\Layout\\ActivityPanel\\ActivityEntry\\CMDBChangeOp\\CMDBChangeOpAttachmentAddedFactory' => __DIR__ . '/../..' . '/sources/application/UI/Layout/ActivityPanel/ActivityEntry/CMDBChangeOp/CMDBChangeOpAttachmentAddedFactory.php', diff --git a/sources/application/UI/Component/Title/Title.php b/sources/application/UI/Component/Title/Title.php index a9e9a8980..d3c2f42ac 100644 --- a/sources/application/UI/Component/Title/Title.php +++ b/sources/application/UI/Component/Title/Title.php @@ -25,12 +25,15 @@ class Title extends UIBlock protected $sTitle; /** @var int */ protected $iLevel; + /** @var string */ + protected $sIconHtml; public function __construct(string $sTitle = '', int $iLevel = 1, ?string $sId = null) { parent::__construct($sId); $this->sTitle = $sTitle; $this->iLevel = $iLevel; + $this->sIconHtml = null; } /** @@ -48,4 +51,21 @@ class Title extends UIBlock { return $this->iLevel; } + + public function SetIcon(string $sIconHtml): self + { + $this->sIconHtml = $sIconHtml; + return $this; + } + + public function GetIcon(): string + { + return $this->sIconHtml; + } + + public function HasIcon(): string + { + return !is_null($this->sIconHtml); + } + } \ 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 84b6a8567..7462de2ce 100644 --- a/sources/application/UI/Component/Title/TitleFactory.php +++ b/sources/application/UI/Component/Title/TitleFactory.php @@ -15,4 +15,12 @@ class TitleFactory { return new Title($sTitle, 1, $sId); } + + public static function MakeForObjectDetails(string $sClassName, string $sObjectName, string $sIconHtml, ?string $sId = null) + { + $oTitle = new TitleForObjectDetails($sClassName, $sObjectName, $sId); + $oTitle->SetIcon($sIconHtml); + + return $oTitle; + } } \ No newline at end of file diff --git a/sources/application/UI/Component/Title/TitleForObjectDetails.php b/sources/application/UI/Component/Title/TitleForObjectDetails.php new file mode 100644 index 000000000..a29a367fd --- /dev/null +++ b/sources/application/UI/Component/Title/TitleForObjectDetails.php @@ -0,0 +1,44 @@ +sClassName = $sClassName; + $this->sObjectName = $sObjectName; + } + + /** + * @return string + */ + public function GetClassName(): string + { + return $this->sClassName; + } + + /** + * @return string + */ + public function GetObjectName(): string + { + return $this->sObjectName; + } + + +} \ No newline at end of file diff --git a/sources/application/WebPage/iTopWebPage.php b/sources/application/WebPage/iTopWebPage.php index 369ee9f09..01dd9f072 100644 --- a/sources/application/WebPage/iTopWebPage.php +++ b/sources/application/WebPage/iTopWebPage.php @@ -19,6 +19,7 @@ use Combodo\iTop\Application\TwigBase\Twig\TwigHelper; +use Combodo\iTop\Application\UI\Component\Panel\Panel; use Combodo\iTop\Application\UI\iUIBlock; use Combodo\iTop\Application\UI\Layout\NavigationMenu\NavigationMenuFactory; use Combodo\iTop\Application\UI\Layout\PageContent\PageContent; @@ -1229,7 +1230,11 @@ EOF; */ public function AddTabContainer($sTabContainer, $sPrefix = '') { - $this->AddUiBlock($this->m_oTabs->AddTabContainer($sTabContainer, $sPrefix)); + $oPanel = new Panel(''); + // TODO 2.8.0 Change color according to object + $oPanel->SetColor(Panel::ENUM_COLOR_BLUE); + $oPanel->AddSubBlock($this->m_oTabs->AddTabContainer($sTabContainer, $sPrefix)); + $this->AddUiBlock($oPanel); } /** diff --git a/templates/components/html/layout.html.twig b/templates/components/html/layout.html.twig index 3da5b4e9f..ef12b8056 100644 --- a/templates/components/html/layout.html.twig +++ b/templates/components/html/layout.html.twig @@ -1,3 +1 @@ -{% apply spaceless %} - {{ oUIBlock.GetHtml()|raw }} -{% endapply %} \ No newline at end of file +{{ oUIBlock.GetHtml()|raw }} \ No newline at end of file diff --git a/templates/components/title/layout.html.twig b/templates/components/title/layout.html.twig index 6af485b5b..2bd51eddc 100644 --- a/templates/components/title/layout.html.twig +++ b/templates/components/title/layout.html.twig @@ -1 +1,16 @@ -{{ oUIBlock.GetTitle() }} \ No newline at end of file +{% apply spaceless %} +
+ {% if oUIBlock.HasIcon() %} +
+ {{ oUIBlock.GetIcon()|raw }} +
+ {% endif %} +
+ {% block iboPageTitleText %} + + {{ oUIBlock.GetTitle()|raw }} + + {% endblock %} +
+
+{% endapply %} \ No newline at end of file diff --git a/templates/components/title/titleforobjectdetails.html.twig b/templates/components/title/titleforobjectdetails.html.twig new file mode 100644 index 000000000..61694a4bd --- /dev/null +++ b/templates/components/title/titleforobjectdetails.html.twig @@ -0,0 +1,7 @@ +{# @copyright Copyright (C) 2010-2020 Combodo SARL #} +{# @license http://opensource.org/licenses/AGPL-3.0 #} +{% extends 'components/title/layout.html.twig' %} + +{% block iboPageTitleText %} +

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

+{% endblock %} \ No newline at end of file diff --git a/templates/layouts/tabcontainer/layout.html.twig b/templates/layouts/tabcontainer/layout.html.twig index 3eec27d7a..0317c16c9 100644 --- a/templates/layouts/tabcontainer/layout.html.twig +++ b/templates/layouts/tabcontainer/layout.html.twig @@ -3,7 +3,7 @@ {% block iboTabContainer %}
-