= content_for :page_title do
  = t('.title')

= ng_form_for @enterprise_fee_set, :url => main_app.bulk_update_admin_enterprise_fees_path, :html => {'ng-app' => 'admin.enterpriseFees', 'ng-controller' => 'enterpriseFeesCtrl'} do |enterprise_fee_set_form|
  = hidden_field_tag 'enterprise_id', @enterprise.id if @enterprise
  = render "admin/enterprise_fees/data"
  = render :partial => 'spree/shared/error_messages', :locals => { :target => @enterprise_fee_set }

  %input.search{'ng-model' => 'query', 'placeholder' => t('.search')}

  %table.index#listing_enterprise_fees
    %thead
      %tr
        %th
          = t('.enterprise')
        %th
          = t('.fee_type')
        %th
          = t('.name')
        %th
          = t('.tax_category')
        %th
          = t('.calculator')
        %th
          = t('.calculator_values')
        %th.actions
    %tbody
      = enterprise_fee_set_form.ng_fields_for :collection do |f|
        %tr{ ng: { repeat: 'enterprise_fee in enterprise_fees | filter:query' } }
          %td
            = f.ng_hidden_field :id
            %ofn-select{ :id => angular_id(:enterprise_id), data: 'enterprises', include_blank: true, ng: { model: 'enterprise_fee.enterprise_id' } }
            %input{ type: "hidden", name: angular_name(:enterprise_id), ng: { value: "enterprise_fee.enterprise_id" } }
          %td= f.ng_select :fee_type, enterprise_fee_type_options, 'enterprise_fee.fee_type'
          %td= f.ng_text_field :name, { placeholder: t('.name_placeholder') }
          %td
            %ofn-select{ :id => angular_id(:tax_category_id), data: 'tax_categories', include_blank: true, ng: { model: 'enterprise_fee.tax_category_id' } }
            %input{ type: "hidden", name: angular_name(:tax_category_id), 'watch-tax-category' => true }
            %input{ type: "hidden", name: angular_name(:inherits_tax_category), ng: { value: "enterprise_fee.inherits_tax_category" } }
          %td
            %ofn-select.calculator_type{ :id => angular_id(:calculator_type), ng: { model: 'enterprise_fee.calculator_type' }, value_attr: 'name', text_attr: 'description', data: 'calculators', 'spree-ensure-calculator-preferences-match-type' => true }
            %input{ type: "hidden", name: angular_name(:calculator_type), ng: { value: "enterprise_fee.calculator_type" } }
          %td{'ng-bind-html-unsafe-compiled' => 'enterprise_fee.calculator_settings'}
          %td.actions{'spree-delete-resource' => "1"}

  = enterprise_fee_set_form.submit t(:update)
