Newer
Older
dmpopidor / app / views / sections / _edit_section.html.erb
<!--
**Project: DMPRoadmap
**Description: This block edits a section and its questions.
**Arguments transferred: 'section'
**Copyright: Digital Curation Centre and California Digital Library
-->

<h3><%= _('Section details') %></h3>
<div id="collapse-sec-<%= section.id %>">
	<%= form_for(section, url: admin_update_section_path(section, phase: phase, edit: edit), html: { method: :put, class: 'roadmap-form bordered'}) do |s| %>
		<fieldset class="side-by-side">
			<div class="form-input">
      	<%= s.label :title %>
				<%= s.text_field :title, as: :string, class: 'input-large', placeholder: _('New section title') %>
			</div>
			<div class="form-input">
				<%= s.label _('Order of display'), for: :number %>
        <%= s.number_field :number, in: 1..15, class: "input-small has-tooltip", 'data-toggle' => "tooltip", 'title' => _('This allows you to order sections.') %>
      <div class="form-input">
				<%= s.label :description %>
        <%= text_area_tag("section-desc-#{section.id}", section.description , class: "tinymce") %>
        <div class="inline">
          <%= link_to( image_tag('help_button.png'), '#', class: 'section_desc_popover', rel: "popover", 'data-html' => "true", 'data-content' => _("<div class='tooltip_box'>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.</div>"))%>
        </div>
			</div>
			
      <br />
      <div class="form-input">
        <label></label>
        <%= s.submit _('Save'), class: 'btn btn-primary' %>
        <% if section.modifiable %>
          <%= 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-primary"%>
        <% end %>
        <%= link_to _('Cancel'), :back, class: 'btn cancel' %>
      </div>
		</fieldset>
	<% end %>
</div>
	
<h3><%= _('Questions') %></h3>
<% @questions = section.questions.order("number")%>
<% if @questions.length > 0 %>
	<% @questions.each do |question| %>
		<div class="question_guidance_block">
			<div id="show_question_div_<%= question.id%>" class="<%= if question.id == @question_id then "current_question" end %>">
        <!-- render the show question block-->
        <%= render partial: 'questions/show_question', locals: {question: question} %>
      </div>

      <div id="edit_question_div_<%= question.id%>"  style="display: none">
        <!-- render the edit question block-->
        <%= render partial: 'questions/edit_question', locals: {question: question} %>
      </div>
		</div>
  <% end %>
<% end %>
        
<!-- Add a new question if the version is not published-->
<% if section.modifiable %>
	<!-- add question block -->
	<div id="add_question_block_div_<%= section.id%>" style="display: none">
		<%= render partial: 'questions/add_question', locals: {section: section} %>
	</div>

  <!-- add question button-->
	<div id="add_question_button_div_<%= section.id%>">
    <div class="div_left">
      <%= hidden_field_tag :section_id, section.id, class: "section_id" %>
      <%= link_to _('Add question'), '#', class: "btn btn-primary add_question_button" %>
    </div>
  </div>
<% end %>