<% columns = @importer.importable_columns(@importer.parser).map { |column| [@importer.source_klass.human_attribute_name(column), column] }.unshift([t('csv_import_magic.views.importers.edit.ignore_column_label'), :ignore]) %>

<%= t('csv_import_magic.views.importers.edit.title') %>
<%= t('csv_import_magic.views.importers.edit.description') %>

<%= simple_form_for @importer, url: importer_path(@importer) do |f| %>
<% import_file_csv.headers.each_with_index do |header, i| %>
<%= t('csv_import_magic.views.importers.edit.column') %> <%= header %>
<% selected = columns.find { |c| c.join(' ').match(/#{header}/i) }.try(:last).presence || :ignore %> <%= f.input "columns][", as: :select, collection: columns, label: false, hint: t('csv_import_magic.views.importers.edit.hint'), include_blank: false, selected: f.object.columns[i] || selected %>
<%= t('csv_import_magic.views.importers.edit.example_of_values') %>
<% import_file_csv.first(5).each_with_index do |row, c| %> <% end %>
<%= c + 1 %> <%= row[header] || t('csv_import_magic.views.importers.edit.empty_values') %>
<% end %>
<%= link_to t('csv_import_magic.views.importers.edit.buttons.cancel'), 'javascript:history.back()', class: 'button button--secondary' %> <%= f.submit t('csv_import_magic.views.importers.edit.buttons.import', count: import_file_csv.count), class: 'button button--primary' %>
<% end %>