<div class="row">
  <div class="col-md-12">
    <h3><%= _('Section details') %></h3>
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <%= form_for(section, url: admin_update_section_path(section, phase: phase), html: { method: :put }) do |f| %>
      <div class='form-group col-xs-8'>
          <%= f.label(:title, _('Title'), { class: 'control-label' }) %>
          <%= f.text_field(:title, { class: 'form-control', 'aria-required': false, placeholder: _('Enter a title for the section'), 'data-toggle': 'tooltip', title: _('Enter a title for the section')} ) %>
      </div>

      <div class='form-group col-xs-8'>
        <%= f.label(:number, _('Order of display'), class: 'control-label') %>
        <%= f.number_field(:number, in: 1..15, class: 'form-control', 'aria-required': false, 'data-toggle': 'tooltip', title: _('This allows you to order sections.')) %>
      </div>

      <div class='form-group col-xs-8'>
        <%= f.label(:description, _('Description'), class: 'control-label') %>
        <div data-toggle="tooltip" title="<%= _("Enter a basic description. This could be a summary of what is covered in the section or instructions on how to answer. This text will be displayed in the coloured banner once a section is opened to edit.") %>">
          <%= text_area_tag('section-desc', section.description, class: 'tinymce form-control') %>
        </div>
      </div>

      <div class='form-group col-xs-8'>
        <%= f.button(_('Save'), class: 'btn btn-default', type: "submit") %>
        <%= link_to _('Delete'), admin_destroy_section_path(section_id: section.id),
              confirm: _("You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?") % { :section_title => section.title }, method: :delete, class: 'btn btn-default', role:'button' %>
      </div>
    <% end %>
  </div>
</div>

<div class="row">
  <div class="col-md-12">
    <h3><%= _('Questions') %></h3>
    <% questions = section.questions.order('number') %>
    <% if questions.present? %>
      <% questions.each do |question| %>
        <% if question.modifiable %>
          <%#= render partial: 'questions/edit_question', locals: {question: question} %>
        <% else %>
          <%#= render partial: 'questions/show_question', locals: {question: question} %>
        <% end %>
        <% if questions.last.id != question.id %>
          <hr />
        <% end %>
      <% end %>
    <% end %>
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <div class="pull-right">
      <%= link_to(_('Add Question'), '#', { class: 'btn btn-default question_new_link', role: "button" }) %>
    </div>
  </div>
  <div class="col-md-12">
    <div class="question_new" style="display: none;">
      <%= render partial: 'questions/add_question', locals: { section: section } %>
    </div>
  </div>
</div>