Add votable name to agree/disagree links aria-label

This commit is contained in:
Javi Martín
2021-09-30 01:37:06 +02:00
parent 704687dc54
commit 413a77bd98
6 changed files with 27 additions and 2 deletions

View File

@@ -2,7 +2,11 @@
<div class="in-favor inline-block">
<% if current_user %>
<%= link_to polymorphic_path(votable, action: :vote, value: "yes"),
class: "like #{voted_classes[:in_favor]}", title: t("votes.agree"), method: "post", remote: true do %>
class: "like #{voted_classes[:in_favor]}",
title: t("votes.agree"),
"aria-label": agree_aria_label,
method: "post",
remote: true do %>
<span class="icon-like">
<span class="show-for-sr"><%= t("votes.agree") %></span>
</span>
@@ -22,7 +26,12 @@
<div class="against inline-block">
<% if current_user %>
<%= link_to polymorphic_path(votable, action: :vote, value: "no"), class: "unlike #{voted_classes[:against]}", title: t("votes.disagree"), method: "post", remote: true do %>
<%= link_to polymorphic_path(votable, action: :vote, value: "no"),
class: "unlike #{voted_classes[:against]}",
title: t("votes.disagree"),
"aria-label": disagree_aria_label,
method: "post",
remote: true do %>
<span class="icon-unlike">
<span class="show-for-sr"><%= t("votes.disagree") %></span>
</span>

View File

@@ -22,4 +22,12 @@ class Shared::InFavorAgainstComponent < ApplicationComponent
{ in_favor: "", against: "" }
end
end
def agree_aria_label
t("votes.agree_label", title: votable.title)
end
def disagree_aria_label
t("votes.disagree_label", title: votable.title)
end
end

View File

@@ -847,9 +847,11 @@ en:
retired_help_text: Dashboard not available for retired proposals
votes:
agree: I agree
agree_label: "I agree with %{title}"
anonymous: Too many anonymous votes to admit vote %{verify_account}.
comment_unauthenticated: You must %{signin} or %{signup} to vote.
disagree: I disagree
disagree_label: "I don't agree with %{title}"
organizations: Organizations are not permitted to vote
supports: Supports
verified_only: Only verified users can vote on proposals; %{verify_account}.

View File

@@ -847,9 +847,11 @@ es:
retired_help_text: Dashboard no disponible para propuestas retiradas
votes:
agree: Estoy de acuerdo
agree_label: "Estoy de acuerdo con %{title}"
anonymous: Demasiados votos anónimos, para poder votar %{verify_account}.
comment_unauthenticated: Necesitas %{signin} o %{signup} para poder votar.
disagree: No estoy de acuerdo
disagree_label: "No estoy de acuerdo con %{title}"
organizations: Las organizaciones no pueden votar.
supports: Apoyos
verified_only: Las propuestas sólo pueden ser votadas por usuarios verificados, %{verify_account}.

View File

@@ -22,7 +22,9 @@ describe Debates::VotesComponent do
expect(page).to have_link count: 2
expect(page).to have_link "I agree", title: "I agree"
expect(page).to have_link "I agree with What about the 2030 agenda?"
expect(page).to have_link "I disagree", title: "I disagree"
expect(page).to have_link "I don't agree with What about the 2030 agenda?"
expect(page).not_to have_content "You must sign in or sign up to continue."
end
end

View File

@@ -35,7 +35,9 @@ describe Legislation::Proposals::VotesComponent do
expect(page).to have_link count: 2
expect(page).to have_link "I agree", title: "I agree"
expect(page).to have_link "I agree with Require wearing masks at home"
expect(page).to have_link "I disagree", title: "I disagree"
expect(page).to have_link "I don't agree with Require wearing masks at home"
expect(page).not_to have_content "You must sign in or sign up to continue."
end
end