mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Add UIBlocks to twig (generic parser and node)
# Conflicts: # pages/run_query.php # test/VisualTest/Backoffice/RenderAllUiBlocks.php
This commit is contained in:
@@ -19,8 +19,10 @@
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Alert;
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
|
||||
|
||||
/**
|
||||
* Class AlertFactory
|
||||
* Class AlertUIBlockFactory
|
||||
*
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
* @package Combodo\iTop\Application\UI\Base\Component\Alert
|
||||
@@ -28,8 +30,11 @@ namespace Combodo\iTop\Application\UI\Base\Component\Alert;
|
||||
*
|
||||
* @link <itop_url>/test/VisualTest/Backoffice/RenderAllUiBlocks.php#title-alerts to see live examples
|
||||
*/
|
||||
class AlertFactory
|
||||
class AlertUIBlockFactory extends AbstractUIBlockFactory
|
||||
{
|
||||
public const TWIG_TAG_NAME = 'UIAlert';
|
||||
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Alert\\Alert";
|
||||
|
||||
/**
|
||||
* Make a basis Alert component
|
||||
*
|
||||
@@ -39,7 +44,7 @@ class AlertFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Alert\Alert
|
||||
*/
|
||||
public static function MakeNeutral(string $sTitle, string $sContent, ?string $sId = null)
|
||||
public static function MakeNeutral(string $sTitle = '', string $sContent = '', ?string $sId = null)
|
||||
{
|
||||
return new Alert($sTitle, $sContent, Alert::ENUM_COLOR_NEUTRAL, $sId);
|
||||
}
|
||||
@@ -53,7 +58,7 @@ class AlertFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Alert\Alert
|
||||
*/
|
||||
public static function MakeForInformation(string $sTitle, string $sContent, ?string $sId = null)
|
||||
public static function MakeForInformation(string $sTitle = '', string $sContent = '', ?string $sId = null)
|
||||
{
|
||||
return new Alert($sTitle, $sContent, Alert::ENUM_COLOR_INFORMATION, $sId);
|
||||
|
||||
@@ -68,7 +73,7 @@ class AlertFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Alert\Alert
|
||||
*/
|
||||
public static function MakeForSuccess(string $sTitle, string $sContent, ?string $sId = null)
|
||||
public static function MakeForSuccess(string $sTitle = '', string $sContent = '', ?string $sId = null)
|
||||
{
|
||||
return new Alert($sTitle, $sContent, Alert::ENUM_COLOR_SUCCESS, $sId);
|
||||
}
|
||||
@@ -82,7 +87,7 @@ class AlertFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Alert\Alert
|
||||
*/
|
||||
public static function MakeForWarning(string $sTitle, string $sContent, ?string $sId = null)
|
||||
public static function MakeForWarning(string $sTitle = '', string $sContent = '', ?string $sId = null)
|
||||
{
|
||||
return new Alert($sTitle, $sContent, Alert::ENUM_COLOR_WARNING, $sId);
|
||||
}
|
||||
@@ -96,7 +101,7 @@ class AlertFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Alert\Alert
|
||||
*/
|
||||
public static function MakeForDanger(string $sTitle, string $sContent, ?string $sId = null)
|
||||
public static function MakeForDanger(string $sTitle = '', string $sContent = '', ?string $sId = null)
|
||||
{
|
||||
return new Alert($sTitle, $sContent, Alert::ENUM_COLOR_DANGER, $sId);
|
||||
}
|
||||
@@ -110,7 +115,7 @@ class AlertFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Alert\Alert
|
||||
*/
|
||||
public static function MakeForFailure(string $sTitle, string $sContent, ?string $sId = null)
|
||||
public static function MakeForFailure(string $sTitle = '', string $sContent = '', ?string $sId = null)
|
||||
{
|
||||
return new Alert($sTitle, $sContent, Alert::ENUM_COLOR_FAILURE, $sId);
|
||||
}
|
||||
@@ -124,7 +129,7 @@ class AlertFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Alert\Alert
|
||||
*/
|
||||
public static function MakeWithBrandingPrimaryColor(string $sTitle, string $sContent, ?string $sId = null)
|
||||
public static function MakeWithBrandingPrimaryColor(string $sTitle = '', string $sContent = '', ?string $sId = null)
|
||||
{
|
||||
return new Alert($sTitle, $sContent, Alert::ENUM_COLOR_PRIMARY, $sId);
|
||||
}
|
||||
@@ -138,7 +143,7 @@ class AlertFactory
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Base\Component\Alert\Alert
|
||||
*/
|
||||
public static function MakeWithBrandingSecondaryColor(string $sTitle, string $sContent, ?string $sId = null)
|
||||
public static function MakeWithBrandingSecondaryColor(string $sTitle = '', string $sContent = '', ?string $sId = null)
|
||||
{
|
||||
return new Alert($sTitle, $sContent, Alert::ENUM_COLOR_SECONDARY, $sId);
|
||||
}
|
||||
@@ -19,8 +19,10 @@
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Button;
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
|
||||
|
||||
/**
|
||||
* Class ButtonFactory
|
||||
* Class ButtonUIBlockFactory
|
||||
*
|
||||
* @internal
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
@@ -29,8 +31,11 @@ namespace Combodo\iTop\Application\UI\Base\Component\Button;
|
||||
*
|
||||
* @link <itop_url>/test/VisualTest/Backoffice/RenderAllUiBlocks.php#title-buttons to see live examples
|
||||
*/
|
||||
class ButtonFactory
|
||||
class ButtonUIBlockFactory extends AbstractUIBlockFactory
|
||||
{
|
||||
public const TWIG_TAG_NAME = 'UIButton';
|
||||
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\Button\\Button";
|
||||
|
||||
//---------------------------------------------
|
||||
// Regular action buttons, mostly used in forms
|
||||
//---------------------------------------------
|
||||
@@ -273,8 +278,7 @@ class ButtonFactory
|
||||
public static function MakeLinkNeutral(
|
||||
string $sURL, ?string $sLabel = null, ?string $sIconClasses = null, ?string $sName = null, ?string $sTarget = null,
|
||||
?string $sId = null
|
||||
): Button
|
||||
{
|
||||
): Button {
|
||||
$sType = empty($sIconClasses) ? Button::ENUM_ACTION_TYPE_REGULAR : Button::ENUM_ACTION_TYPE_ALTERNATIVE;
|
||||
$oButton = static::MakeForAction($sLabel, Button::ENUM_COLOR_NEUTRAL, $sType, null, $sName, false, $sId);
|
||||
|
||||
@@ -305,8 +309,7 @@ class ButtonFactory
|
||||
public static function MakeIconLink(
|
||||
string $sIconClasses, string $sTooltipText, ?string $sURL = null, ?string $sName = null, ?string $sTarget = null,
|
||||
?string $sId = null
|
||||
)
|
||||
{
|
||||
) {
|
||||
$oButton = static::MakeForAction('', Button::ENUM_COLOR_NEUTRAL, Button::ENUM_ACTION_TYPE_ALTERNATIVE, null, $sName, false, $sId);
|
||||
$oButton->SetIconClass($sIconClasses);
|
||||
$oButton->SetTooltip($sTooltipText);
|
||||
@@ -10,11 +10,12 @@ use ApplicationException;
|
||||
use appUserPreferences;
|
||||
use AttributeLinkedSet;
|
||||
use cmdbAbstractObject;
|
||||
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\FormTable\FormTable;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\FormTableRow\FormTableRow;
|
||||
use Combodo\iTop\Application\UI\Base\Component\DataTable\StaticTable\StaticTable;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Panel\PanelFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Title\TitleFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Title\TitleUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Toolbar\Toolbar;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
|
||||
use DBObjectSet;
|
||||
@@ -26,15 +27,17 @@ use utils;
|
||||
use WebPage;
|
||||
|
||||
/**
|
||||
* Class DataTableFactory
|
||||
* Class DataTableUIBlockFactory
|
||||
*
|
||||
* @internal
|
||||
* @package Combodo\iTop\Application\UI\Base\Component\DataTable
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class DataTableFactory
|
||||
class DataTableUIBlockFactory extends AbstractUIBlockFactory
|
||||
{
|
||||
|
||||
public const TWIG_TAG_NAME = 'UIDataTable';
|
||||
public const UI_BLOCK_CLASS_NAME = "Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTable";
|
||||
|
||||
/**
|
||||
* @param \WebPage $oPage
|
||||
* @param string $sListId
|
||||
@@ -55,7 +58,7 @@ class DataTableFactory
|
||||
*/
|
||||
public static function MakeForResult(WebPage $oPage, string $sListId, DBObjectSet $oSet, $aExtraParams = array())
|
||||
{
|
||||
$oDataTable = DataTableFactory::MakeForRendering($sListId, $oSet, $aExtraParams);
|
||||
$oDataTable = DataTableUIBlockFactory::MakeForRendering($sListId, $oSet, $aExtraParams);
|
||||
return self::RenderDataTable($oDataTable, 'list', $oPage, $sListId, $oSet, $aExtraParams);
|
||||
}
|
||||
|
||||
@@ -78,7 +81,7 @@ class DataTableFactory
|
||||
*/
|
||||
public static function MakeForObject(WebPage $oPage, string $sListId, DBObjectSet $oSet, $aExtraParams = array())
|
||||
{
|
||||
$oDataTable = DataTableFactory::MakeForRenderingObject($sListId, $oSet, $aExtraParams);
|
||||
$oDataTable = DataTableUIBlockFactory::MakeForRenderingObject($sListId, $oSet, $aExtraParams);
|
||||
return self::RenderDataTable($oDataTable, 'listInObject', $oPage, $sListId, $oSet, $aExtraParams);
|
||||
}
|
||||
|
||||
@@ -750,7 +753,7 @@ class DataTableFactory
|
||||
public static function MakeForStaticData(string $sTitle, array $aColumns, array $aData, ?string $sId = null)
|
||||
{
|
||||
$oBlock = new UIContentBlock();
|
||||
$oTitle = TitleFactory::MakeNeutral($sTitle, 3);
|
||||
$oTitle = TitleUIBlockFactory::MakeNeutral($sTitle, 3);
|
||||
$oBlock->AddSubBlock($oTitle);
|
||||
$oTable = new StaticTable($sId);
|
||||
$oTable->SetColumns($aColumns);
|
||||
@@ -7,14 +7,18 @@
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Field;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
|
||||
use Combodo\iTop\Application\UI\Base\UIBlock;
|
||||
|
||||
/**
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class FieldFactory
|
||||
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 static function MakeFromParams($aParams)
|
||||
{
|
||||
$oValue = new Html($aParams['value']);
|
||||
@@ -86,5 +90,11 @@ class FieldFactory
|
||||
return $oField;
|
||||
}
|
||||
|
||||
public static function MakeStandard(string $sLabel = '', string $sLayout = Field::ENUM_FIELD_LAYOUT_SMALL, ?string $sId = null)
|
||||
{
|
||||
$oField = new Field($sLabel, null, $sId);
|
||||
$oField->SetLayout($sLayout);
|
||||
return $oField;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ class FieldBadge extends UIContentBlock
|
||||
// Overloaded constants
|
||||
public const BLOCK_CODE = 'ibo-field-badge';
|
||||
|
||||
public function __construct(string $sName = null, string $sContainerClass = '')
|
||||
public function __construct(string $sId = null, string $sContainerClass = '')
|
||||
{
|
||||
parent::__construct($sName, $sContainerClass);
|
||||
parent::__construct($sId, $sContainerClass);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\FieldSet;
|
||||
|
||||
|
||||
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 static function MakeStandard(string $sLegend, ?string $sId = null): FieldSet
|
||||
{
|
||||
return new FieldSet($sLegend, $sId);
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,9 @@ class Form extends UIContentBlock
|
||||
/** @var string */
|
||||
protected $sAction;
|
||||
|
||||
public function __construct(string $sName = null)
|
||||
public function __construct(string $sId = null)
|
||||
{
|
||||
parent::__construct($sName);
|
||||
parent::__construct($sId);
|
||||
$this->sOnSubmitJsCode = null;
|
||||
$this->sAction = null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Form;
|
||||
|
||||
|
||||
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 static function MakeStandard(string $sId = null)
|
||||
{
|
||||
return new Form($sId);
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,15 @@
|
||||
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 InputFactory
|
||||
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 static function MakeForHidden(string $sName, string $sValue, ?string $sId = null): Input
|
||||
{
|
||||
@@ -8,12 +8,15 @@
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Title;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\AbstractUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Helper\UIHelper;
|
||||
use DBObject;
|
||||
use MetaModel;
|
||||
|
||||
class TitleFactory
|
||||
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 static function MakeForPage(string $sTitle, ?string $sId = null)
|
||||
{
|
||||
Reference in New Issue
Block a user