N°3123 - Moved Popup Menu Items JS parts to UIBlocks

This commit is contained in:
Eric
2020-11-27 17:25:50 +01:00
parent fd5958b764
commit 4099a8ef5a
4 changed files with 92 additions and 24 deletions

View File

@@ -64,6 +64,11 @@ abstract class UIBlock implements iUIBlock
/** @var string $sId */
protected $sId;
/** @var array */
protected $aJsFilesRelPath;
/** @var array */
protected $aCssFilesRelPath;
/**
* UIBlock constructor.
*
@@ -72,6 +77,8 @@ abstract class UIBlock implements iUIBlock
public function __construct(?string $sId = null)
{
$this->sId = $sId ?? $this->GenerateId();
$this->aJsFilesRelPath = [];
$this->aCssFilesRelPath = [];
}
/**
@@ -99,7 +106,7 @@ abstract class UIBlock implements iUIBlock
/**
* @inheritDoc
*/
public static function GetJsFilesRelPaths() {
public function GetJsFilesRelPaths() {
return static::JS_FILES_REL_PATH;
}
@@ -114,9 +121,9 @@ abstract class UIBlock implements iUIBlock
/**
* @inheritDoc
*/
public static function GetCssFilesRelPaths()
public function GetCssFilesRelPaths()
{
return static::CSS_FILES_REL_PATH;
return array_merge(static::CSS_FILES_REL_PATH, $this->aCssFilesRelPath);
}
/**
@@ -201,6 +208,24 @@ abstract class UIBlock implements iUIBlock
return [];
}
/**
* @inheritDoc
*/
public function AddJsFileRelPath(string $sPath)
{
$this->aJsFilesRelPath[] = $sPath;
return $this;
}
/**
* @inheritDoc
*/
public function AddCssFileRelPath(string $sPath)
{
$this->aCssFilesRelPath[] = $sPath;
return $this;
}
/**
* **Warning**, this shouldn't generate any dot as this will be used in CSS and JQuery selectors !
*
@@ -229,7 +254,7 @@ abstract class UIBlock implements iUIBlock
$sFilesRelPathMethodName = 'Get'.ucfirst($sFileType).'FilesRelPaths';
// Files from the block itself
foreach ($this::$sFilesRelPathMethodName() as $sFilePath) {
foreach ($this->$sFilesRelPathMethodName() as $sFilePath) {
$aFiles[] = (($bAbsoluteUrl === true) ? utils::GetAbsoluteUrlAppRoot() : '').$sFilePath;
}