app/views/noticeboards/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">Schwarzes Brett</h1>
</div>
<div class="table-responsive pb-4">
<table class="table data_table bg-white">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Titel</th>
<th scope="col" class="nosort">Inhalt</th>
<th scope="col">Kategorie</th>
<th scope="col">Nachrichten</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>
<% @noticeboards.each do |noticeboard| %>
<tr>
<th scope="row"><%= noticeboard.id %></th>
<td>
<%= noticeboard.content_blocks.first.try(:title) || "" %>
</td>
<td>
<%= link_to(
(noticeboard.content_blocks.first.try(:body) || "").truncate(30),
"#",
data: { toggle: "modal", target: "#content_#{noticeboard.id}" }
) %>
<%= render(
partial: "noticeboards/modal_content",
locals: { noticeboard: noticeboard }
) %>
</td>
<td><%= noticeboard.categories.first.try(:name) || "" %></td>
<td><%= noticeboard.generic_item_messages.count %></td>
<td data-sort="<%= to_unix_timestamp(noticeboard.dates.try(:first).try(:date_start)) %>">
<%= to_local_date(noticeboard.dates.try(:first).try(:date_start)) %>
</td>
<td data-sort="<%= to_unix_timestamp(noticeboard.dates.try(:first).try(:date_end)) %>">
<%= to_local_date(noticeboard.dates.try(:first).try(:date_end)) %>
</td>
<td data-sort="<%= DateTime.parse(noticeboard.updated_at).to_i %>">
<%= to_local_date_time(noticeboard.updated_at) %>
</td>
<td data-sort="<%= DateTime.parse(noticeboard.created_at).to_i %>">
<%= to_local_date_time(noticeboard.created_at) %>
</td>
<% if editor? || extended_user? %>
<td><%= noticeboard.data_provider.try(:name) %></td>
<% end %>
<% if editor? %>
<td align="center"><%= visibility_switch(noticeboard, "Noticeboard") %></td>
<% end %>
<td align="right" class="text-nowrap">
<%= link_to noticeboard_path(noticeboard.id), method: :delete, "data-confirm" => "Diesen Eintrag wirklich löschen?", class: "btn btn-sm btn-danger", title: "Löschen" do %>
<i class="fas fa-trash"></i>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>