<div class="modal-dialog modal-lg" role="document">
  <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
      <h4 class="modal-title"><%= t('samples.modal_import.title') %></h4>
    </div>
    <%= bootstrap_form_tag(url: import_samples_team_path(@team, format: :json),
                          html: {'data-type' => 'json', id: 'form-import'},
                          remote: true) do |f|%>
    <div class="modal-body">
      <h4><%= t("teams.parse_sheet.help_text") %></h4>
      <div style="overflow-x: scroll">
        <table class="table" style="display: block">
          <thead>
            <th style="min-width: 100px">
              <p><%= t("teams.parse_sheet.scinote_columns_html") %></p>
              <p style="margin-bottom: 0px"><%= t("teams.parse_sheet.file_columns") %></p>
            </th>
            <% @header.each.with_index do |th, index| %>
              <th style="min-width: 150px" title="<%= th %>">
                <%= f.select("mappings[#{index.to_s}]",
                             options_from_collection_for_select(@available_fields,
                                                                :first,
                                                                :last),
                             include_blank: t('teams.parse_sheet.do_not_include_column'),
                             hide_label: true) %>
                <br />
                <% if th.nil? %>
                  <i><%= t('samples.modal_import.no_header_name') %></i>
                <% else %>
                  <% if th.length > Constants::NAME_TRUNCATION_LENGTH_DROPDOWN %>
                    <div class="modal-tooltip">
                      <%= truncate(th, length: Constants::NAME_TRUNCATION_LENGTH_DROPDOWN) %>
                    </div>
                  <% else %>
                    <%= th %>
                  <% end %>
                <% end %>
              </th>
            <% end %>
          </thead>
          <tbody>
            <tr>
              <td>
                <p><%= t('teams.parse_sheet.example_value') %></p>
              </td>
              <% @columns.each do |td| %>
                <td>
                  <%= td %>
                </td>
              <% end %>
            </tr>
          </tbody>
        </table>
      </div>
      <%= hidden_field_tag 'file_id', @temp_file.id %>

      <div id="import-errors-container">
      </div>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default" data-dismiss="modal"><%= t('general.cancel')%></button>
      <input type="submit" class="btn btn-primary" value="<%= t('teams.parse_sheet.import_samples') %>"</input>
    </div>
    <% end %>
  </div>
</div>

<%= javascript_include_tag('samples/samples_importer') %>