{% extends "@bazar/layouts/input.twig" %}

{% block input %}
    <div class="input-group">
        {% if value %}
            <a href="{{ fileUrl }}" target="_blank" download="{{ shortFileName }}">{{ shortFileName }}</a>
            &nbsp;-&nbsp;
            <label class="btn btn-sm btn-default">
                <i class="fa fa-pencil-alt"></i>
                {{ _t('BAZ_MODIFIER_FICHIER') }}
                {% set style = 'display:none;' %}
                {{ block('inputblock') }}
            </label>   
             {% if isAllowedToDeleteFile %}
                <a class="btn btn-sm btn-danger" href="{{ deleteUrl }}" 
                   onClick="javascript:return confirm('{{ _t('BAZ_CONFIRMATION_SUPPRESSION_FICHIER') }}');">
                    {{- _t('BAZ_SUPPRIMER') -}}
                </a>            
             {% else %}            
                <button class="btn btn-sm btn-danger" disabled="disabled"
                    data-toggle="tooltip" data-placement="bottom" title="{{ _t('BAZ_DROIT_INSUFFISANT') }}">
                    <i class="fa fa-trash"></i>
                    {{ _t('BAZ_SUPPRIMER') }}
                </button>
            {% endif %}
            <br />
            <input
                type="hidden"
                name="{{ field.propertyName }}"
                value="{{ value }}"
            />
        {% else %}
          {% block inputblock %}
            <input
                type="file"
                data-max-size="{{ maxSize }}"
                id="{{ field.propertyName }}"
                name="{{ field.propertyName }}"
                {% if style %}style="{{ style }}"{% endif %}
                class="form-control yw-file-upload"
                {% if field.authorizedExts is not empty %}accept="{{field.authorizedExts|join(',')}}"{% endif %}
                {% if field.required %}required{% endif %}
            />
            {% endblock %}
        {% endif %}
    </div>
{% endblock %}
