<% provide(:head_title, t('sample_types.index.head_title')) %>
<%= render partial: "shared/sidebar" %>
<%= render partial: "shared/secondary_navigation" %>

<% if current_team %>
  <ul class="nav nav-tabs nav-settings" data-position="bottom">
    <li role="presentation" class="active">
      <%= link_to t('sample_types.index.sample_types'),
                  team_sample_types_path(current_team,
                    project_id: (@project.id if @project),
                    my_module_id: (@my_module.id if @my_module),
                    experiment_id: (@experiment.id if @experiment)) %>
    </li>
    <li role="presentation">
      <%= link_to t('sample_types.index.sample_groups'),
                  team_sample_groups_path(current_team,
                    project_id: (@project.id if @project),
                    my_module_id: (@my_module.id if @my_module),
                    experiment_id: (@experiment.id if @experiment)) %>
    </li>
  </ul>
  <div class="tab-content">
    <div class="tab-pane tab-pane-settings tab-pane-protocols active" role="tabpanel">
      <div class="pull-right">
        <button id="create-resource"
               class="btn btn-primary pull-right"><%= t 'sample_types.index.new' %></button>
      </div>
      <ul class="list-unstyled sample_types_groups_list"
          id="sample_types_list">
        <li class="new-resource-form">
          <div class="row">
              <%= form_for SampleType.new,
                                     remote: true,
                                     html: { class: 'form-inline' },
                                     url: team_sample_types_path(current_team) do |f| %>

              <div class="col-xs-8">
                <div class="form-group">
                  <%= f.text_field :name, id: 'name-input', class: 'form-control' %>
                </div>
              </div>
              <div class="text-right col-md-4">
                <button id="submit"
                        class="btn btn-primary"><%= t('general.create') %></button>
                <button id="remove"
                        class="btn btn-default"><%= t('general.cancel') %></button>
              </div>
            <% end %>
          </div>
        </li>
        <% @sample_types.sorted.each do |sample_type| %>
          <%= render partial: 'sample_type',
                              locals: { sample_type: sample_type,
                                        team: current_team } %>
        <% end %>
      </ul>
    </div>
  </div>
<% end %>

<%= javascript_include_tag 'samples/sample_types_groups' %>
