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

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

= form_tag admin_general_settings_path, :method => :put do
  #preferences{"data-hook" => ""}

    %fieldset.general.no-border-top
      - @preferences_general.each do |key|
        - type = Spree::Config.preference_type(key)
        .field
          = label_tag(key, Spree.t(key) + ': ') + tag(:br) if type != :boolean
          = preference_field_tag(key, Spree::Config[key], :type => type)
          = label_tag(key, Spree.t(key)) + tag(:br) if type == :boolean

      .row
        .alpha.six.columns
          %fieldset.security.no-border-bottom
            %legend{:align => "center"}= Spree.t(:security_settings)
            - @preferences_security.each do |key|
              - type = Spree::Config.preference_type(key)
              .field
                = label_tag(key, Spree.t(key) + ': ') + tag(:br) if type != :boolean
                = preference_field_tag(key, Spree::Config[key], :type => type)
                = label_tag(key, Spree.t(key)) + tag(:br) if type == :boolean
          %fieldset.legal.no-border-bottom
            %legend{:align => "center"}= t('.legal_settings')
            .field
              = label_tag(:footer_tos_url, t('.footer_tos_url')) + tag(:br)
              = preference_field_tag(:footer_tos_url, Spree::Config[:footer_tos_url], type: Spree::Config.preference_type(:footer_tos_url))
            .field
              = preference_field_tag(:enterprises_require_tos, Spree::Config[:enterprises_require_tos], :type => Spree::Config.preference_type(:enterprises_require_tos))
              = label_tag(:enterprises_require_tos, t('.enterprises_require_tos')) + tag(:br)
            .field
              = preference_field_tag(:cookies_consent_banner_toggle, Spree::Config[:cookies_consent_banner_toggle], :type => Spree::Config.preference_type(:cookies_consent_banner_toggle))
              = label_tag(:cookies_consent_banner_toggle, t('.cookies_consent_banner_toggle')) + tag(:br)
            .field
              = preference_field_tag(:cookies_policy_matomo_section, Spree::Config[:cookies_policy_matomo_section], :type => Spree::Config.preference_type(:cookies_policy_matomo_section))
              = label_tag(:cookies_policy_matomo_section, t('.cookies_policy_matomo_section')) + tag(:br)
            .field
              = preference_field_tag(:cookies_policy_ga_section, Spree::Config[:cookies_policy_ga_section], :type => Spree::Config.preference_type(:cookies_policy_ga_section))
              = label_tag(:cookies_policy_ga_section, t('.cookies_policy_ga_section')) + tag(:br)
            .field
              = label_tag(:privacy_policy_url, t('.privacy_policy_url')) + tag(:br)
              = preference_field_tag(:privacy_policy_url, Spree::Config[:privacy_policy_url], type: Spree::Config.preference_type(:privacy_policy_url))
          %fieldset.embedded_shopfronts.no-border-bottom
            %legend{:align => "center"}= t('admin.shopfront_settings.embedded_shopfront_settings')
            .field
              = preference_field_tag(:enable_embedded_shopfronts, Spree::Config[:enable_embedded_shopfronts], type: Spree::Config.preference_type(:enable_embedded_shopfronts))
              = label_tag(:enable_embedded_shopfronts, t('admin.shopfront_settings.enable_embedded_shopfronts')) + tag(:br)
            .field
              = label_tag(:embedded_shopfronts_whitelist, t('admin.shopfront_settings.embedded_shopfronts_whitelist')) + tag(:br)
              = preference_field_tag(:embedded_shopfronts_whitelist, Spree::Config[:embedded_shopfronts_whitelist], type: Spree::Config.preference_type(:embedded_shopfronts_whitelist))

        .omega.six.columns
          %fieldset.currency.no-border-bottom
            %legend{:align => "center"}= Spree.t(:currency_settings)
            - @preferences_currency.each do |key|
              - type = Spree::Config.preference_type(key)
              .field
                = label_tag(key, Spree.t(key) + ': ') + tag(:br) if type != :boolean
                = preference_field_tag(key, Spree::Config[key], :type => type)
                = label_tag(key, Spree.t(key)) + tag(:br) if type == :boolean
            .field
              = label_tag :currency, Spree.t(:choose_currency)
              %br/
              = select_tag :currency, currency_options, :class => 'fullwidth'
            .field
              = label_tag Spree.t(:currency_symbol_position)
              %br/
              .choices
                %ul
                  %li
                    = radio_button_tag :currency_symbol_position, "before", Spree::Config[:currency_symbol_position] == "before"
                    = label_tag :currency_symbol_position_before, Spree::Money.new(10, :symbol_position => "before")
                  %li.white-space-nowrap
                    = radio_button_tag :currency_symbol_position, "after", Spree::Config[:currency_symbol_position] == "after"
                    = label_tag :currency_symbol_position_after, Spree::Money.new(10, :symbol_position => "after")
            .field
              = label_tag :currency_decimal_mark, Spree.t(:currency_decimal_mark)
              %br/
              = text_field_tag :currency_decimal_mark, Spree::Config[:currency_decimal_mark], :size => 3
            .field
              = label_tag :currency_thousands_separator, Spree.t(:currency_thousands_separator)
              %br/
              = text_field_tag :currency_thousands_separator, Spree::Config[:currency_thousands_separator], :size => 3
          %fieldset.number_localization.no-border-bottom
            %legend{:align => "center"}= t('admin.number_localization.number_localization_settings')
            .field
              = preference_field_tag(:enable_localized_number?, Spree::Config[:enable_localized_number?], type: Spree::Config.preference_type(:enable_localized_number?))
              = label_tag(:enable_localized_number?, t('admin.number_localization.enable_localized_number')) + tag(:br)

      .form-buttons.filter-actions.actions{"data-hook" => "buttons"}
        = button Spree.t('actions.update'), 'icon-refresh'
        %span.or= Spree.t(:or)
        = link_to_with_icon 'icon-remove', Spree.t('actions.cancel'), edit_admin_general_settings_url, :class => 'button'

:javascript
  $('#currency').select2();
