КОНТРОЛЫ/drive_field.md


Исходный код

Twig код

{% if is_deleted %}
  {% set file_id = null %}
  {% set file_name = null %}
  {% set file_size = null %}
{% endif %}

<div class="drive-field {{ control_class_name|default('js-control-drive-field') }} {% if not file_id %}empty{% endif %} js-file-name-cache-width" data-field-id="{{ field_id }}" data-uuid="{{ file_id }}" data-element-id="{{ element_id }}" data-element-type="{{ element_type }}" data-lead-element-id="{{lead_element_id}}" {{ additional_data|raw }}>
  <div class="drive-field__controls">
    <div class="drive-field__name">
      <div class="drive-field__name-inner js-drive-field-name js-control-file-name" title="{{ file_name }}" data-upload-text="{{ 'Upload'|i18n }}" data-file-name-type="{{file_name_type}}">
        {% if file_id %}
          {{ file_name|default('Deleted file'|i18n) }}
        {% endif %}
      </div>
      <span class="drive-field__size">
        {% if file_id %}
          {% if file_size > 0 %}({{ file_size|format_file_size }}){% endif %}
        {% endif %}
      </span>
    </div>

    {% if not disabled and not disable_download %}
      {% include "interface/controls/button.twig" with {
        class_name: 'drive-field__download-btn js-drive-field-download',
        svg_class_name: 'common--download-files',
        text: 'download'|i18n,
        tab_index: "-1",
        inner_class_name: 'drive-field__download-btn-inner',
      } only %}
    {% endif %}

    <input type="hidden" {% if input_class_name %}class="{{ input_class_name }}"{% endif %} name="{{ name }}" value="{{ file_id }}" {% if disabled %}disabled="disabled"{% endif %}>
  </div>

  {% set unq_id = random() %}

  {% include "interface/controls/file.twig" with {
    id: 'drive-field-' ~ unq_id,
    class: 'hidden js-drive-field-file js-form-changes-skip',
    accept: accept,
  } only %}

  {% include "interface/common/tip.twig" with {
    class_name: 'drive-field__main-menu js-drive-field-main-menu',
    items: [
      {
        svg_icon: 'controls--substitute',
        class_name: 'drive-field__substitute js-drive-field-substitute',
        text: '<label class="drive-field__substitute-label" for="drive-field-' ~ unq_id ~ '">' ~ 'Replace'|i18n ~ '</label>',
        should_be_raw: true
      },
      {
        svg_icon: 'common--download-files',
        class_name: 'js-drive-field-download',
        text: 'download'|i18n
      },
      {
        svg_icon: 'controls--file-versions',
        class_name: 'js-drive-field-versions',
        text: 'Versions'|i18n
      },
      {
        svg_icon: 'common--trash',
        class_name: 'js-drive-field-delete ' ~ (element_id and element_type ? '' : 'hidden'),
        text: 'Delete'|i18n
      },
    ]
  } %}
</div>

Ссылка на вики репозиторий