app/views/surveys/index.html.erb
<div class="d-flex flex-wrap align-items-center row-gap justify-content-between mb-5">
<h1 class="h3 mb-0 pb-0 font-weight-bold mr-3">Umfragen</h1>
<%= link_to new_survey_path, class: "btn btn-sm btn-primary shadow-sm" do %>
<i class="fas fa-plus fa-sm text-white-50"></i>
Neue Umfrage erstellen
<% end %>
</div>
<div class="table-responsive pb-4">
<table class="table data_table bg-white">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Frage</th>
<th scope="col">Kommentare</th>
<th scope="col">Startdatum</th>
<th scope="col">Enddatum</th>
<th scope="col">Änderungsdatum</th>
<th scope="col">Erstellungsdatum</th>
<% if editor? || extended_user? %>
<th>Datenquelle</th>
<% end %>
<% if editor? %>
<th scope="col" class="nosort">Sichtbarkeit</th>
<% end %>
<th scope="col" class="nosort">Aktionen</th>
</tr>
</thead>
<tbody>
<% @surveys.each do |survey| %>
<tr>
<th scope="row"><%= survey.id %></th>
<td><%= link_to i18n_json_to_text(survey.question_title), edit_survey_path(survey.id) %></td>
<td>
<%# link to survey counts table if there are any %>
<%= !survey.can_comment ? "-" : survey.comments.count.zero? ?
survey.comments.count :
(link_to survey.comments.count, survey_comments_path(survey.id)) %>
</td>
<td data-sort="<%= to_unix_timestamp(survey.date.try(:date_start)) %>">
<%= to_local_date(survey.date.try(:date_start)) %>
</td>
<td data-sort="<%= to_unix_timestamp(survey.date.try(:date_end)) %>">
<%= to_local_date(survey.date.try(:date_end)) %>
</td>
<td data-sort="<%= DateTime.parse(survey.updated_at).to_i %>">
<%= to_local_date_time(survey.updated_at) %>
</td>
<td data-sort="<%= DateTime.parse(survey.updated_at).to_i %>">
<%= to_local_date_time(survey.created_at) %>
</td>
<% if editor? || extended_user? %>
<td><%= survey.data_provider.name %></td>
<% end %>
<% if editor? %>
<td align="center"><%= visibility_switch(survey, "Survey") %></td>
<% end %>
<td align="right" class="text-nowrap">
<%= link_to "Bearbeiten", edit_survey_path(survey.id), class: "btn btn-sm btn-secondary" %>
<%= link_to(
survey_path(survey.id),
method: :delete,
"data-confirm" => "Möchten Sie diese Umfrage wirklich löschen? Damit werden auch alle zugehörigen Kommentare und Stimmabgaben gelöscht.",
class: "btn btn-sm btn-danger",
title: "Löschen"
) do %>
<i class="fas fa-trash"></i>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>