<div class="table-responsive">
<table class="table table-hover" id="guidances">
<thead>
<tr>
<th scope="col"><%= _('Text') %> <%= paginable_sort_link('guidances.text') %></th>
<th scope="col"><%= _('Themes') %></th>
<th scope="col"><%= _('Guidance group') %> <%= paginable_sort_link('guidance_groups.name') %></th>
<th scope="col"><%= _('Status') %> <%= paginable_sort_link('guidances.published') %></th>
<th scope="col" class="date-column"><%= _('Last updated') %> <%= paginable_sort_link('guidances.updated_at') %></th>
<th scope="col" class="sorter-false"><span aria-hidden="false" class="sr-only"><%= _('Actions') %></span></th>
</tr>
</thead>
<tbody>
<% scope.each do |guidance| %>
<% if guidance.in_group_belonging_to?(current_user.org_id) %>
<tr>
<td><%= guidance.text.html_safe %></td>
<% if guidance.themes.present? %>
<td>
<% guidance.themes.each do |th| %>
<%= th.title %>
<% end %>
</td>
<% else %>
<td>-</td>
<% end %>
<% if guidance.guidance_group.present? %>
<td><%= guidance.guidance_group.name %></td>
<% else %>
<td>-</td>
<% end %>
<td class="text-center">
<% if guidance.published.nil? || guidance.published == false %>
<%= _('Unpublished')%>
<% else %>
<%= _('Published')%>
<% end %>
</td>
<td>
<%= l guidance.updated_at.to_date, formats: :short %>
</td>
<td>
<div class="dropdown">
<button
class="btn btn-link dropdown-toggle"
type="button"
id="guidance-<%= guidance.id %>-actions"
data-toggle="dropdown"
aria-haspopup="true" aria-expanded="true">
<%= _('Actions') %><span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="guidance-<%= guidance.id %>-actions">
<li><%= link_to _('Edit'), admin_edit_guidance_path(guidance) %></li>
<!-- If the guidance has never been published or it has changed -->
<% if guidance.published? %>
<li><%= link_to _('Unpublish'), admin_unpublish_guidance_path(guidance), method: :put %></li>
<% else %>
<li><%= link_to _('Publish'), admin_publish_guidance_path(guidance), method: :put %></li>
<% end %>
<li><%= link_to _('Remove'), 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 %>
</li>
</ul>
</div>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>