mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-02 07:34:13 +01:00
N°6385 - Move Linkset flags and edit_when logic from UIBlock to DisplayBareRelations
This commit is contained in:
@@ -91,11 +91,11 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
|
||||
* @param string $sObjectClass
|
||||
* @param string $sAttCode
|
||||
* @param AttributeLinkedSet $oAttDef
|
||||
* @param bool $bIsReadOnly
|
||||
*
|
||||
* @throws CoreException
|
||||
* @throws Exception
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public function __construct(WebPage $oPage, DBObject $oDbObject, string $sObjectClass, string $sAttCode, AttributeLinkedSet $oAttDef)
|
||||
public function __construct(WebPage $oPage, DBObject $oDbObject, string $sObjectClass, string $sAttCode, AttributeLinkedSet $oAttDef, bool $bIsReadOnly = false)
|
||||
{
|
||||
parent::__construct("links_view_table_$sAttCode", ["ibo-block-links-table"]);
|
||||
|
||||
@@ -105,6 +105,7 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
|
||||
$this->sObjectClass = $sObjectClass;
|
||||
$this->oDbObject = $oDbObject;
|
||||
$this->sTableId = 'rel_'.$this->sAttCode;
|
||||
$this->bIsAttEditable = !$bIsReadOnly;
|
||||
$this->SetDataAttributes(['role' => 'ibo-block-links-table', 'link-attcode' => $sAttCode, 'link-class' => $this->oAttDef->GetLinkedClass()]);
|
||||
// Initialization
|
||||
$this->Init();
|
||||
@@ -122,7 +123,6 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
|
||||
private function Init()
|
||||
{
|
||||
$this->sTargetClass = $this->GetTargetClass();
|
||||
$this->InitIsAttEditable();
|
||||
|
||||
// User rights
|
||||
$this->bIsAllowCreate = $this->bIsAttEditable && UserRights::IsActionAllowed($this->oAttDef->GetLinkedClass(), UR_ACTION_CREATE) == UR_ALLOWED_YES;
|
||||
@@ -199,38 +199,8 @@ abstract class AbstractBlockLinkSetViewTable extends UIContentBlock
|
||||
$oBlock = new DisplayBlock($oLinkSet->GetFilter(), DisplayBlock::ENUM_STYLE_LIST_IN_OBJECT, false);
|
||||
$this->AddSubBlock($oBlock->GetRenderContent($oPage, $this->GetExtraParam(), $this->sTableId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \CoreException
|
||||
*/
|
||||
private function InitIsAttEditable(): void
|
||||
{
|
||||
$iFlags = OPT_ATT_NORMAL;
|
||||
|
||||
if ($this->oDbObject->IsNew())
|
||||
{
|
||||
$iFlags = $this->oDbObject->GetInitialStateAttributeFlags($this->sAttCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
$iFlags = $this->oDbObject->GetAttributeFlags($this->sAttCode);
|
||||
}
|
||||
|
||||
$bEditWhen = $this->IsEditableBasedOnEditWhen();
|
||||
|
||||
$this->bIsAttEditable = !($iFlags & (OPT_ATT_READONLY | OPT_ATT_SLAVE | OPT_ATT_HIDDEN)) && $bEditWhen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares Linkset attribute edit_when values with its usage requirements
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.1.1 3.2.0 N°6385
|
||||
*/
|
||||
protected function IsEditableBasedOnEditWhen(): bool{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* GetTableId.
|
||||
|
||||
Reference in New Issue
Block a user