N°5904 - Use attribute linked set edit mode to enable actions in view

This commit is contained in:
Benjamin Dalsass
2023-02-06 17:22:30 +01:00
parent 1fe9520b7e
commit de1c58a84c
7 changed files with 75 additions and 93 deletions

View File

@@ -16,6 +16,7 @@ use Combodo\iTop\Application\UI\Base\Component\Panel\PanelUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\Toolbar;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\ToolbarUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Service\Links\LinkSetModel;
use ConfigException;
use CoreException;
use CoreUnexpectedValue;
@@ -267,41 +268,6 @@ class BlockDirectLinksEditTable extends UIContentBlock
return ($bSafe) ? \utils::GetSafeId($sFieldId) : $sFieldId;
}
/**
* Convert edit_mode to relation type.
*
* @return string|null
*/
private function ConvertEditModeToRelationType(): ?string
{
switch ($this->oAttributeLinkedSet->GetEditMode()) {
case LINKSET_EDITMODE_INPLACE:
return LINKSET_RELATIONTYPE_PROPERTY;
case LINKSET_EDITMODE_ADDREMOVE:
return LINKSET_RELATIONTYPE_LINK;
default:
return null;
}
}
/**
* Convert edit_mode to read only.
*
* @return bool
*/
private function ConvertEditModeToReadOnly(): bool
{
switch ($this->oAttributeLinkedSet->GetEditMode()) {
case LINKSET_EDITMODE_NONE:
case LINKSET_EDITMODE_ADDONLY:
case LINKSET_EDITMODE_ACTIONS:
return true;
default:
return false;
}
}
/**
* Return row actions.
*
@@ -311,9 +277,9 @@ class BlockDirectLinksEditTable extends UIContentBlock
{
$aRowActions = array();
if (!$this->ConvertEditModeToReadOnly()) {
if (!LinkSetModel::ConvertEditModeToReadOnly($this->oAttributeLinkedSet)) {
switch ($this->ConvertEditModeToRelationType()) {
switch (LinkSetModel::ConvertEditModeToRelationType($this->oAttributeLinkedSet)) {
case LINKSET_RELATIONTYPE_LINK:
$aRowActions[] = array(