N°5905 - Move tab description to a tooltip on the panel's title instead of a big blue alert

This commit is contained in:
Molkobain
2023-01-27 17:24:50 +01:00
parent 0374e303e4
commit af2421a2cb
6 changed files with 31 additions and 7 deletions

View File

@@ -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 */

View File

@@ -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
*

View File

@@ -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'])){

View File

@@ -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);
}
}
/**

View File

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

View File

@@ -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()) {