Files
grecia/app/views/admin/admin_notifications/index.html.erb
Javi Martín 6a2c01b119 Extract method to render an admin table action
This way it will be easier to change the behavior of all table actions,
like adding ARIA attributes. In the past, when we changed the behavior
of the `link_to` method, we had to change all table action classes.
2021-09-20 20:27:37 +02:00

51 lines
2.0 KiB
Plaintext

<h2 class="inline-block"><%= t("admin.admin_notifications.index.section_title") %></h2>
<%= link_to t("admin.admin_notifications.index.new_notification"), new_admin_admin_notification_path,
class: "button float-right" %>
<% if @admin_notifications.any? %>
<table id="admin_notifications">
<thead>
<tr>
<th><%= t("admin.admin_notifications.index.title") %></th>
<th><%= t("admin.admin_notifications.index.segment_recipient") %></th>
<th><%= t("admin.admin_notifications.index.sent") %></th>
<th><%= t("admin.admin_notifications.index.actions") %></th>
</tr>
</thead>
<tbody>
<% @admin_notifications.order(created_at: :desc).each do |admin_notification| %>
<tr id="<%= dom_id(admin_notification) %>" class="admin_notification">
<td>
<%= admin_notification.title %>
</td>
<td>
<%= segment_name(admin_notification.segment_recipient) %>
</td>
<td>
<% if admin_notification.draft? %>
<%= t("admin.admin_notifications.index.draft") %>
<% else %>
<%= l admin_notification.sent_at.to_date %>
<% end %>
</td>
<td>
<% if admin_notification.draft? %>
<%= render Admin::TableActionsComponent.new(admin_notification) do |actions| %>
<%= actions.action(:preview, text: t("admin.admin_notifications.index.preview")) %>
<% end %>
<% else %>
<%= render Admin::TableActionsComponent.new(admin_notification, actions: []) do |actions| %>
<%= actions.action(:show, text: t("admin.admin_notifications.index.view")) %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<div data-alert class="callout primary margin-top clear">
<%= t("admin.admin_notifications.index.empty_notifications") %>
</div>
<% end %>