N°3649 - Activity panel: Work on multiple caselogs edition at once

This commit is contained in:
Molkobain
2021-02-02 10:59:48 +01:00
parent 5f00362805
commit 8026965915
12 changed files with 219 additions and 60 deletions

View File

@@ -10,6 +10,7 @@ use Combodo\iTop\Application\UI\Base\Component\Input\RichText\RichText;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Application\UI\Base\UIBlock;
use DBObject;
/**
* Class CaseLogEntryForm
@@ -34,6 +35,10 @@ class CaseLogEntryForm extends UIContentBlock
/** @var string */
public const DEFAULT_SUBMIT_MODE = self::ENUM_SUBMIT_MODE_AUTONOMOUS;
/** @var DBObject Object hosting the case log attribute */
protected $oObject;
/** @var string Attribute code of the case log in $oObject */
protected $sAttCode;
/**
* @var string Whether the form can send data on its own or if it's bridged with its host object form
* @see static::ENUM_SUBMIT_MODE_XXX
@@ -51,15 +56,54 @@ class CaseLogEntryForm extends UIContentBlock
/**
* CaseLogEntryForm constructor.
*
* @param null $sId
* @param \DBObject $oObject
* @param string|null $sId
*/
public function __construct($sId = null)
public function __construct(DBObject $oObject, string $sAttCode, string $sId = null)
{
parent::__construct($sId);
$this->oObject = $oObject;
$this->sAttCode = $sAttCode;
$this->sSubmitMode = static::DEFAULT_SUBMIT_MODE;
$this->SetTextInput(new RichText());
$this->aMainActionButtons = [];
$this->aExtraActionButtons = [];
$this->InitTextInput();
}
/**
* @uses static::$oObject
* @return \DBObject
*/
public function GetObject(): DBObject
{
return $this->oObject;
}
/**
* @uses static::$oObject
* @return string The class of $oObject
*/
public function GetObjectClass(): string
{
return get_class($this->oObject);
}
/**
* @uses static::$oObject
* @return string The ID of $oObject
*/
public function GetObjectId(): string
{
return $this->oObject->GetKey();
}
/**
* @uses static::$sAttCode
* @return string
*/
public function GetAttCode(): string
{
return $this->sAttCode;
}
/**
@@ -144,6 +188,16 @@ class CaseLogEntryForm extends UIContentBlock
return $this;
}
/**
* @uses $oTextInput
* @return $this
*/
protected function InitTextInput()
{
$this->oTextInput = new RichText();
return $this;
}
/**
* @return \Combodo\iTop\Application\UI\Base\UIBlock[]
*/

View File

@@ -34,7 +34,7 @@ class CaseLogEntryFormFactory
{
public static function MakeForCaselogTab(DBObject $oObject, string $sCaseLogAttCode, string $sObjectMode = cmdbAbstractObject::DEFAULT_OBJECT_MODE)
{
$oCaseLogEntryForm = new CaseLogEntryForm();
$oCaseLogEntryForm = new CaseLogEntryForm($oObject, $sCaseLogAttCode);
$oCaseLogEntryForm->SetSubmitModeFromHostObjectMode($sObjectMode)
->AddMainActionButtons(static::PrepareCancelButton())
->AddMainActionButtons(static::PrepareSaveButton())