{% from 'utils.html.twig' import ico %}
{% for field in fields %}
<div class="cp {{ field.type == enum('UserCustomFieldEnum::FIELD_LONGTEXT') ? 'cp-4-2' : 'cp-4' }} cp-custom">
<label for="{{ field.id }}">
{{ field.title }}
{% if field.required == enum('UserCustomFieldEnum::YES') %} <em>*</em>{% endif %}
</label>
{# TEXT #}
{% if field.type == enum('UserCustomFieldEnum::FIELD_TEXT') %}
<input
id="{{ field.id }}"
type="text"
name="field[{{ field.id }}]"
cod="{{ field.type }}"
value="{{ field.value }}"
custom-field
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}
{% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %}
disabled="disabled"
{% endif %}
{% if field.size > 0 %}
maxlength="{{ field.size }}"
{% endif %}>
{# INT #}
{% elseif field.type == enum('UserCustomFieldEnum::FIELD_INT') %}
<input
id="{{ field.id }}"
type="number"
name="field[{{ field.id }}]"
cod="{{ field.type }}"
value="{{ field.value }}"
custom-field
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}
{% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %}
disabled="disabled"
{% endif %}>
{# DOUBLE #}
{% elseif field.type == enum('UserCustomFieldEnum::FIELD_DOUBLE') %}
<input
id="{{ field.id }}"
type="text"
name="field[{{ field.id }}]"
class="float-inp"
cod="{{ field.type }}"
value="{{ field.value }}"
custom-field
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}
{% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %}
disabled="disabled"
{% endif %}>
{# LONGTEXT #}
{% elseif field.type == enum('UserCustomFieldEnum::FIELD_LONGTEXT') %}
{% set edit = not (field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty) %}
{% set tag = edit? 'textarea':'div' %}
<{{ tag }}
id="{{ field.id }}"
name="field[{{ field.id }}]"
cod="{{ field.type }}"
custom-field
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}
{% if edit %}
class="js--editor"
{% else %}
disabled="disabled"
class="fr-view text-noedit"
{% endif %}
>{{ field.value|raw }}
</{{ tag }}>
{# OPTION SELECT #}
{% elseif field.type == enum('UserCustomFieldEnum::FIELD_OPTION_SELECT') %}
<select
id="{{ field.id }}"
type="text"
name="field[{{ field.id }}]"
cod="{{ field.type }}"
custom-field
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}
{% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %}
disabled="disabled"
{% endif %}>
<option value="">Selecione...</option>
{% for option in field.optionsObj %}
<option {% if field.value == option.value %} selected="selected=" {% endif %} value="{{ option.value }}">
{{ option.text }}
</option>
{% endfor %}
</select>
{# RADIOS #}
{% elseif field.type == enum('UserCustomFieldEnum::FIELD_OPTION_RADIO') %}
{% set fieldDisabled = (field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty) %}
<div id="{{ field.id }}"
custom-field
cod="{{ field.type }}">
<div class="wrap-boxes">
{% for k, option in field.optionsObj %}
<label for="radio_{{ k }}_{{ field.id }}" class="cp-radio{{ fieldDisabled?' disabled' }}">
<input
id="radio_{{ k }}_{{ field.id }}"
type="radio"
name="field[{{ field.id }}]"
class="float-inp custom-input-group"
value="{{ option.value }}"
{% if field.value == option.value %}
checked="checked"
{% endif %}
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}
{% if fieldDisabled %}
disabled="disabled"
{% endif %}>
<span class="check material-icons">radio_button_unchecked</span>
<span class="check material-icons">radio_button_checked</span>
<span class="txt">{{ option.text }}</span>
</label>
{% endfor %}
</div>
</div>
{# CHECKBOXES #}
{% elseif field.type == enum('UserCustomFieldEnum::FIELD_MULTIPLE') %}
{% set fieldDisabled = (field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty) %}
<div id="{{ field.id }}"
custom-field
cod="{{ field.type }}">
<div class="wrap-boxes">
{% for k, option in field.optionsObj %}
<label for="checkbox_{{ k }}_{{ field.id }}" class="cp-radio{{ fieldDisabled?' disabled' }}">
<input
id="checkbox_{{ k }}_{{ field.id }}"
type="checkbox"
name="field[{{ field.id }}][]"
class="float-inp custom-input-group"
value="{{ option.value }}"
required
{% if option.checked %}
checked="checked"
{% endif %}
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}
{% if fieldDisabled %}
disabled="disabled"
{% endif %}>
<span class="check material-icons">check_box_outline_blank</span>
<span class="check material-icons">check_box</span>
<span class="txt">{{ option.text }}</span>
</label>
{% endfor %}
</div>
</div>
{# MASK #}
{% elseif field.type == enum('UserCustomFieldEnum::FIELD_MASK') %}
<input
id="{{ field.id }}"
type="text"
name="field[{{ field.id }}]"
class="mask-inp"
cod="{{ field.type }}"
value="{{ field.value }}"
data-mask="{{ field.options }}"
custom-field
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}
{% if field.allowEdit == enum('UserCustomFieldEnum::NO') and field.value is not empty %}
disabled="disabled"
{% endif %}>
{# FILE #}
{% elseif field.type == enum('UserCustomFieldEnum::FIELD_FILE') %}
{# Cheio e Não Editável #}
{% if (field.value is not empty) and (field.value.path is defined) and (field.allowEdit == enum('UserCustomFieldEnum::NO')) %}
<div
custom-field
class="input-file"
size="{{ field.value.size }}"
type-content="{{ field.value.type }}"
name-content="{{ field.value.name }}"
path="{{ field.value.path }}"
extension="{{ field.value.extension }}"
>
<p class="file-label filename">{{ field.value.name }}</p>
</div>
{% endif %}
{# Vazio ou Editável #}
{% if (field.value is empty) or (field.allowEdit == enum('UserCustomFieldEnum::YES')) %}
<div class="dropfile js--dropfile input-file"
data-status="{{ (field.value is empty)? 'empty':'full' }}"
data-btn-delete="{{ (field.value is not empty)? "#btn-delete-#{field.id}" }}">
<div class="drop-area js--dropfile-area">
{{ ico('upload') }}
<div class="drop-label">
<p class="filename show-empty">{{ getLanguage('drop_file', 'profile') }}</p>
<p class="filename show-wait">{{ getLanguage('wait', 'util') }}…</p>
<p class="filename show-full js--dropfile-file-label">{{ (field.value is not empty)? field.value.name }}</p>
</div>
</div>
<input
custom-field
class="js--dropfile-input"
id="{{ field.id }}"
type="file"
name="files[{{ field.id }}]"
data-delete-url="{{ path('userDeleteCustomFile', { id: user.id, fieldId: field.id }) }}"
cod="{{ field.type }}"
data-status="{{ (field.value is empty) ? 'empty' : 'full' }}"
{% if (field.value is not empty) %}
size="{{ field.value.size }}"
type-content="{{ field.value.type }}"
name-content="{{ field.value.name }}"
path="{{ field.value.path|default('') }}"
extension="{{ field.value.extension|default('') }}"
{% endif %}
{% if field.value is not empty %}
disabled="disabled"
{% endif %}
{% if field.required == enum('UserCustomFieldEnum::YES') %}
required="required"
{% endif %}>
</div>
{% endif %}
{# ACTIONS #}
{# Cheio #}
{% if field.value is not empty %}
<nav class="actions">
<a href="{{ path('userDownloadCustom', { id: user.id, fieldId: field.id }) }}" class="btn-ed" download>{{ ico('download') }}DOWNLOAD</a>
{# Cheio e Editável #}
{% if field.allowEdit == enum('UserCustomFieldEnum::YES') %}
<button id="btn-delete-{{ field.id }}" type="button" class="js--dropfile-btn-delete btn-ed">
{{ ico('delete') }}{{ getLanguage('delete', 'profile') }}
</button>
{% endif %}
</nav>
{% endif %}
{% endif %}
</div>
{% endfor %}