N°2847 - Datatable modal dialogs

This commit is contained in:
Eric
2020-11-19 17:45:46 +01:00
parent 26d912f059
commit 32e0c8f9bf
24 changed files with 541 additions and 170 deletions

View File

@@ -225,7 +225,8 @@ class PageContent extends UIBlock implements iUIContentBlock {
*
* @inheritDoc
*/
public function GetSubBlocks(): array {
public function GetSubBlocks(): array
{
$aSubBlocks = [];
foreach ($this->GetContentAreas() as $oContentArea) {
$aSubBlocks = array_merge($aSubBlocks, $oContentArea->GetSubBlocks());
@@ -233,4 +234,90 @@ class PageContent extends UIBlock implements iUIContentBlock {
return $aSubBlocks;
}
public function GetDeferredBlocks(): array
{
$aSubBlocks = [];
foreach ($this->GetContentAreas() as $oContentArea) {
$aSubBlocks = array_merge($aSubBlocks, $oContentArea->GetDeferredBlocks());
}
return $aSubBlocks;
}
/**
* Add the $oDeferredBlock directly in the main area
*
* @inheritDoc
*/
public function AddDeferredBlock(iUIBlock $oDeferredBlock)
{
$this->AddDeferredBlockToContentArea(static::ENUM_CONTENT_AREA_MAIN, $oDeferredBlock);
return $this;
}
/**
* Remove a specified subBlock from all the areas
*
* @param string $sId
*
* @return $this
*/
public function RemoveDeferredBlock(string $sId)
{
foreach ($this->GetContentAreas() as $oContentArea) {
$oContentArea->RemoveDeferredBlock($sId);
}
return $this;
}
/**
* Check if the specified subBlock is within one of all the areas
*
* @param string $sId
*
* @return bool
*/
public function HasDeferredBlock(string $sId): bool
{
foreach ($this->GetContentAreas() as $oContentArea) {
if ($oContentArea->HasDeferredBlock($sId)) {
return true;
}
}
return false;
}
/**
* Get a specific subBlock within all the areas
*
* @inheritDoc
*/
public function GetDeferredBlock(string $sId): ?iUIBlock
{
foreach ($this->GetContentAreas() as $oContentArea) {
$oDeferredBlock = $oContentArea->GetDeferredBlock($sId);
if (!is_null($oDeferredBlock)) {
return $oDeferredBlock;
}
}
return null;
}
/**
* Set the MAIN AREA subBlocks
*
* @inheritDoc
* @return $this|\Combodo\iTop\Application\UI\Layout\iUIContentBlock
*/
public function SetDeferredBlocks(array $aDeferredBlocks): iUIContentBlock
{
$this->SetContentAreaDeferredBlocks(self::ENUM_CONTENT_AREA_MAIN, $aDeferredBlocks);
return $this;
}
}

View File

@@ -33,6 +33,8 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
protected $aDataAttributes;
/** @var array */
protected $aSubBlocks;
/** @var array */
protected $aDeferredBlocks;
/**
* UIContentBlock constructor.
@@ -45,6 +47,7 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
parent::__construct($sName);
$this->aSubBlocks = [];
$this->aDeferredBlocks = [];
$this->aDataAttributes = [];
$this->SetCSSClasses($sContainerClass);
}
@@ -52,7 +55,8 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
/**
* @inheritDoc
*/
public function AddHtml(string $sHtml) {
public function AddHtml(string $sHtml)
{
$oBlock = new Html($sHtml);
$this->AddSubBlock($oBlock);
@@ -62,7 +66,8 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
/**
* @inheritDoc
*/
public function AddSubBlock(iUIBlock $oSubBlock) {
public function AddSubBlock(iUIBlock $oSubBlock)
{
$this->aSubBlocks[$oSubBlock->GetId()] = $oSubBlock;
return $this;
@@ -71,7 +76,8 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
/**
* @inheritDoc
*/
public function RemoveSubBlock(string $sId) {
public function RemoveSubBlock(string $sId)
{
if ($this->HasSubBlock($sId)) {
unset($this->aSubBlocks[$sId]);
}
@@ -82,28 +88,32 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
/**
* @inheritDoc
*/
public function HasSubBlock(string $sId): bool {
public function HasSubBlock(string $sId): bool
{
return array_key_exists($sId, $this->aSubBlocks);
}
/**
* @inheritDoc
*/
public function GetSubBlock(string $sId): ?iUIBlock {
public function GetSubBlock(string $sId): ?iUIBlock
{
return isset($this->aSubBlocks[$sId]) ? $this->aSubBlocks[$sId] : null;
}
/**
* @inheritDoc
*/
public function GetSubBlocks(): array {
public function GetSubBlocks(): array
{
return $this->aSubBlocks;
}
/**
* @inheritDoc
*/
public function SetSubBlocks(array $aSubBlocks) {
public function SetSubBlocks(array $aSubBlocks)
{
foreach ($aSubBlocks as $oSubBlock) {
$this->AddSubBlock($oSubBlock);
}
@@ -114,7 +124,8 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
/**
* @return string
*/
public function GetCSSClasses(): string {
public function GetCSSClasses(): string
{
return implode(' ', $this->aCSSClasses);
}
@@ -123,7 +134,8 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
*
* @return UIContentBlock
*/
public function SetCSSClasses(string $sCSSClasses) {
public function SetCSSClasses(string $sCSSClasses)
{
$this->aCSSClasses = [];
$this->AddCSSClasses($sCSSClasses);
@@ -135,7 +147,8 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
*
* @return $this
*/
public function AddCSSClasses(string $sCSSClasses) {
public function AddCSSClasses(string $sCSSClasses)
{
foreach (explode(' ', $sCSSClasses) as $sCSSClass) {
if (!empty($sCSSClass)) {
$this->aCSSClasses[$sCSSClass] = $sCSSClass;
@@ -177,4 +190,62 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
return $this;
}
/**
* @inheritDoc
*/
public function AddDeferredBlock(iUIBlock $oDeferredBlock)
{
$this->aDeferredBlocks[$oDeferredBlock->GetId()] = $oDeferredBlock;
return $this;
}
/**
* @inheritDoc
*/
public function RemoveDeferredBlock(string $sId)
{
if ($this->HasDeferredBlock($sId)) {
unset($this->aDeferredBlocks[$sId]);
}
return $this;
}
/**
* @inheritDoc
*/
public function HasDeferredBlock(string $sId): bool
{
return array_key_exists($sId, $this->aDeferredBlocks);
}
/**
* @inheritDoc
*/
public function GetDeferredBlock(string $sId): ?iUIBlock
{
return isset($this->aDeferredBlocks[$sId]) ? $this->aDeferredBlocks[$sId] : null;
}
/**
* @inheritDoc
*/
public function GetDeferredBlocks(): array
{
return $this->aDeferredBlocks;
}
/**
* @inheritDoc
*/
public function SetDeferredBlocks(array $aDeferredBlocks)
{
foreach ($aDeferredBlocks as $oDeferredBlock) {
$this->AddDeferredBlock($oDeferredBlock);
}
return $this;
}
}

View File

@@ -79,4 +79,59 @@ interface iUIContentBlock {
* @return $this
*/
public function SetSubBlocks(array $aSubBlocks);
/**
* Add $oDeferredBlock, replacing any block with the same ID
*
* @param \Combodo\iTop\Application\UI\iUIBlock $oDeferredBlock
*
* @return $this
*/
public function AddDeferredBlock(iUIBlock $oDeferredBlock);
/**
* Remove the sub block identified by $sId.
* Note that if no sub block matches the ID, it proceeds silently.
*
* @param string $sId ID of the sub block to remove
*
* @return $this
*/
public function RemoveDeferredBlock(string $sId);
/**
* Return true if there is a sub block identified by $sId
*
* @param string $sId
*
* @return bool
*/
public function HasDeferredBlock(string $sId): bool;
/**
* Return the sub block identified by $sId or null if not found
*
* @param string $sId
*
* @return \Combodo\iTop\Application\UI\iUIBlock|null
*/
public function GetDeferredBlock(string $sId): ?iUIBlock;
/**
* Return an array of all the sub blocks
*
* @return \Combodo\iTop\Application\UI\iUIBlock[]
*/
public function GetDeferredBlocks(): array;
/**
* Set all sub blocks at once, replacing all existing ones
*
* @param \Combodo\iTop\Application\UI\iUIBlock[] $aDeferredBlocks
*
* @return $this
*/
public function SetDeferredBlocks(array $aDeferredBlocks);
}