<!-- Display of phase, sections and its questions. A phase is passed as an argument -->
<div class="row">
<div class="col-md-12">
<p class="text-justify">
<%= raw phase.description %>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="pull-right">
<%= link_to _('Show Phase'), admin_show_phase_path(id: phase.id), { class: "btn btn-default", role: 'button' } %>
<% if template == current && phase.modifiable %>
<%= link_to _('Delete'), admin_destroy_phase_path(phase_id: phase.id), {
confirm: _("You are about to delete '%{phase_title}'. This will affect versions, sections and questions linked to this phase. Are you sure?") % { phase_title: phase.title },
method: :delete,
class: "btn btn-default", role: "button" }
%>
<% end %>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<% if phase_hash[:sections].length > 0 %>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th><%= _('Sections')%></th>
<th><%= _('Questions')%></th>
</tr>
</thead>
<tbody>
<% (phase_hash[:sections].values.sort_by { |key| key[:data][:number] }).each do |section| %>
<tr>
<td>
<p><%= section[:data].title %></p>
</td>
<td>
<% if section[:questions].present? %>
<ul>
<% (section[:questions].values.sort_by { |key| key[:data][:number] }).each do |question| %>
<li><%= raw question[:data].text %></li>
<% end %>
</ul>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>
</div>