N°2847 - Add Title component

* Add id to button factory
 * Rework of Configuration File Editor page
This commit is contained in:
Eric
2020-09-18 18:15:03 +02:00
parent 08eada82f4
commit 74160d2447
13 changed files with 287 additions and 215 deletions

View File

@@ -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);
}

View 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;
}
}

View 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);
}
}