♻️ new FieldFactory

Idea is to remove the aParams parameter from the Field object
And also allow to pass subblocks for the input value instead of only raw HTML
This commit is contained in:
Pierre Goiffon
2020-12-18 10:00:41 +01:00
parent f8b8dd0bc6
commit c8dbf88c03
9 changed files with 434 additions and 318 deletions

View File

@@ -1,23 +1,23 @@
{% set aParams = oUIBlock.GetParams() %}
<div id="{{ oUIBlock.GetId() }}" class="ibo-field ibo-field-{{ aParams.layout }}"
data-role="ibo-field"
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 %}"
<div id="{{ oUIBlock.GetId() }}" class="ibo-field ibo-field-{{ oUIBlock.GetLayout() }}"
data-role="ibo-field"
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 #}
{# as we might want to re-use / adapt the Field classes introduced with the end-user portal #}
data-attribute-flag-hidden="{% if oUIBlock.IsHidden() %}true{% else %}false{% endif %}"
data-attribute-flag-read-only="{% if oUIBlock.IsReadOnly() %}true{% else %}false{% endif %}"
data-attribute-flag-mandatory="{% if oUIBlock.IsMandatory() %}true{% else %}false{% endif %}"
data-attribute-flag-must-change="{% if oUIBlock.IsMustChange() %}true{% else %}false{% endif %}"
data-attribute-flag-must-prompt="{% if oUIBlock.IsMustPrompt() %}true{% else %}false{% endif %}"
data-attribute-flag-slave="{% if oUIBlock.IsSlave() %}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>
{% if (aParams.comments is not null) %}
{{ aParams.comments|raw }}
>
<div class="ibo-field--label">{{ oUIBlock.GetLabel()|raw }}</div>
<div class="ibo-field--value">{{ render_block(oUIBlock.GetValue()) }}</div>
{% if (oUIBlock.GetComments() is not null) %}
{{ oUIBlock.GetComments() }}
{% endif %}
</div>