diff --git a/sources/application/UI/Base/Component/Alert/Alert.php b/sources/application/UI/Base/Component/Alert/Alert.php index 7cb6938bd9..568afc7356 100644 --- a/sources/application/UI/Base/Component/Alert/Alert.php +++ b/sources/application/UI/Base/Component/Alert/Alert.php @@ -84,8 +84,6 @@ class Alert extends UIContentBlock public const DEFAULT_IS_COLLAPSIBLE = true; /** @var bool Default value for static::$bIsOpenedByDefault */ public const DEFAULT_IS_OPENED_BY_DEFAULT = true; - /** @var bool Default value for static::$bIsHidden */ - public const DEFAULT_IS_HIDDEN = false; /** @var string $sTitle */ protected $sTitle; @@ -95,8 +93,6 @@ class Alert extends UIContentBlock protected $bIsClosable; /** @var bool Whether the alert can be collapsed or not */ protected $bIsCollapsible; - /** @var bool Whether the alert is hidden or not */ - protected $bIsHidden; /** @var bool Whether the alert is opened by default or not, only works when $bIsCollapsible set to true */ protected $bIsOpenedByDefault; /** @var boolean if true will store collapsible state */ @@ -120,7 +116,6 @@ class Alert extends UIContentBlock $this->bIsClosable = static::DEFAULT_IS_CLOSABLE; $this->bIsCollapsible = static::DEFAULT_IS_COLLAPSIBLE; $this->bIsOpenedByDefault = static::DEFAULT_IS_OPENED_BY_DEFAULT; - $this->bIsHidden = static::DEFAULT_IS_HIDDEN; if (!empty($sContent)) { $this->AddSubBlock(new Html($sContent)); } @@ -280,25 +275,4 @@ class Alert extends UIContentBlock { return $this->sSectionStateStorageKey; } - - /** - * @return bool - */ - public function IsHidden(): bool - { - return $this->bIsHidden; - } - - /** - * @param bool $bIsHidden - * - * @return $this - */ - public function SetIsHidden(bool $bIsHidden) - { - $this->bIsHidden = $bIsHidden; - return $this; - } - - } \ 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 e9fc2af0eb..9504a7ab13 100644 --- a/sources/application/UI/Base/Component/Field/Field.php +++ b/sources/application/UI/Base/Component/Field/Field.php @@ -32,8 +32,6 @@ class Field extends UIContentBlock /** @var string */ protected $sAttLabel; /** @var bool */ - protected $bIsHidden = false; - /** @var bool */ protected $bIsReadOnly = false; /** @var bool */ protected $bIsMandatory = false; @@ -143,26 +141,6 @@ class Field extends UIContentBlock return $this; } - /** - * @return bool - */ - public function IsHidden(): bool - { - return $this->bIsHidden; - } - - /** - * @param bool $bIsHidden - * - * @return Field - */ - public function SetIsHidden(bool $bIsHidden) - { - $this->bIsHidden = $bIsHidden; - - return $this; - } - /** * @return bool */ diff --git a/sources/application/UI/Base/Component/Spinner/Spinner.php b/sources/application/UI/Base/Component/Spinner/Spinner.php index d18da033ff..07f3199ef6 100644 --- a/sources/application/UI/Base/Component/Spinner/Spinner.php +++ b/sources/application/UI/Base/Component/Spinner/Spinner.php @@ -20,32 +20,8 @@ class Spinner extends UIBlock public const BLOCK_CODE = 'ibo-spinner'; public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/spinner/layout'; - protected $bIsHidden; - public function __construct(?string $sId = null) { parent::__construct($sId); - $this->bIsHidden = false; } - - /** - * @return false - */ - public function IsHidden(): bool - { - return $this->bIsHidden; - } - - /** - * @param false $bIsHidden - * - * @return $this - */ - public function SetIsHidden(bool $bIsHidden) - { - $this->bIsHidden = $bIsHidden; - return $this; - } - - } \ No newline at end of file diff --git a/sources/application/UI/Base/UIBlock.php b/sources/application/UI/Base/UIBlock.php index e0a83b4ef1..fdc8454605 100644 --- a/sources/application/UI/Base/UIBlock.php +++ b/sources/application/UI/Base/UIBlock.php @@ -45,7 +45,7 @@ abstract class UIBlock implements iUIBlock public const DEFAULT_HTML_TEMPLATE_REL_PATH = null; /** @var array JS_FILES_REL_PATH Relative paths (from /) to the JS files */ public const DEFAULT_JS_FILES_REL_PATH = []; - /** @var string|null JS_TEMPLATE_REL_PATH Relative path (from /templates/) to the JS template on dom ready*/ + /** @var string|null JS_TEMPLATE_REL_PATH Relative path (from /templates/) to the JS template on dom ready */ public const DEFAULT_JS_TEMPLATE_REL_PATH = null; /** @var string|null Relative path (from /templates/) to the JS template not deferred */ public const DEFAULT_JS_LIVE_TEMPLATE_REL_PATH = null; @@ -55,6 +55,8 @@ abstract class UIBlock implements iUIBlock public const DEFAULT_CSS_FILES_REL_PATH = []; /** @var string|null CSS_TEMPLATE_REL_PATH Relative path (from /templates/) to the CSS template */ public const DEFAULT_CSS_TEMPLATE_REL_PATH = null; + /** @var bool Default value for $bIsHidden */ + public const DEFAULT_IS_HIDDEN = false; /** @var string ENUM_BLOCK_FILES_TYPE_JS */ public const ENUM_BLOCK_FILES_TYPE_JS = 'js'; @@ -80,8 +82,10 @@ abstract class UIBlock implements iUIBlock protected $aJsFilesRelPath; /** @var array */ protected $aCssFilesRelPath; - /** @var array Array => which will be output as HTML data-xxx attributes (eg. data-="") */ + /** @var array Array => which will be output as HTML data-xxx attributes (eg. data-="") */ protected $aDataAttributes; + /** @var bool show or hide the current block */ + protected $bIsHidden; /** * UIBlock constructor. @@ -100,6 +104,7 @@ abstract class UIBlock implements iUIBlock $this->sCssTemplateRelPath = static::DEFAULT_CSS_TEMPLATE_REL_PATH; $this->sGlobalTemplateRelPath = static::DEFAULT_GLOBAL_TEMPLATE_REL_PATH; $this->aDataAttributes = []; + $this->bIsHidden = static::DEFAULT_IS_HIDDEN; } /** @@ -353,4 +358,23 @@ abstract class UIBlock implements iUIBlock $this->aDataAttributes[$sName] = $sValue; return $this; } + + /** + * @return bool + */ + public function IsHidden(): bool + { + return $this->bIsHidden; + } + + /** + * @param bool $bIsHidden + * + * @return $this + */ + public function SetIsHidden(bool $bIsHidden) + { + $this->bIsHidden = $bIsHidden; + return $this; + } } diff --git a/templates/base/components/button/layout.html.twig b/templates/base/components/button/layout.html.twig index 23cebe466d..d5fe14cd89 100644 --- a/templates/base/components/button/layout.html.twig +++ b/templates/base/components/button/layout.html.twig @@ -10,6 +10,7 @@ value="{{ oUIBlock.GetValue() }}" {% if oUIBlock.IsDisabled() is same as(true) %} disabled {% endif %} {% if oUIBlock.GetTooltip() is not empty %} data-tooltip-content="{{ oUIBlock.GetTooltip() }}" {% endif %} + {% if oUIBlock.IsHidden() %}style="display: none;"{% endif %} > {% if oUIBlock.GetIconClass() is not empty %} diff --git a/templates/base/components/collapsible-section/layout.html.twig b/templates/base/components/collapsible-section/layout.html.twig index 0dc2a36281..637c3969d9 100644 --- a/templates/base/components/collapsible-section/layout.html.twig +++ b/templates/base/components/collapsible-section/layout.html.twig @@ -1,10 +1,11 @@
+ class="ibo-collapsible-section {{ oUIBlock.GetCSSClasses() }}{% if oUIBlock.IsOpenedByDefault() %} ibo-is-opened{% endif %}" + {% if oUIBlock.IsHidden() %}style="display: none;"{% endif %}>
+ class="fas fa-caret-down">
+ class="fas fa-caret-up">
{{ oUIBlock.GetTitle() }}
diff --git a/templates/base/components/dashlet/dashletbadge.html.twig b/templates/base/components/dashlet/dashletbadge.html.twig index 3cfa9901de..a08344efc5 100644 --- a/templates/base/components/dashlet/dashletbadge.html.twig +++ b/templates/base/components/dashlet/dashletbadge.html.twig @@ -1,7 +1,7 @@ {# @copyright Copyright (C) 2010-2020 Combodo SARL #} {# @license http://opensource.org/licenses/AGPL-3.0 #} {% apply spaceless %} -
+
diff --git a/templates/base/components/dashlet/dashletheaderstatic.html.twig b/templates/base/components/dashlet/dashletheaderstatic.html.twig index 0e08a83feb..252446642f 100644 --- a/templates/base/components/dashlet/dashletheaderstatic.html.twig +++ b/templates/base/components/dashlet/dashletheaderstatic.html.twig @@ -1,7 +1,7 @@ {# @copyright Copyright (C) 2010-2020 Combodo SARL #} {# @license http://opensource.org/licenses/AGPL-3.0 #} {% apply spaceless %} -
+
{% if oUIBlock.GetIconUrl() is not empty %}
diff --git a/templates/base/components/datatable/layout.html.twig b/templates/base/components/datatable/layout.html.twig index f3f34a0f37..ba758cb22d 100644 --- a/templates/base/components/datatable/layout.html.twig +++ b/templates/base/components/datatable/layout.html.twig @@ -12,7 +12,7 @@ {% endif %} {% endif %} - +
{% if oUIBlock.GetOption("select_mode") is not empty %} diff --git a/templates/base/components/datatable/static/formtable/layout.html.twig b/templates/base/components/datatable/static/formtable/layout.html.twig index 16e443328d..f9778acf71 100644 --- a/templates/base/components/datatable/static/formtable/layout.html.twig +++ b/templates/base/components/datatable/static/formtable/layout.html.twig @@ -4,7 +4,7 @@ {% set columns = oUIBlock.GetColumns() %} -
+
{% for column in columns %} diff --git a/templates/base/components/datatable/static/layout.html.twig b/templates/base/components/datatable/static/layout.html.twig index 3527d1ad40..83c53d96a2 100644 --- a/templates/base/components/datatable/static/layout.html.twig +++ b/templates/base/components/datatable/static/layout.html.twig @@ -2,7 +2,7 @@ {# @license http://opensource.org/licenses/AGPL-3.0 #} {% set columns = oUIBlock.GetColumns() %} -
+
{% for column in columns %} diff --git a/templates/base/components/field/layout.html.twig b/templates/base/components/field/layout.html.twig index 0a990f2c3c..c3fd4b428c 100644 --- a/templates/base/components/field/layout.html.twig +++ b/templates/base/components/field/layout.html.twig @@ -4,8 +4,8 @@ data-attribute-code="{{ oUIBlock.GetAttCode() }}" data-attribute-type="{{ oUIBlock.GetAttType() }}" data-attribute-label="{{ oUIBlock.GetAttLabel() }}" - {# Note: This might not the best way to this, we might rather have some properties for this flags in te Field class. #} - {# For the moment this just aims at restoring the metadata introduced in iTop 2.7. Refactoring the Field class with specialization for each type must be designed by all the team #} + {# Note: This might not the best way to this, we might rather have some properties for this flags in te Field class. #} + {# For the moment this just aims at restoring the metadata introduced in iTop 2.7. Refactoring the Field class with specialization for each type must be designed by all the team #} {# as we might want to re-use / adapt the Field classes introduced with the end-user portal #} data-attribute-flag-hidden="{{ oUIBlock.IsHidden()|var_export }}" data-attribute-flag-read-only="{{ oUIBlock.IsReadOnly()|var_export }}" @@ -14,6 +14,7 @@ data-attribute-flag-must-prompt="{{ oUIBlock.IsMustPrompt()|var_export }}" data-attribute-flag-slave="{{ oUIBlock.IsSlave()|var_export }}" data-value-raw="{{ aParams.value_raw }}" + {% if oUIBlock.IsHidden() %}style="display: none;"{% endif %} >
{{ oUIBlock.GetLabel()|raw }}
diff --git a/templates/base/components/fieldset/layout.html.twig b/templates/base/components/fieldset/layout.html.twig index 30b7b388b9..3ae01b8fb8 100644 --- a/templates/base/components/fieldset/layout.html.twig +++ b/templates/base/components/fieldset/layout.html.twig @@ -1,8 +1,8 @@ {% if oUIBlock.GetSubBlocks() %} -
- {{ oUIBlock.GetLegend() }} - {% for oSubBlock in oUIBlock.GetSubBlocks() %} - {{ render_block(oSubBlock, {aPage: aPage}) }} - {% endfor %} -
+
+ {{ oUIBlock.GetLegend() }} + {% for oSubBlock in oUIBlock.GetSubBlocks() %} + {{ render_block(oSubBlock, {aPage: aPage}) }} + {% endfor %} +
{% endif %} \ No newline at end of file diff --git a/templates/base/components/form/layout.html.twig b/templates/base/components/form/layout.html.twig index f680954a71..868770c545 100644 --- a/templates/base/components/form/layout.html.twig +++ b/templates/base/components/form/layout.html.twig @@ -5,6 +5,7 @@ {% if oUIBlock.GetAction() %} action="{{ oUIBlock.GetAction() }}" {% endif %} + {% if oUIBlock.IsHidden() %}style="display: none;"{% endif %} > {% apply spaceless %} {% block iboContentBlockContainer %} diff --git a/templates/base/components/input/layout.html.twig b/templates/base/components/input/layout.html.twig index 38ebac029e..da74f9acae 100644 --- a/templates/base/components/input/layout.html.twig +++ b/templates/base/components/input/layout.html.twig @@ -3,5 +3,6 @@ {% block iboInput %} {% endblock %} \ No newline at end of file diff --git a/templates/base/components/panel/layout.html.twig b/templates/base/components/panel/layout.html.twig index 5a05987ff2..b57160f5b9 100644 --- a/templates/base/components/panel/layout.html.twig +++ b/templates/base/components/panel/layout.html.twig @@ -1,7 +1,8 @@ {# @copyright Copyright (C) 2010-2020 Combodo SARL #} {# @license http://opensource.org/licenses/AGPL-3.0 #} {% apply spaceless %} -
+
{% block iboPanelHeader %}
diff --git a/templates/base/components/title/layout.html.twig b/templates/base/components/title/layout.html.twig index 743c46bf28..1fbd7023ef 100644 --- a/templates/base/components/title/layout.html.twig +++ b/templates/base/components/title/layout.html.twig @@ -1,5 +1,5 @@ {% apply spaceless %} -
+
{% if oUIBlock.HasIcon() %}
diff --git a/templates/base/layouts/content-block/layout.html.twig b/templates/base/layouts/content-block/layout.html.twig index feb302276f..c8045fd929 100644 --- a/templates/base/layouts/content-block/layout.html.twig +++ b/templates/base/layouts/content-block/layout.html.twig @@ -2,9 +2,11 @@ {# @license http://opensource.org/licenses/AGPL-3.0 #} {# Content Block #} {% apply spaceless %} - {% block iboContentBlockContainer %} - {% if oUIBlock.GetCSSClasses() or oUIBlock.GetDataAttributes() %} + {% set bHasDiv = (oUIBlock.GetCSSClasses() or oUIBlock.GetDataAttributes()) %} + + {% block iboContentBlockContainer %} + {% if bHasDiv %}
{% endif %} @@ -19,7 +22,7 @@ {{ render_block(oSubBlock, {aPage: aPage}) }} {% endfor %} - {% if oUIBlock.GetCSSClasses() %} + {% if bHasDiv %}
{% endif %}