N°3564 Alert and CollapsibleSectionState can now be saved

This commit is contained in:
Pierre Goiffon
2020-12-24 11:36:51 +01:00
parent d3efd3ea0e
commit 2c0d001721
7 changed files with 128 additions and 5 deletions

View File

@@ -21,6 +21,7 @@ namespace Combodo\iTop\Application\UI\Base\Component\Alert;
use Combodo\iTop\Application\UI\Base\UIBlock;
use utils;
/**
* Class Alert
@@ -96,6 +97,10 @@ class Alert extends UIBlock
protected $bIsCollapsible;
/** @var bool Whether the alert is opened by default or not, only works when $bIsCollapsible set to true */
protected $bIsOpenedByDefault;
/** @var boolean if true will store collapsible state */
protected $bIsSaveCollapsibleStateEnabled = false;
/** @var string localStorage key used to store collapsible state */
protected $sSectionStateStorageKey;
/**
* Alert constructor.
@@ -116,6 +121,20 @@ class Alert extends UIBlock
parent::__construct($sId);
}
/**
* @param $sSectionStateStorageKey
*
* @return self
*/
public function EnableSaveCollapsibleState($sSectionStateStorageKey)
{
$this->bIsSaveCollapsibleStateEnabled = true;
$sSectionStateStorageKeyPrefix = utils::GetConfig()->GetItopInstanceid();
$this->sSectionStateStorageKey = $sSectionStateStorageKeyPrefix.'/'.$sSectionStateStorageKey;
return $this;
}
/**
* @return string
*/
@@ -247,4 +266,14 @@ class Alert extends UIBlock
return $this;
}
public function IsSaveCollapsibleStateEnabled(): bool
{
return $this->bIsSaveCollapsibleStateEnabled;
}
public function GetSessionCollapsibleStateStorageKey(): string
{
return $this->sSectionStateStorageKey;
}
}