Newer
Older
dmpopidor / app / views / sections / _edit_section.html.erb
<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, r: current_tab), html: { method: :put }) do |f| %>
      <div class="form-group col-md-10">
        <%= 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">
        <div class="col-md-10">
          <%= f.label(:number, _('Order of display'), class: "control-label") %>
        </div>
        <div class="col-md-4">
          <%= 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>

      <div class="form-group col-md-10">
        <%= 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: "section tinymce form-control") %>
        </div>
      </div>

      <div class="form-group col-md-10">
        <div class="pull-right">
          <%= f.button(_('Save'), class: 'btn btn-default', type: "submit") %>
          <%= link_to _('Delete'), admin_destroy_section_path(section_id: section.id, r: current_tab), 'data-method': 'delete', rel: 'nofollow',
                'data-confirm': _("You are about to delete '%{section_title}'. This will affect questions linked to this section. Are you sure?") % { :section_title => section.title }, class: 'btn btn-default', role:'button' %>
          <%= link_to _('Cancel'), admin_show_phase_path(section.phase), class: 'btn btn-default', role: 'button' %>
        </div>
      </div>
    <% end %>
  </div>
  <div class="col-md-12">
    <h3><%= _('Questions') %></h3>
    <% questions = section.questions.order('number') %>
    <% if questions.present? %>
        <% questions.each do |question| %>
          <hr />
          <div class="question_show" id="<%= "question_show#{question.id}" %>">
            <%= render partial: 'questions/show_question', locals: {template: template, question: question, current_tab: current_tab, edit: edit} %>
          </div>
          <div class="question_edit" id="<%= "question_edit#{question.id}" %>" style="display: none;">
            <%= render partial: 'questions/edit_question', locals: {template: template, question: question, current_tab: current_tab} %>
          </div>
          <%= raw("<hr />") if questions.last.id == question.id %>
        <% end %>
    <% end %>
  </div>
</div>
<% if edit %>
  <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 class="question_new" style="display: none;">
        <%= render partial: 'questions/add_question', locals: { section: section, current_tab: current_tab } %>
      </div>
    </div>
  </div>
<% end %>