From af2421a2cbe8c2e0e8fbb2fd711d95458fc7fa0a Mon Sep 17 00:00:00 2001 From: Molkobain Date: Fri, 27 Jan 2023 17:24:50 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B05905=20-=20Move=20tab=20description=20to?= =?UTF-8?q?=20a=20tooltip=20on=20the=20panel's=20title=20instead=20of=20a?= =?UTF-8?q?=20big=20blue=20alert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/displayblock.class.inc.php | 2 ++ core/attributedef.class.inc.php | 10 ++++++++++ .../Component/DataTable/DataTableUIBlockFactory.php | 7 +++++++ .../UI/Links/AbstractBlockLinksViewTable.php | 9 ++------- .../UI/Links/Direct/BlockDirectLinksViewTable.php | 5 +++++ .../UI/Links/Indirect/BlockIndirectLinksViewTable.php | 5 +++++ 6 files changed, 31 insertions(+), 7 deletions(-) diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 5947ce253..42b86433e 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -272,6 +272,8 @@ class DisplayBlock 'panel_title', /** string true if panel title should be displayed as html */ 'panel_title_is_html', + /** string Description of the panel content, displayed as a hint on the title */ + 'panel_title_tooltip', /** string class for panel block style */ 'panel_class', /** string class for panel block style */ diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index 7265ad373..9c5fb540c 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -651,6 +651,16 @@ abstract class AttributeDefinition return $sLabel; } + /** + * @return bool True if the attribute has a description {@see \AttributeDefinition::GetDescription()} + * @throws \Exception + * @since 3.1.0 + */ + public function HasDescription(): bool + { + return utils::IsNotNullOrEmptyString($this->GetDescription()); + } + /** * @param string|null $sDefault * diff --git a/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index b0b674ad3..4a6c6994e 100644 --- a/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -157,6 +157,13 @@ class DataTableUIBlockFactory extends AbstractUIBlockFactory $oContainer->SetTitle($aExtraParams['panel_title']); } } + // - Description + if (isset($aExtraParams['panel_title_tooltip'])) { + $oContainerTitleBlock = $oContainer->GetTitleBlock() + ->AddDataAttribute('tooltip-content', $aExtraParams['panel_title_tooltip']) + ->AddDataAttribute('tooltip-max-width', 'min(600px, 90vw)') // Allow big description to be wide enough while shrinking on small screens + ->AddCSSClass('ibo-has-description'); + } // Panel subtitle if(!empty($oDataTable->GetInitDisplayData()) && isset($oDataTable->GetInitDisplayData()['recordsTotal'])){ diff --git a/sources/Application/UI/Links/AbstractBlockLinksViewTable.php b/sources/Application/UI/Links/AbstractBlockLinksViewTable.php index 3bbff1ba5..d8b4da691 100644 --- a/sources/Application/UI/Links/AbstractBlockLinksViewTable.php +++ b/sources/Application/UI/Links/AbstractBlockLinksViewTable.php @@ -113,7 +113,7 @@ abstract class AbstractBlockLinksViewTable extends UIContentBlock } /** - * InitHeader. + * InitHeader by adding UIBlocks to the current self * * @return void * @throws CoreException @@ -121,12 +121,7 @@ abstract class AbstractBlockLinksViewTable extends UIContentBlock */ private function InitHeader() { - // Linkset description as an informative alert - $sDescription = $this->oAttDef->GetDescription(); - if (utils::IsNotNullOrEmptyString($sDescription)) { - $oAlert = AlertUIBlockFactory::MakeForInformation('', $sDescription); - $this->AddSubBlock($oAlert); - } + } /** diff --git a/sources/Application/UI/Links/Direct/BlockDirectLinksViewTable.php b/sources/Application/UI/Links/Direct/BlockDirectLinksViewTable.php index 0c1b3cae6..52c5c7554 100644 --- a/sources/Application/UI/Links/Direct/BlockDirectLinksViewTable.php +++ b/sources/Application/UI/Links/Direct/BlockDirectLinksViewTable.php @@ -42,6 +42,11 @@ class BlockDirectLinksViewTable extends AbstractBlockLinksViewTable 'panel_icon' => MetaModel::GetClassIcon($this->GetTargetClass(), false), ); + // Description + if ($this->oAttDef->HasDescription()) { + $aExtraParams['panel_title_tooltip'] = $this->oAttDef->GetDescription(); + } + // Add creation in modal if the linkset is not readonly if (!$this->oAttDef->GetReadOnly()) { $aExtraParams['creation_in_modal_is_allowed'] = true; diff --git a/sources/Application/UI/Links/Indirect/BlockIndirectLinksViewTable.php b/sources/Application/UI/Links/Indirect/BlockIndirectLinksViewTable.php index 57d1cc6c8..f7e2848d4 100644 --- a/sources/Application/UI/Links/Indirect/BlockIndirectLinksViewTable.php +++ b/sources/Application/UI/Links/Indirect/BlockIndirectLinksViewTable.php @@ -53,6 +53,11 @@ class BlockIndirectLinksViewTable extends AbstractBlockLinksViewTable 'panel_title' => $this->oAttDef->GetLabel(), 'panel_icon' => MetaModel::GetClassIcon($this->GetTargetClass(), false), ); + + // Description + if ($this->oAttDef->HasDescription()) { + $aExtraParams['panel_title_tooltip'] = $this->oAttDef->GetDescription(); + } // Add creation in modal if the linkset is not readonly if (!$this->oAttDef->GetReadOnly()) {