Add UIBlocks to twig (Spinner)

This commit is contained in:
Eric
2021-01-15 09:51:01 +01:00
parent 21740123f4
commit 63eb0f1530
9 changed files with 141 additions and 30 deletions

View File

@@ -14,9 +14,12 @@
{% UIFieldSet Standard {'sLegend':'iTopUpdate:UI:Status'|dict_s} %}
{% UIAlert ForInformation {'sId':'header-requirements', 'IsCollapsible':false, 'IsClosable':false} %}
{% UIContentBlock Standard {'sContainerClass':'ibo-update-core-header-requirements', 'sId':'can-core-update'} %}
{% UIHtml %}
<span id="can-core-update">{{ 'iTopUpdate:UI:CanCoreUpdate:Loading'|dict_s }} <i class="ajax-spin fas fa-spinner fa-spin" aria-hidden="true"></i></span>
{{ 'iTopUpdate:UI:CanCoreUpdate:Loading'|dict_s }}
{% EndUIHtml %}
{% UISpinner Standard {} %}
{% EndUIContentBlock %}
{% EndUIAlert %}
{% UIField Standard {'sLabel':'iTopUpdate:UI:CurrentVersion'|dict_s} %}
@@ -32,15 +35,11 @@
{% EndUIField %}
{% UIField Standard {'sLabel':'iTopUpdate:UI:ItopDiskSpace'|dict_s, 'ValueId':'itop-disk-space'} %}
{% UIHtml %}
<i class="ajax-spin fas fa-spinner fa-spin" aria-hidden="true"></i>
{% EndUIHtml %}
{% UISpinner Standard {} %}
{% EndUIField %}
{% UIField Standard {'sLabel':'iTopUpdate:UI:DBDiskSpace'|dict_s, 'ValueId':'db-disk-space'} %}
{% UIHtml %}
<i class="ajax-spin fas fa-spinner fa-spin" aria-hidden="true"></i>
{% EndUIHtml %}
{% UISpinner Standard {} %}
{% EndUIField %}
{% UIField Standard {'sLabel':'iTopUpdate:UI:FileUploadMaxSize'|dict_s} %}
@@ -56,41 +55,45 @@
{% UIInput ForHidden {'sName':'operation', 'sValue':'ConfirmUpdate'} %}
{% UIInput ForHidden {'sName':'transaction_id', 'sValue':sTransactionId} %}
{% UIAlert ForFailure {'sId':'header-file-size', 'IsHidden':true} %}
{% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %}
{% UIHtml %}
<div id="header-file-size" class="header_message message_error" style="display: none">
<div>
<span>{{ 'iTopUpdate:Error:FileUploadMaxSizeTooStandard'|dict_s }}</span>
</div>
<div>
<span>{{ 'iTopUpdate:UI:PostMaxSize'|dict_format(sPostMaxSize) }}</span>
</div>
<div>
<span>{{ 'iTopUpdate:UI:UploadMaxFileSize'|dict_format(sUploadMaxSize) }}</span>
</div>
</div>
{{ 'iTopUpdate:Error:FileUploadMaxSizeTooStandard'|dict_s }}
{% EndUIHtml %}
{% EndUIContentBlock %}
{% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %}
{% UIHtml %}
{{ 'iTopUpdate:UI:PostMaxSize'|dict_format(sPostMaxSize) }}
{% EndUIHtml %}
{% EndUIContentBlock %}
{% UIContentBlock Standard {'sContainerClass':'ibo-file-size-error'} %}
{% UIHtml %}
{{ 'iTopUpdate:UI:UploadMaxFileSize'|dict_format(sUploadMaxSize) }}
{% EndUIHtml %}
{% EndUIContentBlock %}
{% EndUIAlert %}
{% UIContentBlock Standard {'sContainerClass':'upload_container'} %}
{% UIInput Standard {'sType':'file', 'sId':'file', 'sName':'file', 'sValue':''} %}
{% EndUIContentBlock %}
{% UIAlert ForWarning {'sId':'dobackup-warning', 'IsHidden':true} %}
{% UIHtml %}
<div id="dobackup-warning" class="header_message message_info" style="display: none">{{ 'iTopUpdate:UI:DoBackup:Warning'|dict_s }}</div>
{{ 'iTopUpdate:UI:DoBackup:Warning'|dict_s }}
{% EndUIHtml %}
{% EndUIAlert %}
{% UIField Standard {'sLabel':'iTopUpdate:UI:DoBackup:Label'|dict_s, 'sLayout':'large'} %}
{% UIInput Standard {'sType':'checkbox', 'sId':'doBackup', 'sName':'doBackup', 'sValue':'1', 'Checked':true} %}
{% UIInput Standard {'sType':'checkbox', 'sId':'doBackup', 'sName':'doBackup', 'sValue':'1', 'IsChecked':true} %}
{% EndUIField %}
{% UIField Standard {'sLabel':'iTopUpdate:UI:DoFilesArchive'|dict_s, 'sLayout':'large'} %}
{% UIInput Standard {'sType':'checkbox', 'sId':'doFilesArchive', 'sName':'doFilesArchive', 'sValue':'1', 'Checked':true} %}
{% UIInput Standard {'sType':'checkbox', 'sId':'doFilesArchive', 'sName':'doFilesArchive', 'sValue':'1', 'IsChecked':true} %}
{% EndUIField %}
{% UIContentBlock Standard {'sContainerClass':'ibo_check_update_submit'} %}
{% UIButton ForPrimaryAction {'sLabel':'iTopUpdate:UI:CheckUpdate'|dict_s, 'sId':'check-update', 'bIsSubmit':true, 'IsDisabled':true} %}
{% UIHtml %}
<i id="submit-wait" style="display: none" class="fas fa-spinner fa-spin" aria-hidden="true"></i>
{% EndUIHtml %}
{% UISpinner Standard {'sId':'submit-wait', 'IsHidden':true} %}
{% EndUIContentBlock %}
{% EndUIForm %}
@@ -104,6 +107,5 @@
{% EndUIFieldSet %}
{% EndUIContentBlock %}
{% EndUIContentBlock %}
{% endapply %}

View File

@@ -211,6 +211,8 @@ return array(
'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreate' => $baseDir . '/sources/application/UI/Base/Component/QuickCreate/QuickCreate.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreateFactory' => $baseDir . '/sources/application/UI/Base/Component/QuickCreate/QuickCreateFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreateHelper' => $baseDir . '/sources/application/UI/Base/Component/QuickCreate/QuickCreateHelper.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Spinner\\Spinner' => $baseDir . '/sources/application/UI/Base/Component/Spinner/Spinner.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Spinner\\SpinnerUIBlockFactory' => $baseDir . '/sources/application/UI/Base/Component/Spinner/SpinnerUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\Title' => $baseDir . '/sources/application/UI/Base/Component/Title/Title.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\TitleForObjectDetails' => $baseDir . '/sources/application/UI/Base/Component/Title/TitleForObjectDetails.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\TitleUIBlockFactory' => $baseDir . '/sources/application/UI/Base/Component/Title/TitleUIBlockFactory.php',

View File

@@ -441,6 +441,8 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreate' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/QuickCreate/QuickCreate.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreateFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/QuickCreate/QuickCreateFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\QuickCreate\\QuickCreateHelper' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/QuickCreate/QuickCreateHelper.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Spinner\\Spinner' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Spinner/Spinner.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Spinner\\SpinnerUIBlockFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Spinner/SpinnerUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\Title' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Title/Title.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\TitleForObjectDetails' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Title/TitleForObjectDetails.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Title\\TitleUIBlockFactory' => __DIR__ . '/../..' . '/sources/application/UI/Base/Component/Title/TitleUIBlockFactory.php',

View File

@@ -84,6 +84,8 @@ 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;
@@ -93,6 +95,8 @@ 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 */
@@ -116,6 +120,7 @@ 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));
}
@@ -275,4 +280,25 @@ 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;
}
}

View File

@@ -20,7 +20,7 @@ class Input extends AbstractInput
public const INPUT_HIDDEN = 'hidden';
protected $bChecked = false;
protected $bIsChecked = false;
/** @var string */
protected $sType;
@@ -47,9 +47,9 @@ class Input extends AbstractInput
*
* @return $this
*/
public function SetChecked($bChecked)
public function SetIsChecked($bIsChecked)
{
$this->bChecked = $bChecked;
$this->bIsChecked = $bIsChecked;
return $this;
}
@@ -58,6 +58,6 @@ class Input extends AbstractInput
*/
public function IsChecked()
{
return $this->bChecked;
return $this->bIsChecked;
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (C) 2010-2021 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\Spinner;
use Combodo\iTop\Application\UI\Base\UIBlock;
/**
* Class Spinner
*
* @package Combodo\iTop\Application\UI\Base\Component\Spinner
*/
class Spinner extends UIBlock
{
// Overloaded constants
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;
}
}

View File

@@ -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\Spinner;
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 static function MakeStandard(?string $sId = null)
{
return new Spinner($sId);
}
}

View File

@@ -1,5 +1,6 @@
<div id="{{ oUIBlock.GetId() }}"
class="ibo-alert ibo-is-{{ oUIBlock.GetColor() }}{% if oUIBlock.IsOpenedByDefault() %} ibo-is-opened{% endif %}">
class="ibo-alert ibo-is-{{ oUIBlock.GetColor() }}{% if oUIBlock.IsOpenedByDefault() %} ibo-is-opened{% endif %}"
{% if oUIBlock.IsHidden() %}style="display: none;"{% endif %}>
{% if oUIBlock.IsCollapsible() %}
<div class="ibo-alert--action-button ibo-alert--maximize-button" data-role="ibo-alert--collapse-toggler">
<i class="fas fa-caret-down"></i>

View File

@@ -0,0 +1,5 @@
{# @copyright Copyright (C) 2010-2021 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
{% apply spaceless %}
<i id="{{ oUIBlock.GetId() }}" {% if oUIBlock.IsHidden() %}style="display: none;"{% endif %} class="fas fa-spinner fa-spin" aria-hidden="true"></i>
{% endapply %}