mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°2847 - Add Title component
* Add id to button factory * Rework of Configuration File Editor page
This commit is contained in:
@@ -34,12 +34,13 @@ class ButtonFactory
|
||||
*
|
||||
* @param string $sLabel
|
||||
* @param string $sName See Button::$sName
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeNeutral(string $sLabel, string $sName)
|
||||
public static function MakeNeutral(string $sLabel, string $sName, ?string $sId = null)
|
||||
{
|
||||
$oButton = new Button($sLabel);
|
||||
$oButton = new Button($sLabel, $sId);
|
||||
$oButton->SetActionType(Button::ENUM_ACTION_TYPE_REGULAR)
|
||||
->SetColor(Button::ENUM_COLOR_NEUTRAL)
|
||||
->SetName($sName);
|
||||
@@ -54,12 +55,18 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForPrimaryAction(string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
public static function MakeForPrimaryAction(
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_PRIMARY, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit);
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_PRIMARY, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,12 +76,18 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForSecondaryAction(string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
public static function MakeForSecondaryAction(
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SECONDARY, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit);
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SECONDARY, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,12 +98,18 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForValidationAction(string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
public static function MakeForValidationAction(
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_VALIDATION, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit);
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_VALIDATION, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName, $bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,13 +120,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForDestructiveAction(string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
public static function MakeForDestructiveAction(
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_DESTRUCTIVE, Button::ENUM_ACTION_TYPE_REGULAR, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,12 +140,13 @@ class ButtonFactory
|
||||
*
|
||||
* @param string $sLabel
|
||||
* @param string $sName See Button::$sName
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeAlternativeNeutral(string $sLabel, string $sName)
|
||||
public static function MakeAlternativeNeutral(string $sLabel, string $sName, ?string $sId = null)
|
||||
{
|
||||
$oButton = new Button($sLabel);
|
||||
$oButton = new Button($sLabel, $sId);
|
||||
$oButton->SetActionType(Button::ENUM_ACTION_TYPE_ALTERNATIVE)
|
||||
->SetColor(Button::ENUM_COLOR_NEUTRAL)
|
||||
->SetName($sName);
|
||||
@@ -136,14 +162,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForAlternativePrimaryAction(
|
||||
string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_PRIMARY, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,14 +184,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForAlternativeSecondaryAction(
|
||||
string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_SECONDARY, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,14 +206,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForAlternativeValidationAction(
|
||||
string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_VALIDATION, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,14 +228,19 @@ class ButtonFactory
|
||||
* @param string|null $sName See Button::$sName
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param bool $bIsSubmit See Button::$sType
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
*/
|
||||
public static function MakeForAlternativeDestructiveAction(
|
||||
string $sLabel, string $sName = null, string $sValue = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sName = null,
|
||||
string $sValue = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
return static::MakeForAction($sLabel, Button::ENUM_COLOR_DESTRUCTIVE, Button::ENUM_ACTION_TYPE_ALTERNATIVE, $sValue, $sName,
|
||||
$bIsSubmit);
|
||||
$bIsSubmit, $sId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,30 +252,34 @@ class ButtonFactory
|
||||
* @param string|null $sValue See Button::$sValue
|
||||
* @param string|null $sName See Button::$sValue
|
||||
* @param bool $bIsSubmit
|
||||
* @param string|null $sId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Component\Button\Button
|
||||
* @interal
|
||||
*/
|
||||
protected static function MakeForAction(
|
||||
string $sLabel, string $sColor, string $sActionType, string $sValue = null, string $sName = null, bool $bIsSubmit = false
|
||||
string $sLabel,
|
||||
string $sColor,
|
||||
string $sActionType,
|
||||
string $sValue = null,
|
||||
string $sName = null,
|
||||
bool $bIsSubmit = false,
|
||||
?string $sId = null
|
||||
) {
|
||||
$oButton = new Button($sLabel);
|
||||
$oButton = new Button($sLabel, $sId);
|
||||
$oButton->SetActionType($sActionType)
|
||||
->SetColor($sColor);
|
||||
|
||||
if (empty($sValue) === false)
|
||||
{
|
||||
if (empty($sValue) === false) {
|
||||
$oButton->SetValue($sValue);
|
||||
}
|
||||
|
||||
if (empty($sName) === false)
|
||||
{
|
||||
if (empty($sName) === false) {
|
||||
$oButton->SetName($sName);
|
||||
}
|
||||
|
||||
// Set as submit button if necessary
|
||||
if ($bIsSubmit === true)
|
||||
{
|
||||
if ($bIsSubmit === true) {
|
||||
$oButton->SetType(Button::ENUM_TYPE_SUBMIT);
|
||||
}
|
||||
|
||||
|
||||
51
sources/application/UI/Component/Title/Title.php
Normal file
51
sources/application/UI/Component/Title/Title.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\Title;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
|
||||
/**
|
||||
* Class Title
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Component\Title
|
||||
*/
|
||||
class Title extends UIBlock
|
||||
{
|
||||
// Overloaded constants
|
||||
public const BLOCK_CODE = 'ibo-title';
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/title/layout';
|
||||
public const JS_TEMPLATE_REL_PATH = 'components/title/layout';
|
||||
|
||||
/** @var string */
|
||||
protected $sTitle;
|
||||
/** @var int */
|
||||
protected $iLevel;
|
||||
|
||||
public function __construct(string $sTitle = '', int $iLevel = 1, ?string $sId = null)
|
||||
{
|
||||
parent::__construct($sId);
|
||||
$this->sTitle = $sTitle;
|
||||
$this->iLevel = $iLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function GetTitle(): string
|
||||
{
|
||||
return $this->sTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function GetLevel(): int
|
||||
{
|
||||
return $this->iLevel;
|
||||
}
|
||||
}
|
||||
18
sources/application/UI/Component/Title/TitleFactory.php
Normal file
18
sources/application/UI/Component/Title/TitleFactory.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Component\Title;
|
||||
|
||||
|
||||
class TitleFactory
|
||||
{
|
||||
|
||||
public static function MakeForPage(string $sTitle, ?string $sId = null)
|
||||
{
|
||||
return new Title($sTitle, 1, $sId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user