Use semantic HTML classes in table actions

Note the CSS could probably be improved to avoid duplication with other
button style definitions. However, that's fine because we're going to
change the style of the links soon.

For the same reason, I haven't bothered to style every single link the
way it was until now.
This commit is contained in:
Javi Martín
2020-07-01 19:09:22 +02:00
parent ccb7695056
commit 8c1140a1bf
32 changed files with 79 additions and 56 deletions

View File

@@ -9,4 +9,17 @@
> p {
align-self: flex-start;
}
a {
@include button($style: hollow);
border-color: $link !important;
color: $link !important;
font-size: $base-font-size;
margin-bottom: 0;
&.destroy-link {
border-color: $alert-color !important;
color: $alert-color !important;
}
}
}

View File

@@ -1,10 +1,14 @@
<%= render Admin::TableActionsComponent.new(budget, actions: [:edit], edit_text: t("admin.budgets.index.edit_budget")) do %>
<%= link_to t("admin.budgets.index.budget_investments"),
admin_budget_budget_investments_path(budget_id: budget.id),
class: "button hollow medium" %>
<%= link_to t("admin.budgets.index.edit_groups"), admin_budget_groups_path(budget) %>
class: "investments-link" %>
<%= link_to t("admin.budgets.index.edit_groups"),
admin_budget_groups_path(budget),
class: "groups-link" %>
<% if budget.poll.present? %>
<%= link_to t("admin.budgets.index.admin_ballots"), admin_poll_booth_assignments_path(budget.poll) %>
<%= link_to t("admin.budgets.index.admin_ballots"),
admin_poll_booth_assignments_path(budget.poll),
class: "ballots-link" %>
<% else %>
<%= link_to_create_budget_poll %>
<% end %>

View File

@@ -16,7 +16,9 @@ class Admin::Budgets::TableActionsComponent < ApplicationComponent
name: budget.name,
budget_id: budget.id,
starts_at: balloting_phase.starts_at,
ends_at: balloting_phase.ends_at }),
ends_at: balloting_phase.ends_at
}),
class: "ballots-link",
method: :post
end
end

View File

@@ -2,11 +2,11 @@
<%= link_to restore_text, restore_path,
method: :put,
data: { confirm: t("admin.actions.confirm") },
class: "button hollow warning" %>
class: "restore-link" %>
<% unless record.confirmed_hide? %>
<%= link_to confirm_hide_text, confirm_hide_path,
method: :put,
class: "button" %>
class: "confirm-hide-link" %>
<% end %>
<% end %>

View File

@@ -2,12 +2,12 @@
<% if can_verify? %>
<%= link_to t("admin.organizations.index.verify"),
verify_admin_organization_path(organization, request.query_parameters),
method: :put, class: "button success small-5" %>
method: :put, class: "verify-link" %>
<% end %>
<% if can_reject? %>
<%= link_to t("admin.organizations.index.reject"),
reject_admin_organization_path(organization, request.query_parameters),
method: :put, class: "button hollow alert small-5" %>
method: :put, class: "reject-link" %>
<% end %>
<% end %>

View File

@@ -3,7 +3,7 @@
<tr>
<th><%= t("admin.poll_officers.officer.name") %></th>
<th><%= t("admin.poll_officers.officer.email") %></th>
<th class="small-3"><%= t("admin.actions.actions") %></th>
<th><%= t("admin.actions.actions") %></th>
</tr>
</thead>
<tbody>
@@ -19,14 +19,15 @@
<% if officer.persisted? %>
<%= render Admin::TableActionsComponent.new(officer,
actions: [:destroy],
destroy_text: t("admin.poll_officers.officer.delete")
destroy_text: t("admin.poll_officers.officer.delete"),
destroy_options: { class: "destroy-officer-link" }
) %>
<% else %>
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
<%= actions.link_to t("admin.poll_officers.officer.add"),
add_user_path(officer),
method: :post,
class: "button success expanded" %>
class: "create-officer-link" %>
<% end %>
<% end %>
</td>

View File

@@ -1,7 +1,10 @@
<% if already_has_role? %>
<%= render Admin::TableActionsComponent.new(record, actions: actions) %>
<%= render Admin::TableActionsComponent.new(record,
actions: actions,
destroy_options: { class: "destroy-role-link" }
) %>
<% else %>
<%= render Admin::TableActionsComponent.new(actions: []) do %>
<%= link_to add_user_text, add_user_path, method: :post, class: "button success expanded" %>
<%= link_to add_user_text, add_user_path, method: :post, class: "create-role-link" %>
<% end %>
<% end %>

View File

@@ -22,7 +22,7 @@ class Admin::TableActionsComponent < ApplicationComponent
end
def edit_options
{ class: "button hollow" }.merge(options[:edit_options] || {})
{ class: "edit-link" }.merge(options[:edit_options] || {})
end
def destroy_text
@@ -36,7 +36,7 @@ class Admin::TableActionsComponent < ApplicationComponent
def destroy_options
{
method: :delete,
class: "button hollow alert",
class: "destroy-link",
data: { confirm: destroy_confirmation }
}.merge(options[:destroy_options] || {})
end

View File

@@ -9,7 +9,7 @@
<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 class="small-5"><%= t("admin.admin_notifications.index.actions") %></th>
<th><%= t("admin.admin_notifications.index.actions") %></th>
</tr>
</thead>
<tbody>
@@ -33,13 +33,13 @@
<%= 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" %>
class: "preview-link" %>
<% end %>
<% else %>
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
<%= actions.link_to t("admin.admin_notifications.index.view"),
admin_admin_notification_path(admin_notification),
class: "button" %>
class: "show-link" %>
<% end %>
<% end %>
</td>

View File

@@ -10,7 +10,7 @@
<thead>
<th scope="col"><%= t("admin.administrators.index.name") %></th>
<th scope="col"><%= t("admin.administrators.index.email") %></th>
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
<th scope="col"><%= t("admin.shared.actions") %></th>
</thead>
<tbody>
<% @users.each do |user| %>

View File

@@ -37,7 +37,7 @@
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
<%= actions.link_to t("shared.show"),
admin_polymorphic_path(audit),
class: "button hollow primary" %>
class: "show-link" %>
<% end %>
</td>
</tr>

View File

@@ -13,7 +13,7 @@
<tr id="<%= dom_id(banner) %>">
<th scope="col"><%= Banner.human_attribute_name(:post_started_at) %></th>
<th scope="col"><%= Banner.human_attribute_name(:post_ended_at) %></th>
<th scope="col" class="small-4"><%= t("admin.actions.actions") %></th>
<th scope="col"><%= t("admin.actions.actions") %></th>
</tr>
</thead>
<tbody>

View File

@@ -28,7 +28,8 @@
<td>
<%= render Admin::TableActionsComponent.new(group) do |actions| %>
<%= actions.link_to t("admin.budget_groups.headings_manage"),
admin_budget_group_headings_path(@budget, group) %>
admin_budget_group_headings_path(@budget, group),
class: "headings-link" %>
<% end %>
</td>
</tr>

View File

@@ -17,7 +17,7 @@
<th class="text-center"><%= t("admin.dashboard.actions.index.day_offset") %></th>
<th class="text-center"><%= t("admin.dashboard.actions.index.required_supports") %></th>
<th class="text-center"><%= t("admin.dashboard.actions.index.order") %></th>
<th class="small-3"><%= t("admin.actions.actions") %></th>
<th><%= t("admin.actions.actions") %></th>
</tr>
</thead>

View File

@@ -10,7 +10,7 @@
<th><%= t("admin.geozones.geozone.external_code") %></th>
<th><%= t("admin.geozones.geozone.census_code") %></th>
<th><%= t("admin.geozones.geozone.coordinates") %></th>
<th class="small-3"><%= t("admin.actions.actions") %></th>
<th><%= t("admin.actions.actions") %></th>
</tr>
</thead>

View File

@@ -10,7 +10,7 @@
<thead>
<th scope="col"><%= t("admin.managers.index.name") %></th>
<th scope="col"><%= t("admin.managers.index.email") %></th>
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
<th scope="col"><%= t("admin.shared.actions") %></th>
</thead>
<tbody>
<% @users.each do |user| %>

View File

@@ -53,7 +53,7 @@
<% end %>
<% end %>
</td>
<td class="small-2">
<td>
<%= render Admin::TableActionsComponent.new(milestone,
destroy_text: t("admin.milestones.index.delete")
) %>

View File

@@ -10,7 +10,7 @@
<thead>
<th scope="col"><%= t("admin.moderators.index.name") %></th>
<th scope="col" class="small-6"><%= t("admin.moderators.index.email") %></th>
<th scope="col" class="small-3"><%= t("admin.shared.actions") %></th>
<th scope="col"><%= t("admin.shared.actions") %></th>
</thead>
<tbody>
<% @users.each do |user| %>

View File

@@ -9,7 +9,7 @@
<th class="small-2"><%= t("admin.newsletters.index.subject") %></th>
<th><%= t("admin.newsletters.index.segment_recipient") %></th>
<th><%= t("admin.newsletters.index.sent") %></th>
<th class="small-5"><%= t("admin.newsletters.index.actions") %></th>
<th><%= t("admin.newsletters.index.actions") %></th>
</tr>
</thead>
<tbody>
@@ -32,7 +32,7 @@
<%= render Admin::TableActionsComponent.new(newsletter) do |actions| %>
<%= actions.link_to t("admin.newsletters.index.preview"),
admin_newsletter_path(newsletter),
class: "button" %>
class: "preview-link" %>
<% end %>
</td>
</tr>

View File

@@ -31,8 +31,7 @@
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" %>
class: "assign-booth-link" %>
<% end %>
<% end %>
</td>

View File

@@ -10,7 +10,7 @@
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
<%= actions.link_to t("admin.booths.booth.shifts"),
new_admin_booth_shift_path(booth),
class: "button hollow" %>
class: "shifts-link" %>
<% end %>
<% else %>
<%= render Admin::TableActionsComponent.new(booth,

View File

@@ -14,7 +14,7 @@
) do |actions| %>
<%= actions.link_to t("admin.actions.configure"),
admin_poll_path(poll),
class: "button hollow " %>
class: "configure-link" %>
<% end %>
</td>
</tr>

View File

@@ -8,11 +8,11 @@
<%= t("admin.polls.show.no_questions") %>
</div>
<% else %>
<table class="fixed margin">
<table class="margin">
<thead>
<tr>
<th><%= t("admin.polls.show.table_title") %></th>
<th class="small-6"><%= t("admin.actions.actions") %></th>
<th><%= t("admin.actions.actions") %></th>
</tr>
</thead>
<% @poll.questions.each do |question| %>
@@ -30,7 +30,7 @@
<td>
<%= render Admin::TableActionsComponent.new(question) do |actions| %>
<%= actions.link_to t("admin.polls.show.edit_answers"), admin_question_path(question),
class: "button hollow" %>
class: "answers-link" %>
<% end %>
</td>
</tr>

View File

@@ -18,7 +18,7 @@
<%= 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" %>
class: "manage-link" %>
<% end %>
</td>
</tr>

View File

@@ -7,12 +7,12 @@
<%= t("admin.questions.index.no_questions") %>
</div>
<% else %>
<table class="fixed">
<table>
<thead>
<tr>
<th><%= t("admin.questions.index.table_question") %></th>
<th><%= t("admin.questions.index.table_poll") %></th>
<th class="small-4"><%= t("admin.actions.actions") %></th>
<th><%= t("admin.actions.actions") %></th>
</tr>
</thead>
<tbody>
@@ -29,7 +29,7 @@
<td>
<%= render Admin::TableActionsComponent.new(question) do |actions| %>
<%= actions.link_to t("admin.polls.show.edit_answers"), admin_question_path(question),
class: "button hollow" %>
class: "answers-link" %>
<% end %>
</td>
</tr>

View File

@@ -1,4 +1,4 @@
<table class="fixed">
<table>
<thead>
<tr>
<th class="small-9"><%= t("admin.questions.index.table_proposal") %></th>
@@ -16,10 +16,10 @@
</td>
<td>
<%= render Admin::TableActionsComponent.new(actions: []) do |actions| %>
<%= actions.link_to t("admin.shared.view"), proposal_path(proposal), class: "button hollow" %>
<%= actions.link_to t("admin.shared.view"), proposal_path(proposal), class: "show-link" %>
<%= actions.link_to t("admin.questions.index.create_question"),
new_admin_question_path(proposal_id: proposal.id),
class: "button hollow" %>
class: "new-link" %>
<% end %>
</td>
</tr>

View File

@@ -44,7 +44,7 @@
document.attachment.url,
target: "_blank",
rel: "nofollow",
class: "button hollow" %>
class: "download-link" %>
<% end %>
</td>

View File

@@ -1,5 +1,5 @@
<h3><%= t("admin.poll_shifts.new.shifts") %></h3>
<table class="fixed">
<table>
<thead>
<tr>
<th><%= t("admin.poll_shifts.new.date") %></th>

View File

@@ -16,7 +16,7 @@
<th><%= t("admin.site_customization.pages.page.created_at") %></th>
<th><%= t("admin.site_customization.pages.page.updated_at") %></th>
<th><%= t("admin.site_customization.pages.page.status") %></th>
<th class="small-4"><%= t("admin.actions.actions") %></th>
<th><%= t("admin.actions.actions") %></th>
</tr>
</thead>
<tbody>
@@ -31,13 +31,13 @@
<%= render Admin::TableActionsComponent.new(page) do |actions| %>
<%= actions.link_to t("admin.site_customization.pages.page.see_cards"),
admin_site_customization_page_cards_path(page),
class: "button hollow expanded" %>
class: "cards-link" %>
<% if page.status == "published" %>
<%= actions.link_to t("admin.site_customization.pages.index.see_page"),
page.url,
target: "_blank",
class: "button hollow" %>
class: "show-link" %>
<% end %>
<% end %>
</td>

View File

@@ -22,16 +22,16 @@
<% if system_email_actions.include?("view") %>
<%= actions.link_to t("admin.shared.view"),
admin_system_email_view_path(system_email_title),
class: "button hollow" %>
class: "show-link" %>
<% 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" %>
class: "preview-pending-link" %>
<%= actions.link_to t("admin.system_emails.preview_pending.send_pending"),
admin_system_email_send_pending_path(system_email_title),
class: "button success",
class: "send-pending-link",
method: :put %>
<% end %>

View File

@@ -22,7 +22,7 @@
<%= render Admin::TableActionsComponent.new(valuator) do |actions| %>
<%= actions.link_to t("admin.shared.view"),
admin_valuator_path(valuator),
class: "button hollow" %>
class: "show-link" %>
<% end %>
</td>
</tr>

View File

@@ -5,7 +5,7 @@
<th scope="col"><%= t("admin.valuators.index.description") %></th>
<th scope="col"><%= t("admin.valuators.index.group") %></th>
<th scope="col"><%= t("admin.valuators.index.abilities") %></th>
<th scope="col" class="small-3"><%= t("admin.actions.actions") %></th>
<th scope="col"><%= t("admin.actions.actions") %></th>
</thead>
<tbody>
<% valuators.each do |valuator| %>