N°5905 - Harmonize how linksets are displayed in edition part I

* Always display a table and its actions to ease link creation
* Display linkset description in an alert block
This commit is contained in:
Molkobain
2023-01-25 10:26:13 +01:00
parent 2f034253e7
commit 1dcf38f2ea
5 changed files with 36 additions and 18 deletions

View File

@@ -121,6 +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);

View File

@@ -17,6 +17,7 @@ use Combodo\iTop\Application\UI\Base\iUIBlock;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Dict;
use MetaModel;
use utils;
/**
* Class BlockDirectLinksEditTable
@@ -113,11 +114,12 @@ class BlockDirectLinksEditTable extends UIContentBlock
*/
private function InitUI()
{
// MedallionIcon
$oClassIcon = new MedallionIcon(MetaModel::GetClassIcon($this->oUILinksDirectWidget->GetLinkedClass(), false));
$oClassIcon->SetDescription($this->oAttributeLinkedSet->GetDescription());
$oClassIcon->AddCSSClass('ibo-block-list--medallion');
$this->AddSubBlock($oClassIcon);
// Linkset description as an informative alert
$sDescription = $this->oAttributeLinkedSet->GetDescription();
if (utils::IsNotNullOrEmptyString($sDescription)) {
$oAlert = AlertUIBlockFactory::MakeForInformation('', $sDescription);
$this->AddSubBlock($oAlert);
}
}
/**
@@ -139,8 +141,14 @@ class BlockDirectLinksEditTable extends UIContentBlock
$aRowActions = $this->GetRowActions();
$oDatatable = DataTableUIBlockFactory::MakeForForm($this->oUILinksDirectWidget->GetInputId(), $aAttribs, $aRows, '', $aRowActions);
$oDatatable->SetOptions(['select_mode' => 'custom', 'disable_hyperlinks' => true]);
$aTablePanel = PanelUIBlockFactory::MakeNeutral('');
$aTablePanel->SetSubTitle(sprintf('Total: %d objects.', count($aRows)));
// Panel
$aTablePanel = PanelUIBlockFactory::MakeForClass($this->oUILinksDirectWidget->GetLinkedClass(), $this->oAttributeLinkedSet->GetLabel())
->SetSubTitle(sprintf('Total: %d objects.', count($aRows)))
->SetIcon(MetaModel::GetClassIcon($this->oUILinksDirectWidget->GetLinkedClass(), false))
->AddCSSClass('ibo-datatable-panel');
// Toolbar and actions
$oToolbar = ToolbarUIBlockFactory::MakeForButton();
$oActionButtonUnlink = ButtonUIBlockFactory::MakeNeutral('Unlink');
$oActionButtonUnlink->SetOnClickJsCode("$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('instance')._removeSelection();");
@@ -153,6 +161,7 @@ class BlockDirectLinksEditTable extends UIContentBlock
$oToolbar->AddSubBlock($oActionButtonCreate);
$oActionButtonDelete = ButtonUIBlockFactory::MakeNeutral('Delete');
$oActionButtonDelete->SetOnClickJsCode("$('#{$this->oUILinksDirectWidget->GetInputId()}').directlinks('instance')._deleteSelection();");
$oToolbar->AddSubBlock($oActionButtonDelete);
$aTablePanel->AddToolbarBlock($oToolbar);
$aTablePanel->AddSubBlock($oDatatable);

View File

@@ -38,7 +38,7 @@ class BlockDirectLinksViewTable extends AbstractBlockLinksViewTable
'table_id' => $this->GetTableId(),
'row_actions' => $this->GetRowActions(),
'currentId' => $this->GetTableId(),
'panel_title' => 'TODO: Replace with current tab label?', // TODO 3.1: What to put there: Tab label? Unlikely. Lnk class name? Unlikely. Maybe there should be a dedicated "label" property so we can define the label.
'panel_title' => $this->oAttDef->GetLabel(),
'panel_icon' => MetaModel::GetClassIcon($this->GetTargetClass(), false),
);

View File

@@ -17,6 +17,7 @@ use Combodo\iTop\Application\UI\Base\Component\Toolbar\ToolbarUIBlockFactory;
use Combodo\iTop\Application\UI\Base\iUIBlock;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use MetaModel;
use utils;
/**
* Class BlockIndirectLinksEditTable
@@ -102,15 +103,16 @@ class BlockIndirectLinksEditTable extends UIContentBlock
*/
private function InitUI()
{
// MedallionIcon
$oClassIcon = new MedallionIcon(MetaModel::GetClassIcon($this->oUILinksWidget->GetRemoteClass(), false));
$oClassIcon->SetDescription($this->oAttributeLinkedSetIndirect->GetDescription());
$oClassIcon->AddCSSClass('ibo-block-list--medallion');
$this->AddSubBlock($oClassIcon);
// To prevent adding forms inside the main form
$oDeferredBlock = new UIContentBlock("dlg_{$this->oUILinksWidget->GetLinkedSetId()}", ['ibo-block-indirect-links--edit--dialog']);
$this->AddDeferredBlock($oDeferredBlock);
// Linkset description as an informative alert
$sDescription = $this->oAttributeLinkedSetIndirect->GetDescription();
if (utils::IsNotNullOrEmptyString($sDescription)) {
$oAlert = AlertUIBlockFactory::MakeForInformation('', $sDescription);
$this->AddSubBlock($oAlert);
}
}
/**
@@ -156,7 +158,6 @@ class BlockIndirectLinksEditTable extends UIContentBlock
*/
public function InitTable(\WebPage $oPage, $oValue, $aArgs, $sFormPrefix, $oCurrentObj, $aTableConfig)
{
$this->AddSubBlock(InputUIBlockFactory::MakeForHidden("{$sFormPrefix}{$this->oUILinksWidget->GetInputId()}", '', "{$sFormPrefix}{$this->oUILinksWidget->GetInputId()}"));
$this->sWizHelper = 'oWizardHelper'.$sFormPrefix;
$oValue->Rewind();
$aForm = array();
@@ -195,8 +196,14 @@ class BlockIndirectLinksEditTable extends UIContentBlock
'select_mode' => 'custom',
'disable_hyperlinks' => true,
]);
$aTablePanel = PanelUIBlockFactory::MakeNeutral('');
$aTablePanel->SetSubTitle(sprintf('Total: %d objects.', count($aForm)));
// Panel
$aTablePanel = PanelUIBlockFactory::MakeForClass($this->oUILinksWidget->GetRemoteClass(), $this->oAttributeLinkedSetIndirect->GetLabel())
->SetSubTitle(sprintf('Total: %d objects.', count($aForm)))
->SetIcon(MetaModel::GetClassIcon($this->oUILinksWidget->GetRemoteClass(), false))
->AddCSSClass('ibo-datatable-panel');
// Toolbar and actions
$oToolbar = ToolbarUIBlockFactory::MakeForButton();
$oActionButtonUnlink = ButtonUIBlockFactory::MakeNeutral('Unlink');
$oActionButtonUnlink->SetOnClickJsCode("oWidget{$this->oUILinksWidget->GetInputId()}.RemoveSelected();");
@@ -208,6 +215,7 @@ class BlockIndirectLinksEditTable extends UIContentBlock
$aTablePanel->AddSubBlock($oDataTable);
$this->AddSubBlock($aTablePanel);
$this->AddSubBlock(InputUIBlockFactory::MakeForHidden("{$sFormPrefix}{$this->oUILinksWidget->GetInputId()}", '', "{$sFormPrefix}{$this->oUILinksWidget->GetInputId()}"));
}
/**

View File

@@ -50,7 +50,7 @@ class BlockIndirectLinksViewTable extends AbstractBlockLinksViewTable
'extra_fields' => $this->GetAttCodesToDisplay(),
'row_actions' => $this->GetRowActions(),
'currentId' => $this->GetTableId(),
'panel_title' => 'TODO: Replace with current tab label?', // TODO 3.1: What to put there: Tab label? Unlikely. Lnk class name? Unlikely. Maybe there should be a dedicated "label" property so we can define the label.
'panel_title' => $this->oAttDef->GetLabel(),
'panel_icon' => MetaModel::GetClassIcon($this->GetTargetClass(), false),
);