<% settings = Setting.plugin_redmine_ux_toolkit || {} %>
<% preview = RedmineUxToolkit::Services::AttachmentPreview %>

<div class="box tabular settings">
  <p>
    <%= hidden_field_tag 'settings[attachment_preview_enabled]', '0', id: nil %>
    <%= check_box_tag 'settings[attachment_preview_enabled]',
                      '1',
                      preview.feature_enabled?(settings),
                      id: 'settings_attachment_preview_enabled' %>
    <%= label_tag 'settings_attachment_preview_enabled',
                  l(:label_ux_toolkit_enable_attachment_previews) %>
    <em class="info"><%= l(:text_ux_toolkit_attachment_preview_help) %></em>
  </p>

  <fieldset>
    <legend><%= l(:label_ux_toolkit_attachment_preview_options) %></legend>

    <% [
         [:attachment_preview_images, :label_ux_toolkit_attachment_preview_images, preview.images_enabled?(settings)],
         [:attachment_preview_pdfs, :label_ux_toolkit_attachment_preview_pdfs, preview.pdfs_enabled?(settings)],
         [:attachment_preview_gallery, :label_ux_toolkit_attachment_preview_gallery, preview.gallery_enabled?(settings)],
         [:attachment_preview_download, :label_ux_toolkit_attachment_preview_download, preview.download_enabled?(settings)]
       ].each do |setting_key, label_key, checked| %>
      <p>
        <%= hidden_field_tag "settings[#{setting_key}]", '0', id: nil %>
        <%= check_box_tag "settings[#{setting_key}]",
                          '1',
                          checked,
                          id: "settings_#{setting_key}" %>
        <%= label_tag "settings_#{setting_key}", l(label_key) %>
      </p>
    <% end %>
  </fieldset>
</div>

<p class="info"><%= l(:text_ux_toolkit_attachment_preview_download_help) %></p>
