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

@@ -22,6 +22,7 @@ namespace Combodo\iTop\Application\UI\Base\Component\CollapsibleSection;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Application\UI\Base\tUIContentAreas;
use utils;
/**
* @package Combodo\iTop\Application\UI\Base\Component\CollapsibleSection
@@ -43,6 +44,10 @@ class CollapsibleSection extends UIContentBlock
protected $bIsOpenedByDefault = false;
/** @var string */
private $sTitle;
/** @var boolean if true will store collapsible state */
protected $bIsSaveCollapsibleStateEnabled = false;
/** @var string localStorage key used to store collapsible state */
protected $sSectionStateStorageKey;
public function __construct(string $sTitle, array $aSubBlocks = [], ?string $sId = null)
{
@@ -51,6 +56,19 @@ class CollapsibleSection extends UIContentBlock
$this->aSubBlocks = $aSubBlocks;
}
/**
* @param $sSectionStateStorageKey
*
* @return self
*/
public function EnableSaveCollapsibleState($sSectionStateStorageKey)
{
$this->bIsSaveCollapsibleStateEnabled = true;
$sSectionStateStorageKeyPrefix = utils::GetConfig()->GetItopInstanceid();
$this->sSectionStateStorageKey = $sSectionStateStorageKeyPrefix.'/'.$sSectionStateStorageKey;
return $this;
}
public function IsOpenedByDefault()
{
@@ -73,4 +91,14 @@ class CollapsibleSection extends UIContentBlock
{
return $this->sTitle;
}
public function IsSaveCollapsibleStateEnabled(): bool
{
return $this->bIsSaveCollapsibleStateEnabled;
}
public function GetSessionCollapsibleStateStorageKey(): string
{
return $this->sSectionStateStorageKey;
}
}