Add UIBlocks to twig (Changed classes name)

This commit is contained in:
Eric
2021-01-19 17:21:48 +01:00
parent c15a60170d
commit 01c4dff035
27 changed files with 182 additions and 122 deletions

View File

@@ -151,8 +151,6 @@ return array(
'Combodo\\iTop\\Application\\TwigBase\\Controller\\PageNotFoundException' => $baseDir . '/sources/application/TwigBase/Controller/Controller.php',
'Combodo\\iTop\\Application\\TwigBase\\Twig\\Extension' => $baseDir . '/sources/application/TwigBase/Twig/Extension.php',
'Combodo\\iTop\\Application\\TwigBase\\Twig\\TwigHelper' => $baseDir . '/sources/application/TwigBase/Twig/TwigHelper.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIHtmlNode' => $baseDir . '/sources/application/TwigBase/UI/Component/Html/UIHtmlNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIHtmlParser' => $baseDir . '/sources/application/TwigBase/UI/Component/Html/UIHtmlParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockExtension' => $baseDir . '/sources/application/TwigBase/UI/UIBlockExtension.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockNode' => $baseDir . '/sources/application/TwigBase/UI/UIBlockNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockParser' => $baseDir . '/sources/application/TwigBase/UI/UIBlockParser.php',
@@ -194,8 +192,10 @@ return array(
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputUIBlockFactory' => $baseDir . '/sources/application/UI/Base/Component/Input/InputUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputWithLabel' => $baseDir . '/sources/application/UI/Base/Component/Input/InputWithLabel.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\RichText\\RichText' => $baseDir . '/sources/application/UI/Base/Component/Input/RichText/RichText.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\SelectUIBlockFactory' => $baseDir . '/sources/application/UI/Base/Component/Input/Select/SelectUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\Select' => $baseDir . '/sources/application/UI/Base/Component/Input/Select/Select.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\SelectOption' => $baseDir . '/sources/application/UI/Base/Component/Input/Select/SelectOption.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\SelectOptionUIBlockFactory' => $baseDir . '/sources/application/UI/Base/Component/Input/Select/SelectOptionUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\TextArea' => $baseDir . '/sources/application/UI/Base/Component/Input/TextArea.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\Panel' => $baseDir . '/sources/application/UI/Base/Component/Panel/Panel.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\PanelEnhanced' => $baseDir . '/sources/application/UI/Base/Component/Panel/PanelEnhanced.php',
@@ -528,31 +528,8 @@ return array(
'PEAR' => $vendorDir . '/pear/pear-core-minimal/src/PEAR.php',
'PEAR_ErrorStack' => $vendorDir . '/pear/pear-core-minimal/src/PEAR/ErrorStack.php',
'PEAR_Exception' => $vendorDir . '/pear/pear_exception/PEAR/Exception.php',
'PHP_LexerGenerator' => $baseDir . '/core/oql/build/PHP/LexerGenerator.php',
'PHP_LexerGenerator_Exception' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Exception.php',
'PHP_LexerGenerator_Lexer' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Lexer.php',
'PHP_LexerGenerator_Parser' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Parser.php',
'PHP_LexerGenerator_ParseryyStackEntry' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Parser.php',
'PHP_LexerGenerator_ParseryyToken' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Parser.php',
'PHP_LexerGenerator_Regex_Lexer' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Regex/Lexer.php',
'PHP_LexerGenerator_Regex_Parser' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php',
'PHP_LexerGenerator_Regex_yyStackEntry' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php',
'PHP_LexerGenerator_Regex_yyToken' => $baseDir . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php',
'PHP_ParserGenerator' => $baseDir . '/core/oql/build/PHP/ParserGenerator.php',
'PHP_ParserGenerator_Action' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Action.php',
'PHP_ParserGenerator_ActionTable' => $baseDir . '/core/oql/build/PHP/ParserGenerator/ActionTable.php',
'PHP_ParserGenerator_Config' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Config.php',
'PHP_ParserGenerator_Data' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Data.php',
'PHP_ParserGenerator_Parser' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Parser.php',
'PHP_ParserGenerator_PropagationLink' => $baseDir . '/core/oql/build/PHP/ParserGenerator/PropagationLink.php',
'PHP_ParserGenerator_Rule' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Rule.php',
'PHP_ParserGenerator_State' => $baseDir . '/core/oql/build/PHP/ParserGenerator/State.php',
'PHP_ParserGenerator_StateNode' => $baseDir . '/core/oql/build/PHP/ParserGenerator/State.php',
'PHP_ParserGenerator_Symbol' => $baseDir . '/core/oql/build/PHP/ParserGenerator/Symbol.php',
'Page' => $baseDir . '/sources/application/WebPage/Page.php',
'ParseError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ParseError.php',
'ParseyyStackEntry' => $baseDir . '/core/oql/build/PHP/Lempar.php',
'ParseyyToken' => $baseDir . '/core/oql/build/PHP/Lempar.php',
'Pelago\\Emogrifier' => $vendorDir . '/pelago/emogrifier/src/Emogrifier.php',
'Pelago\\Emogrifier\\CssConcatenator' => $vendorDir . '/pelago/emogrifier/src/Emogrifier/CssConcatenator.php',
'Pelago\\Emogrifier\\CssInliner' => $vendorDir . '/pelago/emogrifier/src/Emogrifier/CssInliner.php',

View File

@@ -381,8 +381,6 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'Combodo\\iTop\\Application\\TwigBase\\Controller\\PageNotFoundException' => __DIR__ . '/../..' . '/sources/application/TwigBase/Controller/Controller.php',
'Combodo\\iTop\\Application\\TwigBase\\Twig\\Extension' => __DIR__ . '/../..' . '/sources/application/TwigBase/Twig/Extension.php',
'Combodo\\iTop\\Application\\TwigBase\\Twig\\TwigHelper' => __DIR__ . '/../..' . '/sources/application/TwigBase/Twig/TwigHelper.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIHtmlNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Html/UIHtmlNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIHtmlParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Html/UIHtmlParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockExtension' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/UIBlockExtension.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/UIBlockNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/UIBlockParser.php',
@@ -424,8 +422,10 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputUIBlockFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/InputUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputWithLabel' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/InputWithLabel.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\RichText\\RichText' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/RichText/RichText.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\SelectUIBlockFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Select/SelectUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\Select' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Select/Select.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\SelectOption' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Select/SelectOption.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Select\\SelectOptionUIBlockFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/Select/SelectOptionUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\TextArea' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Input/TextArea.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\Panel' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Panel/Panel.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\PanelEnhanced' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Panel/PanelEnhanced.php',
@@ -758,31 +758,8 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'PEAR' => __DIR__ . '/..' . '/pear/pear-core-minimal/src/PEAR.php',
'PEAR_ErrorStack' => __DIR__ . '/..' . '/pear/pear-core-minimal/src/PEAR/ErrorStack.php',
'PEAR_Exception' => __DIR__ . '/..' . '/pear/pear_exception/PEAR/Exception.php',
'PHP_LexerGenerator' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator.php',
'PHP_LexerGenerator_Exception' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Exception.php',
'PHP_LexerGenerator_Lexer' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Lexer.php',
'PHP_LexerGenerator_Parser' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Parser.php',
'PHP_LexerGenerator_ParseryyStackEntry' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Parser.php',
'PHP_LexerGenerator_ParseryyToken' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Parser.php',
'PHP_LexerGenerator_Regex_Lexer' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Regex/Lexer.php',
'PHP_LexerGenerator_Regex_Parser' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php',
'PHP_LexerGenerator_Regex_yyStackEntry' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php',
'PHP_LexerGenerator_Regex_yyToken' => __DIR__ . '/../..' . '/core/oql/build/PHP/LexerGenerator/Regex/Parser.php',
'PHP_ParserGenerator' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator.php',
'PHP_ParserGenerator_Action' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Action.php',
'PHP_ParserGenerator_ActionTable' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/ActionTable.php',
'PHP_ParserGenerator_Config' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Config.php',
'PHP_ParserGenerator_Data' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Data.php',
'PHP_ParserGenerator_Parser' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Parser.php',
'PHP_ParserGenerator_PropagationLink' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/PropagationLink.php',
'PHP_ParserGenerator_Rule' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Rule.php',
'PHP_ParserGenerator_State' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/State.php',
'PHP_ParserGenerator_StateNode' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/State.php',
'PHP_ParserGenerator_Symbol' => __DIR__ . '/../..' . '/core/oql/build/PHP/ParserGenerator/Symbol.php',
'Page' => __DIR__ . '/../..' . '/sources/application/WebPage/Page.php',
'ParseError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ParseError.php',
'ParseyyStackEntry' => __DIR__ . '/../..' . '/core/oql/build/PHP/Lempar.php',
'ParseyyToken' => __DIR__ . '/../..' . '/core/oql/build/PHP/Lempar.php',
'Pelago\\Emogrifier' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier.php',
'Pelago\\Emogrifier\\CssConcatenator' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier/CssConcatenator.php',
'Pelago\\Emogrifier\\CssInliner' => __DIR__ . '/..' . '/pelago/emogrifier/src/Emogrifier/CssInliner.php',

View File

@@ -21,6 +21,7 @@ use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Form\Form;
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
use Combodo\iTop\Application\UI\Base\Component\Input\InputUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOptionUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Panel\Panel;
use Combodo\iTop\Application\UI\Base\Component\Title\TitleUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Layout\PageContent\PageContentFactory;
@@ -305,8 +306,8 @@ JS
$sRichTextToolbarDefaultState = isset(utils::GetCkeditorPref()['toolbarStartupExpanded']) ? (bool)utils::GetCkeditorPref()['toolbarStartupExpanded'] : false;
$oRichTextToolbarDefaultStateInput = InputUIBlockFactory::MakeForSelectWithLabel('toolbarexpanded', Dict::S('UI:RichText:ToolbarState'));
$oRichTextToolbarDefaultStateInput->GetInput()->AddOption(InputUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:RichText:ToolbarState:Expanded'), $sRichTextToolbarDefaultState));
$oRichTextToolbarDefaultStateInput->GetInput()->AddOption(InputUIBlockFactory::MakeForSelectOption('false', Dict::S('UI:RichText:ToolbarState:Collapsed'), !$sRichTextToolbarDefaultState));
$oRichTextToolbarDefaultStateInput->GetInput()->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:RichText:ToolbarState:Expanded'), $sRichTextToolbarDefaultState));
$oRichTextToolbarDefaultStateInput->GetInput()->AddOption(SelectOptionUIBlockFactory::MakeForSelectOption('false', Dict::S('UI:RichText:ToolbarState:Collapsed'), !$sRichTextToolbarDefaultState));
$oRichTextForm->AddSubBlock($oRichTextToolbarDefaultStateInput);
// - Cancel button
@@ -333,8 +334,8 @@ JS
$sTabsScrollableValue = appUserPreferences::GetPref('tab_scrollable', false);;
$oTabsScrollable = InputUIBlockFactory::MakeForSelectWithLabel('tab_scrollable', Dict::S('UI:Tabs:Scrollable:Label'));
$oTabsScrollable->GetInput()->AddOption(InputUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:Tabs:Scrollable:Scrollable'), true === $sTabsScrollableValue));
$oTabsScrollable->GetInput()->AddOption(InputUIBlockFactory::MakeForSelectOption('false', Dict::S('UI:Tabs:Scrollable:Classic'), false === $sTabsScrollableValue));
$oTabsScrollable->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption('true', Dict::S('UI:Tabs:Scrollable:Scrollable'), true === $sTabsScrollableValue));
$oTabsScrollable->GetInput()->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption('false', Dict::S('UI:Tabs:Scrollable:Classic'), false === $sTabsScrollableValue));
$oTabsForm->AddSubBlock($oTabsScrollable);
// - Cancel button
@@ -434,7 +435,7 @@ function GetUserLanguageForm(ApplicationContext $oAppContext, string $sURL): For
$oUserLanguageBlockSelectInput = $oUserLanguageBlockSelect->GetInput();
foreach ($aSortedLang as $sCode) {
$bSelected = ($sCode == Dict::GetUserLanguage());
$oUserLanguageBlockSelectInput->AddOption(InputUIBlockFactory::MakeForSelectOption($sCode, $aLanguages[$sCode]['description'].' ('.$aLanguages[$sCode]['localized_description'].')', $bSelected));
$oUserLanguageBlockSelectInput->AddSubBlock(SelectOptionUIBlockFactory::MakeForSelectOption($sCode, $aLanguages[$sCode]['description'].' ('.$aLanguages[$sCode]['localized_description'].')', $bSelected));
}
$oUserLanguageForm->AddSubBlock($oUserLanguageBlockSelect);

View File

@@ -33,7 +33,7 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
class AlertUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UIAlert';
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Alert\\Alert";
public const UI_BLOCK_CLASS_NAME = Alert::class;
/**
* Make a basis Alert component

View File

@@ -34,7 +34,7 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
class ButtonUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UIButton';
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Button\\Button";
public const UI_BLOCK_CLASS_NAME = Button::class;
//---------------------------------------------
// Regular action buttons, mostly used in forms

View File

@@ -13,7 +13,7 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
class CollapsibleSectionUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UICollapsibleSection';
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\CollapsibleSection\\CollapsibleSection";
public const UI_BLOCK_CLASS_NAME = CollapsibleSection::class;
public static function MakeStandard(string $sTitle, ?string $sId = null)
{

View File

@@ -36,7 +36,7 @@ use WebPage;
class DataTableUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UIDataTable';
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTable";
public const UI_BLOCK_CLASS_NAME = DataTable::class;
/**
* @param \WebPage $oPage

View File

@@ -17,7 +17,7 @@ use Combodo\iTop\Application\UI\Base\UIBlock;
class FieldUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UIField';
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Field\\Field";
public const UI_BLOCK_CLASS_NAME = Field::class;
public static function MakeFromParams($aParams)
{

View File

@@ -13,9 +13,9 @@ use ormStyle;
class FieldBadgeUIBlockFactory extends AbstractUIBlockFactory
{
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\FieldBadge\\FieldBadge";
public const TWIG_TAG_NAME = 'UIFieldBadge';
public const UI_BLOCK_CLASS_NAME = FieldBadge::class;
/**
* @param string $sValue
* @param \ormStyle|null $oStyle

View File

@@ -12,8 +12,8 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
class FieldSetUIBlockFactory extends AbstractUIBlockFactory
{
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\FieldSet\\FieldSet";
public const TWIG_TAG_NAME = 'UIFieldSet';
public const UI_BLOCK_CLASS_NAME = FieldSet::class;
public static function MakeStandard(string $sLegend, ?string $sId = null): FieldSet
{

View File

@@ -12,8 +12,8 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
class FormUIBlockFactory extends AbstractUIBlockFactory
{
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Form\\Form";
public const TWIG_TAG_NAME = 'UIForm';
public const UI_BLOCK_CLASS_NAME = Form::class;
public static function MakeStandard(string $sId = null)
{

View File

@@ -11,12 +11,11 @@ namespace Combodo\iTop\Application\UI\Base\Component\Input;
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Field\Field;
use Combodo\iTop\Application\UI\Base\Component\Input\Select\Select;
use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOption;
class InputUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UIInput';
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\Input";
public const UI_BLOCK_CLASS_NAME = Input::class;
public static function MakeForHidden(string $sName, string $sValue, ?string $sId = null): Input
{
@@ -63,6 +62,17 @@ class InputUIBlockFactory extends AbstractUIBlockFactory
return static::MakeInputWithLabel($sInputName, $sLabel, $oInput, $sInputId);
}
private static function MakeInputWithLabel(string $sName, string $sLabel, Input $oInput, ?string $sId = null)
{
$oInput->SetName($sName);
if (is_null($sId)) {
$sId = $oInput->GetId();
}
return new InputWithLabel($sLabel, $oInput, $sId);
}
/**
* If you need to have a real field with a label, you might use a {@link Field} component instead
*
@@ -75,12 +85,6 @@ class InputUIBlockFactory extends AbstractUIBlockFactory
public static function MakeForSelectWithLabel(string $sName, string $sLabel, ?string $sId = null): InputWithLabel
{
$oInput = new Select($sId);
return static::MakeInputWithLabel($sName, $sLabel, $oInput, $sId);
}
private static function MakeInputWithLabel(string $sName, string $sLabel, Input $oInput, ?string $sId = null)
{
$oInput->SetName($sName);
if (is_null($sId)) {
@@ -90,23 +94,4 @@ class InputUIBlockFactory extends AbstractUIBlockFactory
return new InputWithLabel($sLabel, $oInput, $sId);
}
public static function MakeForSelect(string $sName, ?string $sId = null): Select
{
$oInput = new Select($sId);
$oInput->SetName($sName);
return $oInput;
}
public static function MakeForSelectOption(string $sValue, string $sLabel, bool $bSelected, ?string $sId = null): SelectOption
{
$oInput = new SelectOption($sId);
$oInput->SetValue($sValue)
->SetLabel($sLabel)
->SetSelected($bSelected);
return $oInput;
}
}

View File

@@ -21,15 +21,15 @@ class InputWithLabel extends UIBlock
/** @var string */
protected $sLabel;
/** @var \Combodo\iTop\Application\UI\Base\Component\Input\Input */
/** @var \Combodo\iTop\Application\UI\Base\UIBlock */
protected $oInput;
/**
* @param string $sLabel
* @param \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput $oInput
* @param \Combodo\iTop\Application\UI\Base\UIBlock $oInput
* @param string|null $sId
*/
public function __construct(string $sLabel, AbstractInput $oInput, ?string $sId)
public function __construct(string $sLabel, UIBlock $oInput, ?string $sId)
{
parent::__construct($sId);
$this->sLabel = $sLabel;
@@ -37,7 +37,7 @@ class InputWithLabel extends UIBlock
}
/**
* @return \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput
* @return UIBlock
*/
public function GetInput()
{
@@ -45,11 +45,11 @@ class InputWithLabel extends UIBlock
}
/**
* @param \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput $oInput
* @param \Combodo\iTop\Application\UI\Base\UIBlock $oInput
*
* @return $this
*/
public function SetInput(AbstractInput $oInput)
public function SetInput(UIBlock $oInput)
{
$this->oInput = $oInput;

View File

@@ -8,28 +8,81 @@
namespace Combodo\iTop\Application\UI\Base\Component\Input\Select;
use Combodo\iTop\Application\UI\Base\Component\Input\Input;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
class Select extends Input
class Select extends UIContentBlock
{
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/input/select/select';
/** @var array */
protected $aOptions;
/** @var string */
protected $sName;
/** @var string */
protected $sValue;
/** @var bool */
protected $bSubmitOnChange = false;
public function __construct(?string $sId = null)
{
parent::__construct($sId);
$this->aOptions = [];
}
public function AddOption(SelectOption $oOption)
{
$this->aOptions[$oOption->GetId()] = $oOption;
$this->AddSubBlock($oOption);
}
public function GetSubBlocks()
public function GetName(): string
{
return $this->aOptions;
return $this->sName;
}
/**
* @param string $sName
*
* @return $this
*/
public function SetName(string $sName)
{
$this->sName = $sName;
return $this;
}
public function GetValue(): ?string
{
return $this->sValue;
}
/**
* @param string|null $sValue
*
* @return $this
*/
public function SetValue(?string $sValue)
{
$this->sValue = $sValue;
return $this;
}
/**
* @return bool
*/
public function GetSubmitOnChange(): bool
{
return $this->bSubmitOnChange;
}
/**
* @param bool $bSubmitOnChange
*
* @return $this
*/
public function SetSubmitOnChange(bool $bSubmitOnChange)
{
$this->bSubmitOnChange = $bSubmitOnChange;
return $this;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\Input\Select;
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
class SelectOptionUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UISelectOption';
public const UI_BLOCK_CLASS_NAME = SelectOption::class;
public static function MakeForSelectOption(string $sValue, string $sLabel, bool $bSelected, ?string $sId = null): SelectOption
{
$oInput = new SelectOption($sId);
$oInput->SetValue($sValue)
->SetLabel($sLabel)
->SetSelected($bSelected);
return $oInput;
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\Input;
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Input\Select\Select;
class SelectUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UISelect';
public const UI_BLOCK_CLASS_NAME = Select::class;
/**
* @param string $sName
* @param string|null $sId
*
* @return \Combodo\iTop\Application\UI\Base\Component\Input\Select\Select
*/
public static function MakeForSelect(string $sName, ?string $sId = null): Select
{
$oInput = new Select($sId);
$oInput->SetName($sName);
return $oInput;
}
}

View File

@@ -273,9 +273,10 @@ class Panel extends UIContentBlock
*
* @inheritDoc
*/
public function AddSubBlock(iUIBlock $oSubBlock) {
$this->AddMainBlock($oSubBlock);
public function AddSubBlock(?iUIBlock $oSubBlock) {
if ($oSubBlock) {
$this->AddMainBlock($oSubBlock);
}
return $this;
}

View File

@@ -36,7 +36,7 @@ use ormStyle;
class PanelUIBlockFactory extends AbstractUIBlockFactory
{
public const TWIG_TAG_NAME = 'UIPanel';
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Panel\\Panel";
public const UI_BLOCK_CLASS_NAME = Panel::class;
/**
* Make a basis Panel component

View File

@@ -12,8 +12,8 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
class SpinnerUIBlockFactory extends AbstractUIBlockFactory
{
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Spinner\\Spinner";
public const TWIG_TAG_NAME = 'UISpinner';
public const UI_BLOCK_CLASS_NAME = Spinner::class;
public static function MakeStandard(?string $sId = null)
{

View File

@@ -15,8 +15,8 @@ use MetaModel;
class TitleUIBlockFactory extends AbstractUIBlockFactory
{
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\Title";
public const TWIG_TAG_NAME = 'UITitle';
public const UI_BLOCK_CLASS_NAME = Title::class;
public static function MakeForPage(string $sTitle, ?string $sId = null)
{

View File

@@ -154,9 +154,10 @@ class PageContent extends UIBlock implements iUIContentBlock {
*
* @inheritDoc
*/
public function AddSubBlock(iUIBlock $oSubBlock) {
$this->AddMainBlock($oSubBlock);
public function AddSubBlock(?iUIBlock $oSubBlock) {
if ($oSubBlock) {
$this->AddMainBlock($oSubBlock);
}
return $this;
}

View File

@@ -114,7 +114,7 @@ class AjaxTab extends Tab {
* @inheritDoc
* @throws \Combodo\iTop\Application\UI\Base\UIException
*/
public function AddSubBlock(iUIBlock $oSubBlock) {
public function AddSubBlock(?iUIBlock $oSubBlock) {
throw new UIException($this, Dict::Format('UIBlock:Error:AddBlockForbidden', $this->GetId()));
}

View File

@@ -147,7 +147,7 @@ class TabContainer extends UIContentBlock
* @return iUIContentBlock
* @throws \Combodo\iTop\Application\UI\Base\UIException
*/
public function AddSubBlock(iUIBlock $oSubBlock): iUIContentBlock
public function AddSubBlock(?iUIBlock $oSubBlock): iUIContentBlock
{
if (!($oSubBlock instanceof Tab)) {
throw new UIException($this, Dict::Format('UIBlock:Error:AddBlockNotTabForbidden', $oSubBlock->GetId(), $this->GetId()));

View File

@@ -65,10 +65,11 @@ class UIContentBlock extends UIBlock implements iUIContentBlock
/**
* @inheritDoc
*/
public function AddSubBlock(iUIBlock $oSubBlock)
public function AddSubBlock(?iUIBlock $oSubBlock)
{
$this->aSubBlocks[$oSubBlock->GetId()] = $oSubBlock;
if ($oSubBlock) {
$this->aSubBlocks[$oSubBlock->GetId()] = $oSubBlock;
}
return $this;
}

View File

@@ -12,8 +12,8 @@ use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
class UIContentBlockUIBlockFactory extends AbstractUIBlockFactory
{
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Layout\\UIContentBlock";
public const TWIG_TAG_NAME = 'UIContentBlock';
public const UI_BLOCK_CLASS_NAME = UIContentBlock::class;
public static function MakeStandard(string $sId = null, string $sContainerClass = '')
{

View File

@@ -34,7 +34,7 @@ interface iUIContentBlock {
*
* @return $this
*/
public function AddSubBlock(iUIBlock $oSubBlock);
public function AddSubBlock(?iUIBlock $oSubBlock);
/**
* Remove the sub block identified by $sId.

View File

@@ -2,7 +2,10 @@
{# @license http://opensource.org/licenses/AGPL-3.0 #}
{% extends "base/components/input/layout.html.twig" %}
{% block iboInput %}
<select id="{{ oUIBlock.GetId() }}" name="{{ oUIBlock.GetName() }}">
<select id="{{ oUIBlock.GetId() }}" name="{{ oUIBlock.GetName() }}"
{% if oUIBlock.GetSubmitOnChange() %}onChange="this.form.submit();"{% endif %}
class="{% if oUIBlock.IsHidden() %}ibo-is-hidden{% endif %}"
>
{% for oSubBlock in oUIBlock.GetSubBlocks() %}
{{ render_block(oSubBlock, {aPage: aPage}) }}
{% endfor %}