<%# locals: (f:, current_attachments: nil)  %>

<% current_attachments ||= f.object.attachments.reject(&:new_record?) %>
<%= t('screenshots.requirements', size: number_to_human_size(Rails.configuration.screenshot_max_size), number: Rails.configuration.screenshot_max_count ) %>
<div>
  <%= f.label :attachments, t('scripts.screenshots_add') %>
  <%= f.file_field :attachments, multiple: true, accept: HasAttachments::ALLOWED_CONTENT_TYPES.join(',') %>
</div>
<% if current_attachments.any? %>
  <div class="remove-attachments">
    <% current_attachments.each do |attachment| %>
      <div class="remove-attachment">
        <%= link_to url_for(attachment.blob) do %><%= image_tag attachment.variant(resize_to_limit: [200, 200]).url || attachment.variant(resize_to_limit: [200, 200]) %><% end %>
        <div class="remove-attachment-selecter">
          <%= f.hidden_field('attachments', multiple: true, value: attachment.signed_id) %>
          <input id="remove-attachment-<%= attachment.id %>" name="remove-attachment-<%= attachment.signed_id %>" type="checkbox" value="1"><label class="checkbox-label" for="remove-attachment-<%= attachment.id %>"><%= t('scripts.screenshots_remove') %></label>
        </div>
      </div>
    <% end %>
  </div>
<% end %>
