mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 16:48:42 +02:00
N°2847 - Field: Restore HTML metadata lost during migration, add missing ID in template
This commit is contained in:
@@ -13,14 +13,19 @@ use Combodo\iTop\Application\UI\UIBlock;
|
||||
* Class Field
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Component\Field
|
||||
* @author Eric Espie <eric.espie@combodo.com>
|
||||
* @author Anne-Catherine Cognet <annecatherine.cognet@combodo.com>
|
||||
* @since 3.0.0
|
||||
*/
|
||||
class Field extends UIBlock
|
||||
{
|
||||
// Overloaded constants
|
||||
/** @inheritdoc */
|
||||
public const BLOCK_CODE = 'ibo-field';
|
||||
/** @inheritdoc */
|
||||
public const HTML_TEMPLATE_REL_PATH = 'components/field/layout';
|
||||
|
||||
/** @var array */
|
||||
/** @var array Array of various parameters of the field. This should be exploded in dedicated properties instead of a grey array. */
|
||||
protected $aParams;
|
||||
|
||||
public function __construct(array $aParams, ?string $sId = null)
|
||||
@@ -31,6 +36,7 @@ class Field extends UIBlock
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @internal
|
||||
*/
|
||||
public function GetParams(): array
|
||||
{
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
{% set aParams = oUIBlock.GetParams() %}
|
||||
<div class="ibo-field ibo-field-{{ aParams.layout }}">
|
||||
<div id="{{ oUIBlock.GetId() }}" class="ibo-field ibo-field-{{ aParams.layout }}"
|
||||
data-attribute-code="{{ aParams.attcode }}"
|
||||
data-attribute-type="{{ aParams.atttype }}"
|
||||
data-attribute-label="{{ aParams.attlabel }}"
|
||||
{# 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="{% if (aParams.attflags b-and constant('OPT_ATT_HIDDEN')) == constant('OPT_ATT_HIDDEN') %}true{% else %}false{% endif %}"
|
||||
data-attribute-flag-read-only="{% if (aParams.attflags b-and constant('OPT_ATT_READONLY')) == constant('OPT_ATT_READONLY') %}true{% else %}false{% endif %}"
|
||||
data-attribute-flag-mandatory="{% if (aParams.attflags b-and constant('OPT_ATT_MANDATORY')) == constant('OPT_ATT_MANDATORY') %}true{% else %}false{% endif %}"
|
||||
data-attribute-flag-must-change="{% if (aParams.attflags b-and constant('OPT_ATT_MUSTCHANGE')) == constant('OPT_ATT_MUSTCHANGE') %}true{% else %}false{% endif %}"
|
||||
data-attribute-flag-must-prompt="{% if (aParams.attflags b-and constant('OPT_ATT_MUSTPROMPT')) == constant('OPT_ATT_MUSTPROMPT') %}true{% else %}false{% endif %}"
|
||||
data-attribute-flag-slave="{% if (aParams.attflags b-and constant('OPT_ATT_SLAVE')) == constant('OPT_ATT_SLAVE') %}true{% else %}false{% endif %}"
|
||||
data-value-raw="{{ aParams.value_raw }}"
|
||||
>
|
||||
<div class="ibo-field--label">{{ aParams.label|raw }}</div>
|
||||
<div class="ibo-field--value">{{ aParams.value|raw }}</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user