= render :partial => 'spree/admin/shared/configuration_menu'

- content_for :page_title do
  = Spree.t(:image_settings)

= form_tag admin_image_settings_path, :method => :put do
  - destroy = Spree.t(:destroy)

  %fieldset.no-border-top
    %fieldset.no-border-bottom
      %legend{:align => "center"}= Spree.t(:general_settings)
      .field
        .warning.note= Spree.t(:image_settings_warning)

      .field{"data-hook" => "attachment_path"}
        = label_tag 'preferences[attachment_path]', Spree.t(:attachment_path)
        = preference_field_tag 'preferences[attachment_path]', Spree::Config[:attachment_path], :type => :string
      .alpha.eight.columns
        .field{"data-hook" => "attachment_default_url"}
          = label_tag 'preferences[attachment_default_url]', Spree.t(:attachment_default_url)
          = preference_field_tag 'preferences[attachment_default_url]', Spree::Config[:attachment_default_url], :type => :string
      .alpha.eight.columns
        .field{"data-hook" => "attachment_url"}
          = label_tag 'preferences[attachment_url]', Spree.t(:attachment_url)
          = preference_field_tag 'preferences[attachment_url]', Spree::Config[:attachment_url], :type => :string
      .omega.four.columns
        .field{"data-hook" => "attachment_default_style"}
          = label_tag 'preferences[attachment_default_style]', Spree.t(:attachment_default_style)
          = collection_select 'preferences', 'attachment_default_style', @styles, :first, :first, {:selected => Spree::Config[:attachment_default_style] }, :class => 'select2 fullwidth'
      .clear
      .field{"data-hook" => "use_s3"}
        = preference_field_tag 'preferences[use_s3]', Spree::Config[:use_s3], :type => :boolean
        = label_tag 'preferences[use_s3]', Spree.t(:use_s3)

    %fieldset#attachment_styles.no-border-bottom{"data-hook" => "attachment_styles"}
      %legend{:align => "center"}= Spree.t(:attachment_styles)
      #styles_list.row.frameless
        - @styles.each_with_index do |(style_name, style_value), index|
          .field.three.columns
            = label_tag "attachment_styles[#{style_name}]", style_name
            %a.destroy_style{:alt => t(:destroy), :href => "#", :title => t(:destroy)}
              %i.icon-trash
            = text_field_tag "attachment_styles[#{style_name}][]", admin_image_settings_geometry_from_style(style_value), :class => 'fullwidth'
            %br/
            - current_format = admin_image_settings_format_from_style(style_value) || ''
            = select_tag "attachment_styles[#{style_name}][]", options_for_select(admin_image_settings_format_options, current_format), :class => 'fullwidth', :id => "attachment_styles_format_#{style_name}"
      #new-styles.row.frameless
      .field
        = link_to_with_icon 'icon-plus', Spree.t(:add_new_style), '#', :class => 'add_new_style button'

    .row
      #s3_settings.alpha.six.columns{"data-hook" => "s3_settings", :style => "display: none"}
        %fieldset.no-border-bottom
          %legend{:align => "center"}= Spree.t(:configure_s3)
          .field{"data-hook" => "s3_access_key"}
            = label_tag 'preferences[s3_access_key]', Spree.t(:s3_access_key)
            = preference_field_tag 'preferences[s3_access_key]', Spree::Config[:s3_access_key], :type => :string
          .field{"data-hook" => "s3_secret"}
            = label_tag 'preferences[s3_secret]', Spree.t(:s3_secret)
            = preference_field_tag 'preferences[s3_secret]', Spree::Config[:s3_secret], :type => :string
          .field{"data-hook" => "s3_bucket"}
            = label_tag 'preferences[s3_bucket]', Spree.t(:s3_bucket)
            = preference_field_tag 'preferences[s3_bucket]', Spree::Config[:s3_bucket], :type => :string
          .field{"data-hook" => "s3_protocol"}
            = label_tag 'preferences[s3_protocol]', Spree.t(:s3_protocol)
            = preference_field_tag 'preferences[s3_protocol]', Spree::Config[:s3_protocol], :type => :string

      #s3_headers.omega.six.columns{"data-hook" => "s3_headers", :style => "display: none"}
        %fieldset.no-border-bottom
          %legend{:align => "center"}= Spree.t(:s3_headers)
          #headers_list
            - @headers.each do |header_name, header_value|
              .field
                = label_tag "s3_headers[#{header_name}]", header_name
                %a.destroy_header.with-tip{:alt => destroy, :href => "#", :title => destroy}
                  %i.icon-trash
                = text_field_tag "s3_headers[#{header_name}]", header_value, :class => 'fullwidth'
          = link_to_with_icon 'icon-plus', Spree.t(:add_new_header), '#', :class => 'add_header button'

    .form-buttons.filter-actions.actions{"data-hook" => "buttons"}
      = button Spree.t('actions.update'), 'icon-refresh'
