N°3629 - Activity panel: Add possibility to close the panel

This commit is contained in:
Molkobain
2021-03-01 15:29:15 +01:00
parent 1cdedec33d
commit e3015a284b
11 changed files with 343 additions and 80 deletions

View File

@@ -59,8 +59,8 @@ class ActivityPanel extends UIBlock
/** @var \DBObject $oObject The object for which the activity panel is for */
protected $oObject;
/**
* @var string $sObjectMode Display mode of $oObject (create, edit, view, ...)
* @see \cmdbAbstractObject::ENUM_OBJECT_MODE_XXX
* @var string $sObjectMode Display mode of $oObject (create, edit, view, ...)
*/
protected $sObjectMode;
/** @var null|string $sTransactionId Only when $sObjectMode is set to \cmdbAbstractObject::ENUM_OBJECT_MODE_VIEW */
@@ -198,6 +198,34 @@ class ActivityPanel extends UIBlock
return $this->sObjectMode;
}
/**
* @return bool True if it should be expanded, false otherwise. Based on the user pref. or reduced by default.
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
public function IsExpanded(): bool
{
$bDefault = false;
$aStates = appUserPreferences::GetPref('activity_panel.is_expanded', []);
return $aStates[$this->GetObjectClass().'::'.$this->GetObjectMode()] ?? $bDefault;
}
/**
* @return bool True if it should be closed, false otherwise. Based on the user pref. or closed by default if the object has no case log.
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
*/
public function IsClosed(): bool
{
$bDefault = !$this->HasCaseLogTabs();
$aStates = appUserPreferences::GetPref('activity_panel.is_closed', []);
return $aStates[$this->GetObjectClass().'::'.$this->GetObjectMode()] ?? $bDefault;
}
/**
* @return bool
* @uses static::$sTransactionId
@@ -669,6 +697,15 @@ class ActivityPanel extends UIBlock
return utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php';
}
/**
* @return string The endpoint for the state (expanded, closed, ...) changes to be saved
* @throws \Exception
*/
public function GetSaveStateEndpoint(): string
{
return utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php';
}
/**
* @inheritdoc
*/