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.
38 lines
1.1 KiB
Plaintext
38 lines
1.1 KiB
Plaintext
<%= tag.table options do %>
|
|
<thead>
|
|
<tr>
|
|
<th><%= t("admin.poll_officers.officer.name") %></th>
|
|
<th><%= t("admin.poll_officers.officer.email") %></th>
|
|
<th><%= t("admin.actions.actions") %></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% officers.each do |officer| %>
|
|
<tr>
|
|
<td>
|
|
<%= officer.name %>
|
|
</td>
|
|
<td>
|
|
<%= officer.email %>
|
|
</td>
|
|
<td>
|
|
<% if officer.persisted? %>
|
|
<%= render Admin::TableActionsComponent.new(officer,
|
|
actions: [:destroy],
|
|
destroy_text: t("admin.poll_officers.officer.delete"),
|
|
destroy_options: { class: "destroy-officer-link" }
|
|
) %>
|
|
<% else %>
|
|
<%= render Admin::TableActionsComponent.new(officer, actions: []) do |actions| %>
|
|
<%= actions.action(:create_officer,
|
|
text: t("admin.poll_officers.officer.add"),
|
|
path: add_user_path(officer),
|
|
method: :post) %>
|
|
<% end %>
|
|
<% end %>
|
|
</td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
<% end %>
|