Newer
Older
dmpopidor / app / views / plans / _plan_details.html.erb
@Brian Riley Brian Riley on 23 Jun 2017 15 KB fixed merge conflicts
<% javascript('plans/edit.js') %>

<!-- Project title = default title is the template title plus date of creation -->
<div class="dmp_details_body">

  <!--
    we have two div for the plan details
    one is for editing and one is for viewing
    one is always hidden and we switch between them with javascript in application.js
  -->

  <!-- the editing div -->
  <div class="edit-plan-details <%= unless @editing then "project-hide" end %>">
    <%= form_for @plan, url: {controller: :plans, action: :update }, 
                        html: {method: :put, class: "roadmap-form"} do |f| %>
      <div class="dmp_details">

        <!-- If not first time login in or editing project details -->
        <fieldset class="side-by-side">
          <legend><%= _('Please fill in the basic project details below') %></legend>
    
          <div>
            <%= f.label :title, _('Plan name') %>
            <%= f.text_field :title, class: "input-large has-tooltip", 'data-toggle': "tooltip", 
                    'title': _('If applying for funding, state the name exactly as in the grant proposal.') %>
          </div>
          <div>
            <label for="is_test"><%= _('Test plan') %></label>
            <input type="checkbox" id="is_test"<%= @plan.visibility == 'is_test' ? 'checked="true"' : '' %> />
          </div>
          <div>
            <label for="visibility" class="radio-label"><%= _('Visibility') %></label>
            
            <div class="inline-radios inline">
              <% ['publicly_visible', 'organisationally_visible', 'privately_visible'].each do |visibility| %>
                <input type="radio" 
                       name="visibility" 
                       value="<%= visibility %>"
                       <%= @plan.visibility == visibility ? 'checked="true"' : '' %> 
                       title="<%= visibility_tooltip(visibility) %>" /> 
                <%= raw display_visibility(visibility) %><br />
              <% end %>
            </div>
            <%= f.hidden_field :visibility %>
          </div>
          <div>
            <%= f.label :identifier, _('ID') %>
            <%= f.text_field :identifier, class: 'input-medium has-tooltip', 'data-toggle': "tooltip", 
                    'title': _('A pertinent ID as determined by the funder and/or institution.') %>
          </div>
          <div>
            <%= f.label :grant_number, _('Grant number') %>
            <%= f.text_field :grant_number, class: 'input-medium has-tooltip', 
                    'data-toggle': "tooltip", 
                    'title': _('Grant reference number if applicable [POST-AWARD DMPs ONLY]') %>
          </div>
          <div>
            <%= f.label :principal_investigator, _('Principal Investigator/Researcher') %>
            <%= f.text_field :principal_investigator, class: 'input-medium has-tooltip', 
                    'data-toggle': "tooltip", 
                    'title': _('Name of Principal Investigator(s) or main researcher(s) on the project.') %>
          </div>
          <div>
            <%= f.label :principal_investigator_identifier, _('Principal Investigator/Researcher ID') %>
            <%= f.text_field :principal_investigator_identifier, class: 'input-medium has-tooltip', 
                    'data-toggle': "tooltip", 'title': _('E.g ORCID http://orcid.org/.') %>
          </div>
          <div>      
            <%= f.label :data_contact, _('Plan data contact') %>
            <%= f.text_field :data_contact, class: 'input-medium has-tooltip', 
                    'data-toggle': "tooltip", 
                    'title': _('Name (if different to above), telephone and email contact details') %>
          </div>
          <div>
            <%= f.label :description, _('Description') %>
            <%= f.text_area :description, { rows: 7, class: 'input-large has-tooltip', 
                    'data-toggle': "tooltip", 'data-html': "true", 
                    'title': _("<div class='tooltip_box'><h4>Questions to consider:</h4><ul><li>- What is the nature of your research project?</li><li>- What research questions are you addressing? </li><li>- For what purpose are the data being collected or created? </li></ul><h4>Guidance:</h4><p>Briefly summarise the type of study (or studies) to help others understand the purposes for which the data are being collected or created.</p></div>")} %>
          </div>
          
          <div>
            <label></label>
            <input type="submit" class="form-submit" value="<%= _('Save') %>" />
            <button class="form-cancel show-edit-toggle"><%= _('Cancel') %></button>
          </div>
        </fieldset>
      </div>
      
    <%end%>
  </div>


  <!-- the viewing div -->
  <div class="show-plan-details <%= if @editing then "project-hide" end %> ">
      <div class="div_left">
        <p></p>
      </div>

      <!-- edit plan button -->
      <div class="div_right">
        <button class="btn btn-primary show-edit-toggle"><%= _('Edit plan details') %></button>
      </div>

      <!-- display plan details -->
      <div class="dmp_details">
        <table class="dmp_details_table">
          <tr>
            <td class="first"><%= _('Plan name') %></td>
            <td><%= @plan.title %></td>
          </tr>

          <tr>
            <td class="first"><%= _('Test plan') %></td>
            <td><%= @plan.visibility == 'is_test' ? _('Yes') : _('No') %></td>
          </tr>
          <tr>
            <td class="first"><%= _('Visibility') %></td>
            <td><%= raw display_visibility(@plan.visibility) %></td>
          </tr>

          <tr>
            <td class="first"><%= _('ID') %></td>
            <td>
              <% if !@plan.identifier.nil? && @plan.identifier != "" then %>
                <%= @plan.identifier %>
              <%else%>
                -
              <%end%>
            </td>
          </tr>

          <tr>
            <td class="first"><%= _('Grant number') %></td>
            <td>
              <% if !@plan.grant_number.nil? && @plan.grant_number!= "" then %>
                <%= @plan.grant_number %>
              <%else%>
                -
              <%end%>
            </td>
          </tr>
          <tr>
            <td class="first"><%= _('Principal Investigator/Researcher') %></td>
            <td><% if !@plan.principal_investigator.nil? && @plan.principal_investigator != "" then %>
              <%= @plan.principal_investigator %>
            <%else%>
              -
            <%end%>
            </td>
          </tr>
          <% if !@plan.principal_investigator_identifier.nil? && @plan.principal_investigator_identifier != "" then %>
            <tr>
              <td class="first"><%= _('Principal Investigator/Researcher ID') %></td>
              <td>
                <%= @plan.principal_investigator_identifier %>
              </td>
            </tr>
          <%end%>
          <tr>
            <td class="first"><%= _('Plan data contact') %></td>
            <td><% if !@plan.data_contact.nil? && @plan.data_contact != "" then%>
              <%= @plan.data_contact %>
            <%else%>
              -
            <%end%>
            </td>
          </tr>
          <tr>
            <td class="first"><%= _('Description') %></td>
            <td><% if !@plan.description.nil? && @plan.description != "" then%>
              <%= @plan.description %>
            <%else%>
              -
            <%end%>
            </td>
          </tr>
        </table>
      </div>
  </div>


  <!-- Selection of guidance groups -->
  <%= form_tag( update_guidance_choices_plan_path(@plan), method: :put) do %>
  <div id="plan-guidance-important">
      <h3>Guidance Choices</h3>
      <table id="dmp_table" class="dmp_table tablesorter">
      <tbody>
          <% @important_ggs.each do |org, groups| %>                                                                                                                                                                  
              <tr>
              <td class="dmp_td_medium">
                  <% if groups && groups.size == 1 %>
                      <%= check_box_tag "guidance_group_ids[]", groups[0].id, @selected_guidance_groups.include?(groups[0].id) %>
                      <%= org.name %>
                  <% elsif groups %>
                      <input type="checkbox" disabled> <%= org.name %>
                      <% groups.each do |group| %>
                          <tr><td class="dmp_td_small">
                              └─ <%= check_box_tag "guidance_group_ids[]", group.id, @selected_guidance_groups.include?(group.id) %>
                              <%= group.name %>
                          </td></tr>
                      <% end %>
                  <% end %>
              </td>
              </tr>
          <% end %>
      </tbody>
      </table>
  </div>
  <div class="accordion" id="plan-guidance-accordion">
      <div class="accordion-group">
          <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" data-parent="#plan-guidance-accordion" href="#guidance-choices">
                  <h3><%=_('Other institutions')%><span class="plus-laranja"> </span></h3>
              </a>
          </div>
          <div id="guidance-choices" class="accordion-project collapse">
                  <div class="accordion-inner">
                      <table id="other_ggs_table" class="dmp_table tablesorter">
                      <tbody>
                          <% @all_ggs_grouped_by_org.each do |org, groups| %>
                              <tr>
                              <td class="dmp_td_medium">
                                  <% if groups && groups.size == 1 %>
                                      <%= check_box_tag "guidance_group_ids[]", groups[0].id, @selected_guidance_groups.include?(groups[0].id) %>
                                      <%= org.name %>
                                  <% elsif groups %>
                                      <input type="checkbox" disabled> <%= org.name %>
                                      <% groups.each do |group| %>
                                          <tr><td class="dmp_td_small">
                                              └─ <%= check_box_tag "guidance_group_ids[]", group.id, @selected_guidance_groups.include?(group.id) %>
                                              <%= group.name %>
                                          </td></tr>
                                      <% end %>
                                  <% end %>
                              </td>
                              </tr>
                          <% end %>
                      </tbody>
                      </table>               
                  </div>
              </div>
          </div>
      </div>
      <%= submit_tag _('Save'), class: "btn btn-primary"%>
  <% end %>

  <div class="div_clear"></div>

  <h3><%= _('This plan is based on:')%></h3>

  <p>
    <% if based_on.org != plan.template.org %>
      <%= _('A version of ') %> "<%= based_on.title %>" <%= based_on.title.downcase.include?(_('template')) ? '' : _('template') %><%= _(' that has been customised by ') %> <%= plan.template.org.name %>.
    <% else %>
      <%= _('The')%> "<%= plan.template.title %>" <%= (plan.template.is_default ? _('generic template') : plan.template.title.downcase.include?(_('template')) ? '' : _('template')) %> <%= _(' provided by ') %><%= plan.template.org.name %>.
    <% end %>
  </p>

  <div class="div_clear"></div>

  <!-- If project has phases-->
  <% phases = plan.template.phases %>
    <% if phases.count == 1 %>
      <div class="project_description">
        <%= raw plan.template.description %>
      </div>
      <% phases.each do |phase| %>
        <div class="move_2_right">
          <%= link_to _('Answer questions'), edit_plan_phase_path(plan,phase), :class => 'btn btn-primary'  %>
          <a href="#<%= phases[0].id %>-export-dialog" data-toggle="modal" class='btn btn-primary'><%= _('Export') %></a>
        </div>
        <%= render :partial => "plans/export", locals: {plan: plan, phase: phases[0] } %>
        <div class="div_clear"></div>
        <p><%= raw phase.description %></p>
        <% if phase.sections.any? %>
          <table class="dmp_table">
            <thead>
                <tr>
                    <th class="dmp_th_medium"><%= _('Sections')%></th>
                    <th class="dmp_th_big"><%= _('Questions')%></th>
                 </tr>
               </thead>
               <tbody>
                 <% phase.sections.each do |section| %>
                <tr >
                  <th class="dmp_th_border" >
                    <p><%= section.title %></p>
                  </th>
                  <td class="dmp_td_border" >
                    <% if section.questions.any? %>
                      <ul class="question_ul">
                        <% section.questions.each do |ques|%>
                          <li>
                            <%= raw ques.text %>
                          </li>
                        <%end%>
                      </ul>
                    <%end%>
                  </td>
                </tr>
              <%end%>
            </tbody>
          </table>
        <%end%> <!-- end of if phase.sections.any? -->
      <%end%> <!-- end of phases.each do |phase| -->
    <%else%>   <!-- phases.count > 1 -->
      <div class="project_description">
        <%= raw plan.template.description %>
      </div>
      <% phases.each do |phase| %>
        <div class="accordion" id="project-accordion">
          <div class="accordion-group">
            <div class="accordion-heading">
              <a class="accordion-toggle" data-toggle="collapse" data-parent="#project-accordion" href="#<%= phase.id %>">
                <h3><%= phase.title %><span class="plus-laranja"> </span></h3>
              </a>
            </div>
            <div id="<%= phase.id %>" class="accordion-project collapse">
              <div class="accordion-inner">
                <div class="div_right">
                  <%= link_to _('Answer questions'), edit_plan_phase_path(plan,phase), :class => 'btn btn-primary'  %>
                  <a href="#<%= phase.id %>-export-dialog" data-toggle="modal" class='btn btn-primary'><%= _('Export') %></a>
                </div>
                <%= render :partial => "plans/export", locals: {plan: plan, phase: phase} %>
                <div class="div_clear"></div>
                  <p><%= raw phase.description %>
                </p>

                <% if phase.sections.any? %>
                  <table class="dmp_table">
                    <thead>
                        <tr>
                            <th class="dmp_th_medium"><%= _('Sections')%></th>
                            <th class="dmp_th_big"><%= _('Questions')%></th>
                         </tr>
                       </thead>
                       <tbody>
                         <% phase.sections.each do |section| %>
                        <tr >
                          <th class="dmp_th_border" >
                            <p><%= section.title %></p>
                          </th>
                          <td class="dmp_td_border" >
                            <% if section.questions.any? %>
                              <ul class="question_ul">
                                <% section.questions.each do |ques|%>
                                  <li>
                                    - <%= raw ques.text %>
                                  </li>
                                <%end%>
                              </ul>
                            <%end%>
                          </td>
                        </tr>
                      <%end%>
                    </tbody>
                  </table>
                <%end%> <!-- end of if phase.sections.any? -->
              </div>
            </div>
          </div>
        </div>
      <%end%><!-- end of phases.each
    <%end%> <!-- end of if phases.count == 1 -->
</div>