Allow additional links in table actions component
This way we'll be able to make these links consistent.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
<%= content %>
|
||||
|
||||
<% if actions.include?(:edit) %>
|
||||
<%= link_to edit_text, edit_path, edit_options %>
|
||||
<% end %>
|
||||
|
||||
@@ -30,14 +30,17 @@
|
||||
</td>
|
||||
<td>
|
||||
<% if admin_notification.draft? %>
|
||||
<%= render Admin::TableActionsComponent.new(admin_notification) %>
|
||||
<%= link_to t("admin.admin_notifications.index.preview"),
|
||||
admin_admin_notification_path(admin_notification),
|
||||
class: "button" %>
|
||||
<%= render Admin::TableActionsComponent.new(admin_notification) do |actions| %>
|
||||
<%= actions.link_to t("admin.admin_notifications.index.preview"),
|
||||
admin_admin_notification_path(admin_notification),
|
||||
class: "button" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to t("admin.admin_notifications.index.view"),
|
||||
admin_admin_notification_path(admin_notification),
|
||||
class: "button" %>
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<%= actions.link_to t("admin.admin_notifications.index.view"),
|
||||
admin_admin_notification_path(admin_notification),
|
||||
class: "button" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -34,9 +34,11 @@
|
||||
<%= audit.user&.name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("shared.show"),
|
||||
admin_polymorphic_path(audit),
|
||||
class: "button hollow primary" %>
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<%= actions.link_to t("shared.show"),
|
||||
admin_polymorphic_path(audit),
|
||||
class: "button hollow primary" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
<th><%= t("admin.budget_groups.name") %></th>
|
||||
<th><%= Budget::Group.human_attribute_name(:max_votable_headings) %></th>
|
||||
<th><%= t("admin.budget_groups.headings_name") %></th>
|
||||
<th><%= t("admin.budget_groups.headings_edit") %></th>
|
||||
<th><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -26,10 +25,11 @@
|
||||
<td><%= link_to group.name, edit_admin_budget_group_path(@budget, group) %></td>
|
||||
<td><%= group.max_votable_headings %></td>
|
||||
<td><%= group.headings.count %></td>
|
||||
<td><%= link_to t("admin.budget_groups.headings_manage"),
|
||||
admin_budget_group_headings_path(@budget, group) %></td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(group) %>
|
||||
<%= render Admin::TableActionsComponent.new(group) do |actions| %>
|
||||
<%= actions.link_to t("admin.budget_groups.headings_manage"),
|
||||
admin_budget_group_headings_path(@budget, group) %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -14,10 +14,7 @@
|
||||
<tr>
|
||||
<th><%= t("admin.budgets.index.table_name") %></th>
|
||||
<th><%= t("admin.budgets.index.table_phase") %></th>
|
||||
<th><%= t("admin.budgets.index.table_investments") %></th>
|
||||
<th><%= t("admin.budgets.index.table_edit_groups") %></th>
|
||||
<th><%= t("admin.budgets.index.table_edit_budget") %></th>
|
||||
<th><%= t("admin.budgets.index.table_admin_ballots") %></th>
|
||||
<th><%= t("admin.actions.actions") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -30,21 +27,16 @@
|
||||
<%= t("budgets.phase.#{budget.phase}") %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("admin.budgets.index.budget_investments"),
|
||||
admin_budget_budget_investments_path(budget_id: budget.id),
|
||||
class: "button hollow medium" %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= link_to t("admin.budgets.index.edit_groups"), admin_budget_groups_path(budget) %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<%= link_to t("admin.budgets.index.edit_budget"), edit_admin_budget_path(budget) %>
|
||||
</td>
|
||||
<td class="small">
|
||||
<% if budget.poll.present? %>
|
||||
<%= link_to t("admin.budgets.index.admin_ballots"), admin_poll_booth_assignments_path(budget.poll) %>
|
||||
<% else %>
|
||||
<%= link_to_create_budget_poll(budget) %>
|
||||
<%= render Admin::TableActionsComponent.new(budget, actions: [:edit], edit_text: t("admin.budgets.index.edit_budget")) do |actions| %>
|
||||
<%= actions.link_to t("admin.budgets.index.budget_investments"),
|
||||
admin_budget_budget_investments_path(budget_id: budget.id),
|
||||
class: "button hollow medium" %>
|
||||
<%= actions.link_to t("admin.budgets.index.edit_groups"), admin_budget_groups_path(budget) %>
|
||||
<% if budget.poll.present? %>
|
||||
<%= actions.link_to t("admin.budgets.index.admin_ballots"), admin_poll_booth_assignments_path(budget.poll) %>
|
||||
<% else %>
|
||||
<%= link_to_create_budget_poll(budget) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -29,10 +29,11 @@
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(newsletter) %>
|
||||
|
||||
<%= link_to t("admin.newsletters.index.preview"), admin_newsletter_path(newsletter),
|
||||
class: "button" %>
|
||||
<%= render Admin::TableActionsComponent.new(newsletter) do |actions| %>
|
||||
<%= actions.link_to t("admin.newsletters.index.preview"),
|
||||
admin_newsletter_path(newsletter),
|
||||
class: "button" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -25,11 +25,15 @@
|
||||
<span class="disabled"><%= t("admin.booth_assignments.manage.status.unassigned") %></span>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("admin.booth_assignments.manage.actions.assign"),
|
||||
admin_poll_booth_assignments_path(@poll, booth_id: booth.id),
|
||||
method: :post,
|
||||
remote: true,
|
||||
title: t("admin.booth_assignments.manage.actions.assign"),
|
||||
class: "button hollow expanded" if !@poll.expired? %>
|
||||
<% unless @poll.expired? %>
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<%= actions.link_to t("admin.booth_assignments.manage.actions.assign"),
|
||||
admin_poll_booth_assignments_path(@poll, booth_id: booth.id),
|
||||
method: :post,
|
||||
remote: true,
|
||||
title: t("admin.booth_assignments.manage.actions.assign"),
|
||||
class: "button hollow expanded" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
|
||||
@@ -7,9 +7,11 @@
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<% if controller_name == "shifts" || controller_name == "booths" && action_name == "available" %>
|
||||
<%= link_to t("admin.booths.booth.shifts"),
|
||||
new_admin_booth_shift_path(booth),
|
||||
class: "button hollow" %>
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<%= actions.link_to t("admin.booths.booth.shifts"),
|
||||
new_admin_booth_shift_path(booth),
|
||||
class: "button hollow" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render Admin::TableActionsComponent.new(booth,
|
||||
actions: [:edit],
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
destroy_text: t("admin.poll_officers.officer.delete")
|
||||
) %>
|
||||
<% else %>
|
||||
<%= link_to t("admin.poll_officers.officer.add"), { controller: "admin/poll/officers", action: :create, user_id: officer.user_id },
|
||||
method: :post,
|
||||
class: "button success expanded" %>
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<%= actions.link_to t("admin.poll_officers.officer.add"), { controller: "admin/poll/officers", action: :create, user_id: officer.user_id },
|
||||
method: :post,
|
||||
class: "button success expanded" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -35,11 +35,13 @@
|
||||
destroy_text: t("admin.poll_officers.officer.delete")
|
||||
) %>
|
||||
<% else %>
|
||||
<%= link_to t("admin.poll_officers.officer.add"),
|
||||
{ controller: "admin/poll/officers", action: :create,
|
||||
user_id: officer.user_id },
|
||||
method: :post,
|
||||
class: "button success expanded" %>
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<%= actions.link_to t("admin.poll_officers.officer.add"),
|
||||
{ controller: "admin/poll/officers", action: :create,
|
||||
user_id: officer.user_id },
|
||||
method: :post,
|
||||
class: "button success expanded" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(poll,
|
||||
destroy_confirmation: t("admin.polls.destroy.alert")
|
||||
) %>
|
||||
<%= link_to t("admin.actions.configure"),
|
||||
admin_poll_path(poll),
|
||||
class: "button hollow " %>
|
||||
) do |actions| %>
|
||||
<%= actions.link_to t("admin.actions.configure"),
|
||||
admin_poll_path(poll),
|
||||
class: "button hollow " %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -30,9 +30,10 @@
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("admin.polls.show.edit_answers"), admin_question_path(question),
|
||||
class: "button hollow" %>
|
||||
<%= render Admin::TableActionsComponent.new(question) %>
|
||||
<%= render Admin::TableActionsComponent.new(question) do |actions| %>
|
||||
<%= actions.link_to t("admin.polls.show.edit_answers"), admin_question_path(question),
|
||||
class: "button hollow" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<thead>
|
||||
<th class="medium-6"><%= t("admin.polls.index.name") %></th>
|
||||
<th><%= t("admin.polls.index.dates") %></th>
|
||||
<th class="text-right"><%= t("admin.actions.actions") %></th>
|
||||
<th><%= t("admin.actions.actions") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @polls.each do |poll| %>
|
||||
@@ -16,10 +16,12 @@
|
||||
<td>
|
||||
<%= l poll.starts_at.to_date %> - <%= l poll.ends_at.to_date %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<%= link_to t("admin.booth_assignments.manage_assignments"),
|
||||
manage_admin_poll_booth_assignments_path(poll),
|
||||
class: "button hollow" %>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<%= actions.link_to t("admin.booth_assignments.manage_assignments"),
|
||||
manage_admin_poll_booth_assignments_path(poll),
|
||||
class: "button hollow" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to t("admin.questions.index.create_question"),
|
||||
new_admin_question_path(proposal_id: proposal.id),
|
||||
class: "button hollow" %>
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<%= actions.link_to t("admin.questions.index.create_question"),
|
||||
new_admin_question_path(proposal_id: proposal.id),
|
||||
class: "button hollow" %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -36,16 +36,17 @@
|
||||
<%= link_to document.title, document.attachment.url %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<%= link_to t("documents.buttons.download_document"),
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow",
|
||||
class: "button hollow" %>
|
||||
|
||||
<%= render Admin::TableActionsComponent.new(document,
|
||||
actions: [:destroy],
|
||||
destroy_path: document_path(document)
|
||||
) %>
|
||||
) do |actions| %>
|
||||
<%= actions.link_to t("documents.buttons.download_document"),
|
||||
document.attachment.url,
|
||||
target: "_blank",
|
||||
rel: "nofollow",
|
||||
class: "button hollow" %>
|
||||
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -35,17 +35,17 @@
|
||||
<td><%= I18n.l page.created_at, format: :short %></td>
|
||||
<td><%= t("admin.site_customization.pages.page.status_#{page.status}") %></td>
|
||||
<td>
|
||||
<% if page.status == "published" %>
|
||||
<%= link_to t("admin.site_customization.pages.index.see_page"),
|
||||
page.url,
|
||||
target: "_blank",
|
||||
class: "button hollow" %>
|
||||
<% end %>
|
||||
|
||||
<%= render Admin::TableActionsComponent.new(page,
|
||||
actions: [:destroy],
|
||||
destroy_text: t("admin.site_customization.pages.index.delete")
|
||||
) %>
|
||||
) do |actions| %>
|
||||
<% if page.status == "published" %>
|
||||
<%= actions.link_to t("admin.site_customization.pages.index.see_page"),
|
||||
page.url,
|
||||
target: "_blank",
|
||||
class: "button hollow" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -18,32 +18,29 @@
|
||||
<%= t("admin.system_emails.#{system_email_title}.description") %>
|
||||
</td>
|
||||
<td>
|
||||
<% if system_email_actions.include?("view") %>
|
||||
<div class="small-4 column">
|
||||
<%= link_to t("admin.shared.view"), admin_system_email_view_path(system_email_title),
|
||||
class: "button hollow expanded" %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if system_email_actions.include?("preview_pending") %>
|
||||
<div class="small-4 column">
|
||||
<%= link_to t("admin.system_emails.preview_pending.action"),
|
||||
admin_system_email_preview_pending_path(system_email_title),
|
||||
class: "button expanded" %>
|
||||
</div>
|
||||
<div class="small-4 column">
|
||||
<%= link_to t("admin.system_emails.preview_pending.send_pending"),
|
||||
admin_system_email_send_pending_path(system_email_title),
|
||||
class: "button success expanded",
|
||||
method: :put %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if system_email_actions.include?("edit_info") %>
|
||||
<div class="small-8 column">
|
||||
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
|
||||
<% if system_email_actions.include?("view") %>
|
||||
<%= actions.link_to t("admin.shared.view"),
|
||||
admin_system_email_view_path(system_email_title),
|
||||
class: "button hollow" %>
|
||||
<% end %>
|
||||
|
||||
<% if system_email_actions.include?("preview_pending") %>
|
||||
<%= actions.link_to t("admin.system_emails.preview_pending.action"),
|
||||
admin_system_email_preview_pending_path(system_email_title),
|
||||
class: "button" %>
|
||||
<%= actions.link_to t("admin.system_emails.preview_pending.send_pending"),
|
||||
admin_system_email_send_pending_path(system_email_title),
|
||||
class: "button success",
|
||||
method: :put %>
|
||||
<% end %>
|
||||
|
||||
<% if system_email_actions.include?("edit_info") %>
|
||||
<p class="help-text">
|
||||
<%= t("admin.system_emails.edit_info") %><br>
|
||||
<code><%= "app/views/mailer/#{system_email_title}.html.erb" %></code>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -72,10 +72,6 @@ en:
|
||||
budget_investments: Manage projects
|
||||
table_name: Name
|
||||
table_phase: Phase
|
||||
table_investments: Investments
|
||||
table_edit_groups: Headings groups
|
||||
table_edit_budget: Edit
|
||||
table_admin_ballots: Ballots
|
||||
edit_groups: Edit headings groups
|
||||
edit_budget: Edit budget
|
||||
admin_ballots: Admin ballots
|
||||
@@ -117,7 +113,6 @@ en:
|
||||
budget_groups:
|
||||
name: "Name"
|
||||
headings_name: "Headings"
|
||||
headings_edit: "Edit Headings"
|
||||
headings_manage: "Manage headings"
|
||||
no_groups: "There are no groups."
|
||||
amount:
|
||||
|
||||
@@ -72,10 +72,6 @@ es:
|
||||
budget_investments: Gestionar proyectos de gasto
|
||||
table_name: Nombre
|
||||
table_phase: Fase
|
||||
table_investments: Proyectos de gasto
|
||||
table_edit_groups: Grupos de partidas
|
||||
table_edit_budget: Editar
|
||||
table_admin_ballots: Urnas
|
||||
edit_groups: Editar grupos de partidas
|
||||
edit_budget: Editar presupuesto
|
||||
admin_ballots: Gestionar urnas
|
||||
@@ -117,7 +113,6 @@ es:
|
||||
budget_groups:
|
||||
name: "Nombre"
|
||||
headings_name: "Partidas"
|
||||
headings_edit: "Editar Partidas"
|
||||
headings_manage: "Gestionar partidas"
|
||||
no_groups: "No hay grupos."
|
||||
amount:
|
||||
|
||||
@@ -54,4 +54,15 @@ describe Admin::TableActionsComponent, type: :component do
|
||||
|
||||
expect(page).to have_css "a#edit_me"
|
||||
end
|
||||
|
||||
it "allows custom content" do
|
||||
render_inline Admin::TableActionsComponent.new(record) do
|
||||
"<a href='/'>Main</a>".html_safe
|
||||
end
|
||||
|
||||
expect(page).to have_css "a", count: 3
|
||||
expect(page).to have_link "Main", href: "/"
|
||||
expect(page).to have_link "Edit"
|
||||
expect(page).to have_link "Delete"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user