<%= stylesheet_link_tag "admin" %>
<% javascript "admin.js" %>
<h1>
<%= _('Guidance group list') %>
</h1>
<div class="div_left">
<%= raw _("<p>First create a guidance group. This could be institution wide or a subset e.g. a particular College / School, Institute or department. When you create guidance you'll be asked to assign it to a guidance group.</p>")%>
</div>
<div class="div_right">
<div class="move_2_right">
<%= link_to _('Add guidance group'), admin_new_guidance_group_path(), class: "btn btn-primary" %>
</div>
</div>
<!-- List of guidance groups -->
<% if @guidance_groups.length > 0 then%>
<table id="dmp_table_2" class="dmp_table tablesorter">
<thead>
<tr>
<th class="dmp_th_medium"><%= _('Name') %></th>
<th class="dmp_th_small"><%= _('Published') %></th>
<th class="dmp_th_small"><%= _('Optional subset') %></th>
<th class="dmp_th_small"><%= _('Last updated') %></th>
<td class="dmp_th_medium"><%= _('Actions') %></td>
</tr>
</thead>
<tbody>
<% !@guidance_groups.each do |guidance_gr| %>
<tr>
<td class="dmp_td_medium">
<%= guidance_gr.name %>
</td>
<td class="dmp_td_small">
<% if guidance_gr.published.nil? || guidance_gr.published == false then%>
<%= _('No')%>
<% else %>
<%= _('Yes')%>
<% end %>
</td>
<td class="dmp_td_small">
<% if guidance_gr.optional_subset.nil? || guidance_gr.optional_subset == false then%>
<%= _('No')%>
<% else %>
<%= _('Yes')%>
<% end %>
</td>
<td class="dmp_td_small">
<%= l guidance_gr.updated_at.to_date, formats: :short %>
</td>
<td class="dmp_td_medium">
<%= link_to _('View'), admin_show_guidance_group_path(guidance_gr), class: "dmp_table_link"%><br/>
<%= link_to _('Edit'), admin_edit_guidance_group_path(guidance_gr), class: "dmp_table_link"%><br/>
<%= link_to _('Delete'), admin_destroy_guidance_group_path(guidance_gr), data: {confirm: _("You are about to delete '%{guidance_group_name}'. This will affect guidance. Are you sure?") % { :guidance_group_name => guidance_gr.name }}, method: :delete, class: "dmp_table_link"%>
</td>
</tr>
<% end %>
</tbody>
</table>
<%end%>
<br/>
<div class="div_clear"></div>
<h1>
<%= _('Guidance list') %>
</h1>
<div class="div_left">
<%= raw _('<p>You can write pieces of guidance to be displayed by theme (e.g. generic guidance on storage and backup that should present across the board) or you can write guidance for specific questions. Writing generic guidance by theme saves you time and effort as your advice will be automatically displayed across all templates rather than having to write guidance to accompany each.</p> <p>You will usually want your guidance to display on all templates, however there may be cases where you only want it to show for specific funders e.g. if you have specific instructions for applicants to BBSRC for example. This can be set too if needed.</p>')%>
</div>
<div class="div_right">
<!-- link button to add new guidance -->
<div class="move_2_right">
<%= link_to _('Add guidance'),
admin_new_guidance_path(),
class: "btn btn-primary" %>
</div>
</div>
<div class="div_clear"></div>
<!-- List of guidance -->
<% if @guidances.length > 0 then%>
<table id="dmp_table" class="dmp_table tablesorter">
<thead>
<tr>
<th class="dmp_th_big"><%= _('Text') %></th>
<th class="dmp_th_small"><%= _('Themes') %></th>
<th class="dmp_th_small"><%= _('Question') %></th>
<th class="dmp_th_small"><%= _('Guidance group') %></th>
<th class="dmp_th_small"><%= _('Last updated') %></th>
<td class="dmp_th_medium"><%= _('Actions') %></td>
</tr>
</thead>
<tbody>
<% @guidances.each do |guidance| %>
<% if guidance.in_group_belonging_to?(current_user.org_id) then %>
<tr>
<td class="dmp_td_big">
<%= guidance.text.html_safe%>
</td>
<% if guidance.themes.present? then %>
<td class="dmp_td_small">
<% guidance.themes.each do |th| %>
<%= th.title %>
<% end %>
</td>
<% else %>
<td class="dmp_td_small">
-
</td>
<% end %>
<% if !guidance.question_id.nil? then %>
<td class="dmp_td_small">
<%= raw guidance.question.text.truncate(70, omission: _('... (continued)')) %>
</td>
<% else %>
<td class="dmp_td_small">
-
</td>
<% end %>
<% if guidance.guidance_group.present? then %>
<td class="dmp_td_small">
<%= guidance.guidance_group.name %>
</td>
<% else %>
<td class="dmp_td_small">
-
</td>
<% end %>
<td class="dmp_td_small">
<%= l guidance.updated_at.to_date, formats: :short %>
</td>
<td class="dmp_td_medium">
<%= link_to _('View'), admin_show_guidance_path(guidance), class: "dmp_table_link"%><br/>
<%= link_to _('Edit'), admin_edit_guidance_path(guidance), class: "dmp_table_link"%><br/>
<%= link_to _('Delete'), admin_destroy_guidance_path(guidance),
data: {confirm: _("You are about to delete '%{guidance_summary}'. Are you sure?") % { :guidance_summary => truncate(sanitize(guidance.text,tags: %w(br a)), length: 20 , omission: _('... (continued)'))} }, method: :delete, class: "dmp_table_link"%>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% end %>