mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°8955 New UIBlocks for setup
This commit is contained in:
@@ -2,41 +2,64 @@
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Layout\Extension;
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\Component\Badge\Badge;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Input\Toggler;
|
||||
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
|
||||
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItemFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
|
||||
use JSButtonItem;
|
||||
|
||||
class ExtensionDetails extends UIContentBlock {
|
||||
class ExtensionDetails extends UIContentBlock
|
||||
{
|
||||
public const BLOCK_CODE = 'ibo-extension-details';
|
||||
|
||||
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/extension/extension-details/layout';
|
||||
|
||||
public const DEFAULT_JS_ON_READY_TEMPLATE_REL_PATH = 'base/layouts/extension/extension-details/layout';
|
||||
|
||||
protected string $sCode;
|
||||
protected string $sLabel;
|
||||
protected string $sAbout;
|
||||
protected array $aMetaData;
|
||||
protected string $sDescription;
|
||||
protected Toggler $oToggler;
|
||||
protected UIContentBlock $oMoreActions;
|
||||
protected PopoverMenu $oPopoverMenu;
|
||||
protected array $aBadges;
|
||||
|
||||
public function __construct(string $sCode, string $sLabel, string $sDescription = '', array $aMetaData = [], string $sId = null) {
|
||||
|
||||
public function __construct(string $sCode, string $sLabel, string $sDescription = '', array $aMetaData = [], array $aBadges = [], string $sAbout = '', string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->sCode = $sCode;
|
||||
$this->sLabel = $sLabel;
|
||||
$this->sDescription = $sDescription;
|
||||
$this->aMetaData = $aMetaData;
|
||||
$this->aBadges = $aBadges;
|
||||
$this->sAbout = $sAbout;
|
||||
$this->InitializeToggler();
|
||||
$this->InitializePopoverMenu();
|
||||
}
|
||||
|
||||
public function GetSubBlocks(): array
|
||||
{
|
||||
return [$this->oToggler->GetId() => $this->oToggler, $this->oMoreActions->GetId() => $this->oMoreActions];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetCode(): string {
|
||||
public function GetCode(): string
|
||||
{
|
||||
return $this->sCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sCode
|
||||
*
|
||||
* @return ExtensionDetails
|
||||
*/
|
||||
public function SetCode(string $sCode) {
|
||||
public function SetCode(string $sCode): static
|
||||
{
|
||||
$this->sCode = $sCode;
|
||||
return $this;
|
||||
}
|
||||
@@ -44,14 +67,18 @@ class ExtensionDetails extends UIContentBlock {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetLabel(): string {
|
||||
public function GetLabel(): string
|
||||
{
|
||||
return $this->sLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sLabel
|
||||
*
|
||||
* @return ExtensionDetails
|
||||
*/
|
||||
public function SetLabel(string $sLabel) {
|
||||
public function SetLabel(string $sLabel): static
|
||||
{
|
||||
$this->sLabel = $sLabel;
|
||||
return $this;
|
||||
}
|
||||
@@ -59,14 +86,18 @@ class ExtensionDetails extends UIContentBlock {
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function GetMetaData(): array {
|
||||
public function GetMetaData(): array
|
||||
{
|
||||
return $this->aMetaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aMetaData
|
||||
*
|
||||
* @return ExtensionDetails
|
||||
*/
|
||||
public function SetMetaData(array $aMetaData) {
|
||||
public function SetMetaData(array $aMetaData): static
|
||||
{
|
||||
$this->aMetaData = $aMetaData;
|
||||
return $this;
|
||||
}
|
||||
@@ -74,29 +105,37 @@ class ExtensionDetails extends UIContentBlock {
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetDescription(): string {
|
||||
public function GetDescription(): string
|
||||
{
|
||||
return $this->sDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sDescription
|
||||
*
|
||||
* @return ExtensionDetails
|
||||
*/
|
||||
public function SetDescription(string $sDescription) {
|
||||
public function SetDescription(string $sDescription): static
|
||||
{
|
||||
$this->sDescription = $sDescription;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Input\Toggler
|
||||
* @return Toggler
|
||||
*/
|
||||
public function GetToggler(): Toggler {
|
||||
public function GetToggler(): Toggler
|
||||
{
|
||||
return $this->oToggler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Combodo\iTop\Application\UI\Base\Component\Input\Toggler $oToggler
|
||||
* @param Toggler $oToggler
|
||||
*
|
||||
* @return ExtensionDetails
|
||||
*/
|
||||
public function SetToggler(Toggler $oToggler) {
|
||||
public function SetToggler(Toggler $oToggler): static
|
||||
{
|
||||
$this->oToggler = $oToggler;
|
||||
return $this;
|
||||
}
|
||||
@@ -104,21 +143,73 @@ class ExtensionDetails extends UIContentBlock {
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function GetBadges(): array {
|
||||
public function GetBadges(): array
|
||||
{
|
||||
return $this->aBadges;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aBadges
|
||||
*
|
||||
* @return ExtensionDetails
|
||||
*/
|
||||
public function SetBadges(array $aBadges) {
|
||||
public function SetBadges(array $aBadges): static
|
||||
{
|
||||
$this->aBadges = $aBadges;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function InitializeToggler(){
|
||||
|
||||
public function AddBadge(Badge $oBadge): static
|
||||
{
|
||||
$this->aBadges[] = $oBadge;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function GetMoreActions(): UIContentBlock
|
||||
{
|
||||
return $this->oMoreActions;
|
||||
}
|
||||
|
||||
protected function InitializeToggler()
|
||||
{
|
||||
$this->oToggler = new Toggler();
|
||||
$this->oToggler->SetName('ExtensionToggler');
|
||||
}
|
||||
|
||||
}
|
||||
protected function InitializePopoverMenu()
|
||||
{
|
||||
$sModalLabel = 'About '.$this->sLabel;
|
||||
$sModalText = $this->sAbout;
|
||||
$oModifyButton = new JSButtonItem(
|
||||
'extension_details',
|
||||
'More informations',
|
||||
<<<JS
|
||||
CombodoModal.OpenModal({
|
||||
title: '$sModalLabel',
|
||||
content: '$sModalText',
|
||||
});
|
||||
JS,
|
||||
);
|
||||
$this->oPopoverMenu = new PopoverMenu();
|
||||
$this->oPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oModifyButton));
|
||||
$oPopoverOpenButton = ButtonUIBlockFactory::MakeIconAction('fas fa-ellipsis-v', 'Show more actions');
|
||||
$this->oPopoverMenu->SetTogglerFromBlock($oPopoverOpenButton);
|
||||
$this->oMoreActions = new UIContentBlock();
|
||||
$this->oMoreActions->AddSubBlock($this->oPopoverMenu);
|
||||
$this->oMoreActions->AddSubBlock($oPopoverOpenButton);
|
||||
}
|
||||
|
||||
public function AllowForceUninstall()
|
||||
{
|
||||
$oForceUninstallButton = new JSButtonItem(
|
||||
'force_uninstall',
|
||||
'Force uninstall',
|
||||
<<<JS
|
||||
this.style.display = 'none';
|
||||
this.closest('.ibo-extension-details').querySelector('input[type=checkbox]').disabled = false
|
||||
JS,
|
||||
);
|
||||
$this->oPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oForceUninstallButton));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user