diff --git a/datamodels/2.x/itop-core-update/src/Controller/UpdateController.php b/datamodels/2.x/itop-core-update/src/Controller/UpdateController.php
index b721de763..21b996ddf 100644
--- a/datamodels/2.x/itop-core-update/src/Controller/UpdateController.php
+++ b/datamodels/2.x/itop-core-update/src/Controller/UpdateController.php
@@ -9,6 +9,8 @@ namespace Combodo\iTop\CoreUpdate\Controller;
use Combodo\iTop\Application\TwigBase\Controller\Controller;
use Combodo\iTop\CoreUpdate\Service\CoreUpdater;
use Combodo\iTop\DBTools\Service\DBToolsUtils;
+use DBObjectSearch;
+use DBObjectSet;
use Dict;
use Exception;
use SetupUtils;
@@ -16,21 +18,24 @@ use utils;
class UpdateController extends Controller
{
- public function OperationSelectUpdateFile()
+ public function OperationSelectUpdateFile()
{
$sTransactionId = utils::GetNewTransactionId();
- $aParams = array();
+ $aParams = [];
$aParams['sTransactionId'] = $sTransactionId;
- $aParams['aPreviousInstall'] = $this->GetPreviousInstallations();
- $aParams['sAjaxURL'] = utils::GetAbsoluteUrlModulePage('itop-core-update', 'ajax.php', array('maintenance' => 'true'));
- $aParams['iDiskFreeSpace'] = disk_free_space(APPROOT);
- $aParams['sDiskFreeSpace'] = utils::BytesToFriendlyFormat($aParams['iDiskFreeSpace']);
+ //$aParams['aPreviousInstall'] = $this->GetPreviousInstallations();
+ $aParams['sAjaxURL'] = utils::GetAbsoluteUrlModulePage('itop-core-update', 'ajax.php', array('maintenance' => 'true'));
+ $aParams['iDiskFreeSpace'] = disk_free_space(APPROOT);
+ $aParams['sDiskFreeSpace'] = utils::BytesToFriendlyFormat($aParams['iDiskFreeSpace']);
$aParams['iFileUploadMaxSize'] = $this->GetFileUploadMaxSize();
$aParams['sFileUploadMaxSize'] = utils::BytesToFriendlyFormat($aParams['iFileUploadMaxSize']);
$aParams['sPostMaxSize'] = ini_get('post_max_size');
$aParams['sUploadMaxSize'] = ini_get('upload_max_filesize');
+ $oFilter = DBObjectSearch::FromOQL('SELECT ModuleInstallation WHERE parent_id=0 AND name!="datamodel"');
+ $oSet = new DBObjectSet($oFilter, ['installed' => false]); // Most recent first
+ $aParams['oSet'] = $oSet;
- $this->DisplayPage($aParams);
+ $this->DisplayPage($aParams);
}
/**
diff --git a/datamodels/2.x/itop-core-update/view/SelectUpdateFile.html.twig b/datamodels/2.x/itop-core-update/view/SelectUpdateFile.html.twig
index a72dcf115..af14290a4 100644
--- a/datamodels/2.x/itop-core-update/view/SelectUpdateFile.html.twig
+++ b/datamodels/2.x/itop-core-update/view/SelectUpdateFile.html.twig
@@ -36,203 +36,54 @@
{% EndUIField %}
{% EndUIFieldSet %}
-{% EndUIContentBlock %}
-{% UIContentBlock {'container_class':'display_block display-files'} %}
{% UIFieldSet {'legend':'iTopUpdate:UI:SelectUpdateFile'|dict_s} %}
- {#
#}
+{% EndUIForm %}
+
{% EndUIFieldSet %}
-{% EndUIContentBlock %}
-
-{% UIContentBlock {'container_class':'display_block display-files'} %}
{% UIFieldSet {'legend':'iTopUpdate:UI:History'|dict_s} %}
- {# #}
- {# {% for aInstall in aPreviousInstall %} #}
- {# {% if loop.first %} #}
- {#
#}
- {# #}
- {# | {{ 'Class:ModuleInstallation/Attribute:name'|dict_s }} | #}
- {# {{ 'Class:ModuleInstallation/Attribute:version'|dict_s }} | #}
- {# {{ 'Class:ModuleInstallation/Attribute:installed'|dict_s }} | #}
- {# {{ 'Class:ModuleInstallation/Attribute:comment'|dict_s }} | #}
- {#
#}
- {# {% endif %} #}
-
- {# {% if (loop.index0 % 2) == 0 %} #}
- {# {% set sRowClass = "odd" %} #}
- {# {% else %} #}
- {# {% set sRowClass = "even" %} #}
- {# {% endif %} #}
-
- {# #}
- {# | {{ aInstall.name }} | #}
- {# {{ aInstall.version }} | #}
- {# {{ aInstall.installed }} | #}
- {# {{ aInstall.comment }} | #}
- {#
#}
-
- {# {% if loop.last %} #}
- {#
#}
- {# {% endif %} #}
- {# {% endfor %} #}
- {#
#}
+{% UIDataTable ForResult {'list_id':'iboupdatehistory', 'object_set':oSet} %}
{% EndUIFieldSet %}
{% EndUIContentBlock %}
{% EndUIContentBlock %}
-
- {# #}
-
- {#
#}
-
- {# #}
- {#
#}
-
- {#
#}
-
- {#
#}
-
- {#
#}
{% endapply %}
\ No newline at end of file
diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php
index 433f83602..1582598c4 100644
--- a/lib/composer/autoload_classmap.php
+++ b/lib/composer/autoload_classmap.php
@@ -155,12 +155,18 @@ return array(
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIAlertParser' => $baseDir . '/sources/application/TwigBase/UI/Component/Alert/UIAlertParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIContentBlockNode' => $baseDir . '/sources/application/TwigBase/UI/Layout/UIContentBlockNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIContentBlockParser' => $baseDir . '/sources/application/TwigBase/UI/Layout/UIContentBlockParser.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIDataTableNode' => $baseDir . '/sources/application/TwigBase/UI/Component/DataTable/UIDataTableNode.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIDataTableParser' => $baseDir . '/sources/application/TwigBase/UI/Component/DataTable/UIDataTableParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFieldNode' => $baseDir . '/sources/application/TwigBase/UI/Component/Field/UIFieldNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFieldParser' => $baseDir . '/sources/application/TwigBase/UI/Component/Field/UIFieldParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFieldSetNode' => $baseDir . '/sources/application/TwigBase/UI/Component/FieldSet/UIFieldSetNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFieldSetParser' => $baseDir . '/sources/application/TwigBase/UI/Component/FieldSet/UIFieldSetParser.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFormNode' => $baseDir . '/sources/application/TwigBase/UI/Component/Form/UIFormNode.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFormParser' => $baseDir . '/sources/application/TwigBase/UI/Component/Form/UIFormParser.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\\Component\\UIInputNode' => $baseDir . '/sources/application/TwigBase/UI/Component/Input/UIInputNode.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIInputParser' => $baseDir . '/sources/application/TwigBase/UI/Component/Input/UIInputParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UITitleNode' => $baseDir . '/sources/application/TwigBase/UI/Component/Title/UITitleNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UITitleParser' => $baseDir . '/sources/application/TwigBase/UI/Component/Title/UITitleParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockExtension' => $baseDir . '/sources/application/TwigBase/UI/UIBlockExtension.php',
diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php
index 9d3f8c2cb..7da371b2e 100644
--- a/lib/composer/autoload_static.php
+++ b/lib/composer/autoload_static.php
@@ -385,12 +385,18 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIAlertParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Alert/UIAlertParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIContentBlockNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Layout/UIContentBlockNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIContentBlockParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Layout/UIContentBlockParser.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIDataTableNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/DataTable/UIDataTableNode.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIDataTableParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/DataTable/UIDataTableParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFieldNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Field/UIFieldNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFieldParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Field/UIFieldParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFieldSetNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/FieldSet/UIFieldSetNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFieldSetParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/FieldSet/UIFieldSetParser.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFormNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Form/UIFormNode.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIFormParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Form/UIFormParser.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\\Component\\UIInputNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Input/UIInputNode.php',
+ 'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UIInputParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Input/UIInputParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UITitleNode' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Title/UITitleNode.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\Component\\UITitleParser' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/Component/Title/UITitleParser.php',
'Combodo\\iTop\\Application\\TwigBase\\UI\\UIBlockExtension' => __DIR__ . '/../..' . '/sources/application/TwigBase/UI/UIBlockExtension.php',
diff --git a/setup/moduleinstallation.class.inc.php b/setup/moduleinstallation.class.inc.php
index 663d7a807..b02ef10d2 100644
--- a/setup/moduleinstallation.class.inc.php
+++ b/setup/moduleinstallation.class.inc.php
@@ -42,16 +42,16 @@ class ModuleInstallation extends cmdbAbstractObject
);
MetaModel::Init_Params($aParams);
//MetaModel::Init_InheritAttributes();
- MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values"=>null, "sql"=>"name", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeString("version", array("allowed_values"=>null, "sql"=>"version", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeDateTime("installed", array("allowed_values"=>null, "sql"=>"installed", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeText("comment", array("allowed_values"=>null, "sql"=>"comment", "default_value"=>null, "is_null_allowed"=>true, "depends_on"=>array())));
- MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("targetclass"=>"ModuleInstallation", "jointype"=> "", "allowed_values"=>null, "sql"=>"parent_id", "is_null_allowed"=>true, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
+ MetaModel::Init_AddAttribute(new AttributeString("name", array("allowed_values" => null, "sql" => "name", "default_value" => null, "is_null_allowed" => false, "depends_on" => array())));
+ MetaModel::Init_AddAttribute(new AttributeString("version", array("allowed_values" => null, "sql" => "version", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
+ MetaModel::Init_AddAttribute(new AttributeDateTime("installed", array("allowed_values" => null, "sql" => "installed", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
+ MetaModel::Init_AddAttribute(new AttributeText("comment", array("allowed_values" => null, "sql" => "comment", "default_value" => null, "is_null_allowed" => true, "depends_on" => array())));
+ MetaModel::Init_AddAttribute(new AttributeExternalKey("parent_id", array("targetclass" => "ModuleInstallation", "jointype" => "", "allowed_values" => null, "sql" => "parent_id", "is_null_allowed" => true, "on_target_delete" => DEL_MANUAL, "depends_on" => array())));
// Display lists
MetaModel::Init_SetZListItems('details', array('name', 'version', 'installed', 'comment', 'parent_id')); // Attributes to be displayed for the complete details
- MetaModel::Init_SetZListItems('list', array('name', 'version', 'installed', 'parent_id')); // Attributes to be displayed for a list
+ MetaModel::Init_SetZListItems('list', array('name', 'version', 'installed', 'comment')); // Attributes to be displayed for a list
// Search criteria
// MetaModel::Init_SetZListItems('standard_search', array('name')); // Criteria of the std search form
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
diff --git a/sources/application/TwigBase/UI/Component/Alert/UIAlertNode.php b/sources/application/TwigBase/UI/Component/Alert/UIAlertNode.php
index 5aec163ca..f433f2dbe 100644
--- a/sources/application/TwigBase/UI/Component/Alert/UIAlertNode.php
+++ b/sources/application/TwigBase/UI/Component/Alert/UIAlertNode.php
@@ -22,7 +22,7 @@ class UIAlertNode extends Node
public function compile(Compiler $compiler)
{
- $sBlockVar = UIBlockHelper::GetBlockVarName('oFieldSet');
+ $sBlockVar = UIBlockHelper::GetBlockVarName('oAlert');
$oParams = $this->getAttribute('params');
$compiler
->addDebugInfo($this)
diff --git a/sources/application/TwigBase/UI/Component/DataTable/UIDataTableNode.php b/sources/application/TwigBase/UI/Component/DataTable/UIDataTableNode.php
new file mode 100644
index 000000000..73bb9fa8c
--- /dev/null
+++ b/sources/application/TwigBase/UI/Component/DataTable/UIDataTableNode.php
@@ -0,0 +1,48 @@
+ $sType, 'params' => $oParams], $lineno, $tag);
+ }
+
+ public function compile(Compiler $compiler)
+ {
+ $sBlockVar = UIBlockHelper::GetBlockVarName('oDataTable');
+ $oParams = $this->getAttribute('params');
+ $sType = $this->getAttribute('type');
+ $compiler
+ ->addDebugInfo($this)
+ ->write("\$aParams = ")
+ ->subcompile($oParams)
+ ->raw(";\n");
+
+ switch ($sType) {
+ case 'ForResult':
+ $compiler
+ ->write("\$sListId = \$aParams['list_id'] ?? '';\n")
+ ->write("\$oSet = \$aParams['object_set'] ?? null;\n")
+ ->write("\${$sBlockVar} = Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTableFactory::Make{$sType}(\$context['UIBlockParent'][0], \$sListId, \$oSet);\n")
+ ->write(UIBlockHelper::AddToParentBlock($sBlockVar));
+ break;
+ // TODO 3.0 add other Factory methods
+
+ default:
+ throw new SyntaxError(sprintf('%s: Bad type "%s" for %s at line %d', $this->getTemplateName(), $sType, $this->tag, $this->lineno), $this->lineno, $this->getSourceContext());
+ }
+ }
+}
diff --git a/sources/application/TwigBase/UI/Component/DataTable/UIDataTableParser.php b/sources/application/TwigBase/UI/Component/DataTable/UIDataTableParser.php
new file mode 100644
index 000000000..0e6d18615
--- /dev/null
+++ b/sources/application/TwigBase/UI/Component/DataTable/UIDataTableParser.php
@@ -0,0 +1,41 @@
+getLine();
+ $oStream = $this->parser->getStream();
+
+ $sType = $oStream->expect(Token::NAME_TYPE)->getValue();
+
+ $oParams = $this->parser->getExpressionParser()->parseExpression();
+
+ $oStream->expect(Token::BLOCK_END_TYPE);
+
+ return new UIDataTableNode($sType, $oParams, $iLineno, $this->getTag());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getTag()
+ {
+ return 'UIDataTable';
+ }
+}
\ No newline at end of file
diff --git a/sources/application/TwigBase/UI/Component/Field/UIFieldNode.php b/sources/application/TwigBase/UI/Component/Field/UIFieldNode.php
index c1dbb2a3b..cef5ecd90 100644
--- a/sources/application/TwigBase/UI/Component/Field/UIFieldNode.php
+++ b/sources/application/TwigBase/UI/Component/Field/UIFieldNode.php
@@ -22,7 +22,7 @@ class UIFieldNode extends Node
public function compile(Compiler $compiler)
{
- $sBlockVar = UIBlockHelper::GetBlockVarName('oFieldSet');
+ $sBlockVar = UIBlockHelper::GetBlockVarName('oField');
$oParams = $this->getAttribute('params');
$compiler
->addDebugInfo($this)
diff --git a/sources/application/TwigBase/UI/Component/Form/UIFormNode.php b/sources/application/TwigBase/UI/Component/Form/UIFormNode.php
new file mode 100644
index 000000000..3045c1e05
--- /dev/null
+++ b/sources/application/TwigBase/UI/Component/Form/UIFormNode.php
@@ -0,0 +1,39 @@
+ $oBody], ['params' => $oParams], $lineno, $tag);
+ }
+
+ public function compile(Compiler $compiler)
+ {
+ $sBlockVar = UIBlockHelper::GetBlockVarName('oForm');
+ $oParams = $this->getAttribute('params');
+
+ $compiler
+ ->addDebugInfo($this)
+ ->write("\$aParams = ")
+ ->subcompile($oParams)
+ ->raw(";\n")
+ ->write("\$sId = \$aParams['id'] ?? null;\n")
+ ->write("\${$sBlockVar} = new Combodo\\iTop\\Application\\UI\\Base\\Component\\Form\\Form(\$sId);\n")
+ ->write(UIBlockHelper::AddToParentBlock($sBlockVar))
+ ->write(UIBlockHelper::PushParentBlock($sBlockVar))
+ ->subcompile($this->getNode('body'))
+ ->write(UIBlockHelper::PopParentBlock());
+ }
+}
diff --git a/sources/application/TwigBase/UI/Component/Form/UIFormParser.php b/sources/application/TwigBase/UI/Component/Form/UIFormParser.php
new file mode 100644
index 000000000..4947d9173
--- /dev/null
+++ b/sources/application/TwigBase/UI/Component/Form/UIFormParser.php
@@ -0,0 +1,47 @@
+getLine();
+ $oStream = $this->parser->getStream();
+
+ $oParams = $this->parser->getExpressionParser()->parseExpression();
+
+ $oStream->expect(Token::BLOCK_END_TYPE);
+
+ $oBody = $this->parser->subparse([$this, 'decideForEnd'], true);
+ $oStream->expect(Token::BLOCK_END_TYPE);
+
+ return new UIFormNode($oParams, $oBody, $iLineno, $this->getTag());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getTag()
+ {
+ return 'UIForm';
+ }
+
+ public function decideForEnd(Token $token)
+ {
+ return $token->test('EndUIForm');
+ }
+}
\ No newline at end of file
diff --git a/sources/application/TwigBase/UI/Component/Input/UIInputNode.php b/sources/application/TwigBase/UI/Component/Input/UIInputNode.php
new file mode 100644
index 000000000..b785f27cf
--- /dev/null
+++ b/sources/application/TwigBase/UI/Component/Input/UIInputNode.php
@@ -0,0 +1,79 @@
+ $sType, 'params' => $oParams], $lineno, $tag);
+ }
+
+ public function compile(Compiler $compiler)
+ {
+ $sBlockVar = UIBlockHelper::GetBlockVarName('oInput');
+ $oParams = $this->getAttribute('params');
+ $compiler
+ ->addDebugInfo($this)
+ ->write("\$aParams = ")
+ ->subcompile($oParams)
+ ->raw(";\n");
+
+ $sFactoryType = $this->getAttribute('type');
+ switch ($sFactoryType) {
+ case 'ForHidden':
+ $compiler
+ ->write("\$sName = \$aParams['name'] ?? '';\n")
+ ->write("\$sValue = \$aParams['value'] ?? '';\n")
+ ->write("\$sId = \$aParams['id'] ?? null;\n")
+ ->write("\${$sBlockVar} = Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputFactory::Make{$sFactoryType}(\$sName, \$sValue, \$sId);\n");
+ break;
+
+ case 'Standard':
+ $compiler
+ ->write("\$sType = \$aParams['type'] ?? '';\n")
+ ->write("\$sName = \$aParams['name'] ?? '';\n")
+ ->write("\$sValue = \$aParams['value'] ?? '';\n")
+ ->write("\$sId = \$aParams['id'] ?? null;\n")
+ ->write("\${$sBlockVar} = Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputFactory::Make{$sFactoryType}(\$sType, \$sName, \$sValue, \$sId);\n")
+ ->write("if (\$aParams['checked'] ?? false) {\n")
+ ->indent()
+ ->write("\${$sBlockVar}->SetChecked(true);\n")
+ ->outdent()
+ ->write("}\n");
+ break;
+
+ case 'WithLabel':
+ $compiler
+ ->write("\$sLabel = \$aParams['label'] ?? '';\n")
+ ->write("\$sType = \$aParams['type'] ?? '';\n")
+ ->write("\$sName = \$aParams['name'] ?? '';\n")
+ ->write("\$sValue = \$aParams['value'] ?? '';\n")
+ ->write("\$sId = \$aParams['id'] ?? null;\n")
+ ->write("\${$sBlockVar} = Combodo\\iTop\\Application\\UI\\Base\\Component\\Input\\InputFactory::Make{$sFactoryType}(\$sType, \$sLabel, \$sName, \$sValue, \$sId);\n")
+ ->write("if (\$aParams['checked'] ?? false) {\n")
+ ->indent()
+ ->write("\${$sBlockVar}->GetInput()->SetChecked(true);\n")
+ ->outdent()
+ ->write("}\n");
+ break;
+ // TODO 3.0 add other Factory methods
+
+ default:
+ throw new SyntaxError(sprintf('%s: Bad type "%s" for %s at line %d', $this->getTemplateName(), $sFactoryType, $this->tag, $this->lineno), $this->lineno, $this->getSourceContext());
+
+ }
+ $compiler->write(UIBlockHelper::AddToParentBlock($sBlockVar));
+ }
+}
diff --git a/sources/application/TwigBase/UI/Component/Input/UIInputParser.php b/sources/application/TwigBase/UI/Component/Input/UIInputParser.php
new file mode 100644
index 000000000..bb3d38987
--- /dev/null
+++ b/sources/application/TwigBase/UI/Component/Input/UIInputParser.php
@@ -0,0 +1,43 @@
+getLine();
+ $oStream = $this->parser->getStream();
+
+ $sType = $oStream->expect(Token::NAME_TYPE)->getValue();
+
+ $oParams = $this->parser->getExpressionParser()->parseExpression();
+
+ $oStream->expect(Token::BLOCK_END_TYPE);
+
+
+ return new UIInputNode($sType, $oParams, $iLineno, $this->getTag());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getTag()
+ {
+ return 'UIInput';
+ }
+
+}
\ No newline at end of file
diff --git a/sources/application/TwigBase/UI/Component/Title/UITitleNode.php b/sources/application/TwigBase/UI/Component/Title/UITitleNode.php
index 1b52afb19..b449d8682 100644
--- a/sources/application/TwigBase/UI/Component/Title/UITitleNode.php
+++ b/sources/application/TwigBase/UI/Component/Title/UITitleNode.php
@@ -22,7 +22,7 @@ class UITitleNode extends Node
public function compile(Compiler $compiler)
{
- $sBlockVar = UIBlockHelper::GetBlockVarName('oFieldSet');
+ $sBlockVar = UIBlockHelper::GetBlockVarName('oTitle');
$oParams = $this->getAttribute('params');
$compiler
->addDebugInfo($this)
diff --git a/sources/application/TwigBase/UI/UIBlockExtension.php b/sources/application/TwigBase/UI/UIBlockExtension.php
index af0923c9b..b79586a28 100644
--- a/sources/application/TwigBase/UI/UIBlockExtension.php
+++ b/sources/application/TwigBase/UI/UIBlockExtension.php
@@ -10,9 +10,12 @@ namespace Combodo\iTop\Application\TwigBase\UI;
use Combodo\iTop\Application\TwigBase\UI\Component\UIAlertParser;
use Combodo\iTop\Application\TwigBase\UI\Component\UIContentBlockParser;
+use Combodo\iTop\Application\TwigBase\UI\Component\UIDataTableParser;
use Combodo\iTop\Application\TwigBase\UI\Component\UIFieldParser;
use Combodo\iTop\Application\TwigBase\UI\Component\UIFieldSetParser;
+use Combodo\iTop\Application\TwigBase\UI\Component\UIFormParser;
use Combodo\iTop\Application\TwigBase\UI\Component\UIHtmlParser;
+use Combodo\iTop\Application\TwigBase\UI\Component\UIInputParser;
use Combodo\iTop\Application\TwigBase\UI\Component\UITitleParser;
use Twig\Extension\AbstractExtension;
@@ -27,6 +30,9 @@ class UIBlockExtension extends AbstractExtension
new UIFieldParser(),
new UIAlertParser(),
new UITitleParser(),
+ new UIDataTableParser(),
+ new UIFormParser(),
+ new UIInputParser(),
];
}
}
\ No newline at end of file
diff --git a/sources/application/UI/Base/Component/Field/Field.php b/sources/application/UI/Base/Component/Field/Field.php
index 029850a4c..e9fc2af0e 100644
--- a/sources/application/UI/Base/Component/Field/Field.php
+++ b/sources/application/UI/Base/Component/Field/Field.php
@@ -7,12 +7,13 @@
namespace Combodo\iTop\Application\UI\Base\Component\Field;
+use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Application\UI\Base\UIBlock;
/**
* @since 3.0.0
*/
-class Field extends UIBlock
+class Field extends UIContentBlock
{
/** @inheritdoc */
public const BLOCK_CODE = 'ibo-field';
@@ -48,21 +49,18 @@ class Field extends UIBlock
protected $sLabel;
/** @var string */
protected $sValueId;
- /**
- * Could be Input, but we have legacy code that needs to set raw HTML !
- *
- * @var UIBlock
- */
- protected $oValue;
+
/** @var string */
protected $sComments;
- public function __construct(string $sLabel, UIBlock $oValue, ?string $sId = null)
+ public function __construct(string $sLabel, UIBlock $oValue = null, ?string $sId = null)
{
parent::__construct($sId);
$this->sLabel = $sLabel;
- $this->oValue = $oValue;
$this->sValueId = null;
+ if (!is_null($oValue)) {
+ $this->AddSubBlock($oValue);
+ }
}
/**
diff --git a/sources/application/UI/Base/Component/Field/FieldFactory.php b/sources/application/UI/Base/Component/Field/FieldFactory.php
index cf5997775..80d6b020b 100644
--- a/sources/application/UI/Base/Component/Field/FieldFactory.php
+++ b/sources/application/UI/Base/Component/Field/FieldFactory.php
@@ -8,7 +8,7 @@ namespace Combodo\iTop\Application\UI\Base\Component\Field;
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
-use Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput;
+use Combodo\iTop\Application\UI\Base\UIBlock;
/**
* @since 3.0.0
@@ -61,7 +61,7 @@ class FieldFactory
$oField->$sMethodName((($iParamsFlags & $iConstant) === $iConstant));
}
- public static function MakeFromObject(string $sLabel, AbstractInput $oInput, ?string $sLayout = null)
+ public static function MakeFromObject(string $sLabel, UIBlock $oInput, ?string $sLayout = null)
{
$oField = new Field($sLabel, $oInput);
diff --git a/sources/application/UI/Base/Component/Input/Input.php b/sources/application/UI/Base/Component/Input/Input.php
index 362868aa6..003ed8bb8 100644
--- a/sources/application/UI/Base/Component/Input/Input.php
+++ b/sources/application/UI/Base/Component/Input/Input.php
@@ -20,6 +20,8 @@ class Input extends AbstractInput
public const INPUT_HIDDEN = 'hidden';
+ protected $bChecked = false;
+
/** @var string */
protected $sType;
@@ -39,4 +41,23 @@ class Input extends AbstractInput
return $this;
}
+
+ /**
+ * @param $bChecked
+ *
+ * @return $this
+ */
+ public function SetChecked($bChecked)
+ {
+ $this->bChecked = $bChecked;
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function IsChecked()
+ {
+ return $this->bChecked;
+ }
}
\ No newline at end of file
diff --git a/sources/application/UI/Base/Component/Input/InputFactory.php b/sources/application/UI/Base/Component/Input/InputFactory.php
index 96f92f1e7..573623aae 100644
--- a/sources/application/UI/Base/Component/Input/InputFactory.php
+++ b/sources/application/UI/Base/Component/Input/InputFactory.php
@@ -26,6 +26,32 @@ class InputFactory
return $oInput;
}
+ public static function MakeStandard(string $sType, string $sName, string $sValue, ?string $sId = null): Input
+ {
+ $oInput = new Input($sId);
+
+ $oInput->SetType($sType)
+ ->SetName($sName)
+ ->SetValue($sValue);
+
+ return $oInput;
+ }
+
+ public static function MakeWithLabel(string $sType, string $sLabel, string $sName, string $sValue, ?string $sId = null): InputWithLabel
+ {
+ $oInput = new Input($sId);
+
+ $oInput->SetType($sType)
+ ->SetName($sName)
+ ->SetValue($sValue);
+
+ if (is_null($sId)) {
+ $sId = $oInput->GetId();
+ }
+
+ return new InputWithLabel($sLabel, $oInput, $sId);
+ }
+
/**
* @see Field component that is better adapter when dealing with a standard iTop form
*
diff --git a/templates/base/components/field/layout.html.twig b/templates/base/components/field/layout.html.twig
index 3a657ce92..0a990f2c3 100644
--- a/templates/base/components/field/layout.html.twig
+++ b/templates/base/components/field/layout.html.twig
@@ -16,7 +16,11 @@
data-value-raw="{{ aParams.value_raw }}"
>
{{ oUIBlock.GetLabel()|raw }}
- {{ render_block(oUIBlock.GetValue()) }}
+
+ {% for oSubBlock in oUIBlock.GetSubBlocks() %}
+ {{ render_block(oSubBlock, {aPage: aPage}) }}
+ {% endfor %}
+
{% if (oUIBlock.GetComments() is not null) %}
{{ oUIBlock.GetComments() }}
{% endif %}
diff --git a/templates/base/components/input/layout.html.twig b/templates/base/components/input/layout.html.twig
index 4d9479ac9..38ebac029 100644
--- a/templates/base/components/input/layout.html.twig
+++ b/templates/base/components/input/layout.html.twig
@@ -1,5 +1,7 @@
{% block iboInputLabel %}
{% endblock %}
{% block iboInput %}
-
+
{% endblock %}
\ No newline at end of file