Merge pull request #5896 from consuldemocracy/link_names

Add missing text to links with no text
This commit is contained in:
Javi Martín
2025-04-02 16:48:58 +02:00
committed by GitHub
22 changed files with 130 additions and 114 deletions

View File

@@ -39,14 +39,13 @@
e.stopPropagation();
$("#user_password").val(App.Managers.generatePassword());
});
$(".show-password").on("click", function(e) {
e.preventDefault();
e.stopPropagation();
$(".show-password").on("click", function() {
if ($("#user_password").is("input[type='password']")) {
App.Managers.togglePassword("text");
} else {
App.Managers.togglePassword("password");
}
$(this).attr("aria-pressed", !JSON.parse($(this).attr("aria-pressed")));
});
}
};

View File

@@ -139,24 +139,23 @@
}
}
.icon-check {
display: inline-block;
font-size: rem-calc(24);
form {
display: inline;
vertical-align: top;
button {
font-size: 1.5em;
}
}
.checked-link {
@include has-fa-icon(check, solid);
color: $color-success;
}
.unchecked-link {
display: inline-block;
vertical-align: top;
}
.unchecked {
border: 1px solid $border;
border-radius: rem-calc(4);
display: inline-block;
height: rem-calc(20);
margin-top: calc($line-height / 6);
width: rem-calc(20);
@include has-fa-icon(square, regular);
color: $dark-gray;
}
}

View File

@@ -596,12 +596,6 @@
border-bottom: 1px solid $border;
margin-bottom: rem-calc(16);
padding-bottom: rem-calc(8);
a .icon-expand {
color: #838383;
float: right;
font-size: $small-font-size;
}
}
.comments-wrapper {

View File

@@ -1,5 +1,11 @@
.management-account-edit-password-manually {
[type=password] {
[type=password],
[type=text] {
margin-bottom: 0 !important;
}
.show-password {
@include has-fa-icon(eye, regular);
cursor: pointer;
}
}

View File

@@ -10,7 +10,9 @@
<div class="input-group">
<%= f.password_field :password, class: "input-group-field", label: false, value: nil %>
<span class="input-group-label">
<a href="#" class="show-password"><span class="icon-eye"></span></a>
<button type="button" class="show-password" aria-pressed="false">
<span class="show-for-sr"><%= t("management.account.edit.password.show") %></span>
</button>
</span>
</div>

View File

@@ -1,5 +1,3 @@
<% if banner %>
<div class="banner" style="background-color:<%= banner.background_color %>;">
<%= sanitize link, attributes: %w[href style] %>
</div>
<% end %>

View File

@@ -13,6 +13,10 @@ class Shared::BannerComponent < ApplicationComponent
end
end
def render?
banner && (banner.title.present? || banner.description.present?)
end
private
def link

View File

@@ -46,6 +46,7 @@ class Legislation::Process < ApplicationRecord
validates_translation :title, presence: true
validates :start_date, presence: true
validates :end_date, presence: true
validates :result_publication_date, presence: true, if: :result_publication_enabled?
%i[draft debate proposals_phase allegations].each do |phase_name|
enabled_attribute = :"#{phase_name.to_s.gsub("_phase", "")}_phase_enabled?"

View File

@@ -1,18 +1,18 @@
<div id="<%= dom_id(proposed_action) %>">
<div class="action">
<% if proposed_action.proposals.where(id: proposal.id).any? %>
<%= link_to unexecute_proposal_dashboard_action_path(proposal, proposed_action),
id: "#{dom_id(proposed_action)}_unexecute",
method: :post,
<%= button_to unexecute_proposal_dashboard_action_path(proposal, proposed_action),
class: "checked-link" do %>
<span class="icon-check"></span>
<span class="show-for-sr">
<%= t("dashboard.recommended_actions.unexecute", name: proposed_action.title) %>
</span>
<% end %>
<% else %>
<%= link_to execute_proposal_dashboard_action_path(proposal, proposed_action),
id: "#{dom_id(proposed_action)}_execute",
method: :post,
<%= button_to execute_proposal_dashboard_action_path(proposal, proposed_action),
class: "unchecked-link" do %>
<span class="unchecked"></span>
<span class="show-for-sr">
<%= t("dashboard.recommended_actions.execute", name: proposed_action.title) %>
</span>
<% end %>
<% end %>
<div class="action-content">

View File

@@ -1,3 +0,0 @@
<%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation, sub_annotation_ids: "") do %>
<span class="icon-expand" aria-hidden="true"></span>
<% end %>

View File

@@ -1,5 +1,8 @@
<%= render Shared::CommentsCountComponent.new(annotation.comments.roots.count) %>
<span id="annotation-link" data-sub-annotation-ids="8">
<%= render "annotation_link", annotation: annotation %>
<%= render Shared::CommentsCountComponent.new(
annotation.comments.roots.count,
url: legislation_process_draft_version_annotation_path(
annotation.draft_version.process, annotation.draft_version, annotation, sub_annotation_ids: ""
)
) %>
</span>

View File

@@ -14,11 +14,11 @@ if ($(".comment").length == 0) {
$("#annotation-link a").attr("href", new_annotation_link)
var current_comment_text = $(".comments-count").text()
var current_comment_text = $("#annotation-link a").text()
var current_comment_count = current_comment_text.match(/\d+/)[0]
var new_comment_count = parseInt(current_comment_count) + parseInt(<%= @annotation.comments.roots.count %>)
var new_comment_count_text = current_comment_text.replace(/(\d+)/, new_comment_count);
$(".comments-count").text(new_comment_count_text)
$("#annotation-link a").text(new_comment_count_text)
}
<%= render "comments_box_form", comment: @comment, annotation: @annotation %>

View File

@@ -475,6 +475,8 @@ en:
see_proposed_actions: Check out recommended actions
hide_proposed_actions: Hide recommended actions
pending_title: Pending
execute: "Mark %{name} as done"
unexecute: "Unmark %{name} as done"
show_description: Show description
without_pending_actions: No recommended actions pending
done_title: Done

View File

@@ -18,6 +18,7 @@ en:
reseted: Password reseted successfully
random: Generate random password
save: Save password
show: Show password
print: Print password
print_help: You will be able to print the password when it is saved.
account_info:

View File

@@ -475,6 +475,8 @@ es:
see_proposed_actions: Ver todas las acciones recomendadas
hide_proposed_actions: Ocultar acciones recomendadas
pending_title: Pendientes
execute: "Marcar la acción %{name} como realizada"
unexecute: "Desmarcar la acción %{name} como realizada"
show_description: Mostrar descripción
without_pending_actions: No hay acciones recomendadas pendientes
done_title: Realizadas

View File

@@ -18,6 +18,7 @@ es:
reseted: Contraseña restablecida correctamente
random: Generar contraseña aleatoria
save: Guardar contraseña
show: Mostrar contraseña
print: Imprimir contraseña
print_help: Podrás imprimir la contraseña cuando se haya guardado.
account_info:

View File

@@ -31,6 +31,14 @@ describe Shared::BannerComponent do
expect(page).not_to have_content "Proposal banner"
end
it "does not render an empty banner" do
banner = build(:banner, title: "", description: "")
render_inline Shared::BannerComponent.new(banner)
expect(page).not_to be_rendered
end
context "several banners available in the same section" do
before do
create(:banner,

View File

@@ -154,6 +154,21 @@ describe Legislation::Process do
expect(proposals_disabled).to be_valid
expect(allegations_disabled).to be_valid
end
it "is invalid if result publication is enabled but result_publication_date is not present" do
process = build(:legislation_process, result_publication_enabled: true, result_publication_date: "")
expect(process).not_to be_valid
expect(process.errors.messages[:result_publication_date]).to include("can't be blank")
end
it "is valid if result publication is enabled and result_publication_date is present" do
process = build(:legislation_process,
result_publication_enabled: true,
result_publication_date: Date.tomorrow)
expect(process).to be_valid
end
end
describe "date ranges validations" do

View File

@@ -35,13 +35,12 @@ describe "Commenting legislation annotations" do
end
scenario "View comments of annotations in an included range" do
within("#annotation-link") do
find(".icon-expand").click
end
click_link "2 comment"
expect(page).to have_css(".comment", count: 2)
expect(page).to have_content("my annotation")
expect(page).to have_content("my other annotation")
expect(page).to have_content "Comments about"
expect(page).to have_css ".comment", count: 2
expect(page).to have_content "my annotation"
expect(page).to have_content "my other annotation"
end
scenario "Reply on a single annotation thread and display it in the merged annotation thread" do
@@ -70,20 +69,16 @@ describe "Commenting legislation annotations" do
expect(page).to have_content "my other annotation"
end
within("#annotation-link") do
find(".icon-expand").click
end
click_link "2 comment"
expect(page).to have_css(".comment", count: 3)
expect(page).to have_content("my annotation")
expect(page).to have_content("my other annotation")
expect(page).to have_content("replying in single annotation thread")
expect(page).to have_css ".comment", count: 3
expect(page).to have_content "my annotation"
expect(page).to have_content "my other annotation"
expect(page).to have_content "replying in single annotation thread"
end
scenario "Reply on a multiple annotation thread and display it in the single annotation thread" do
within("#annotation-link") do
find(".icon-expand").click
end
click_link "2 comment"
within("#comment_#{comment2.id}") do
click_link "Reply"

View File

@@ -47,14 +47,6 @@ describe "Proposal's dashboard" do
end
end
scenario "Dashboard progress show proposed actions" do
action = create(:dashboard_action, :proposed_action, :active)
visit progress_proposal_dashboard_path(proposal)
expect(page).to have_content(action.title)
end
scenario "Dashboard progress show proposed actions truncated description" do
action = create(:dashboard_action, :proposed_action, :active, description: "One short action")
action_long = create(:dashboard_action, :proposed_action, :active,
@@ -100,45 +92,42 @@ describe "Proposal's dashboard" do
end
scenario "Dashboard progress display proposed_action pending on his section" do
action = create(:dashboard_action, :proposed_action, :active)
create(:dashboard_action, :proposed_action, :active, title: "Expand!")
visit progress_proposal_dashboard_path(proposal)
within "#proposed_actions_pending" do
expect(page).to have_content(action.title)
end
expect(page).to have_content "Expand!"
end
scenario "Dashboard progress display proposed_action done on his section" do
action = create(:dashboard_action, :proposed_action, :active)
visit progress_proposal_dashboard_path(proposal)
find(:css, "#dashboard_action_#{action.id}_execute").click
click_button "Mark Expand! as done"
within "#proposed_actions_done" do
expect(page).to have_content(action.title)
end
expect(page).to have_content "Expand!"
end
scenario "Dashboard progress can execute proposed action" do
action = create(:dashboard_action, :proposed_action, :active)
visit progress_proposal_dashboard_path(proposal)
expect(page).to have_content(action.title)
find(:css, "#dashboard_action_#{action.id}_execute").click
expect(page).not_to have_css "#dashboard_action_#{action.id}_execute"
expect(page).not_to have_button "Mark Expand! as done"
expect(page).to have_button "Unmark Expand! as done"
end
scenario "Dashboard progress can unexecute proposed action" do
action = create(:dashboard_action, :proposed_action, :active)
action = create(:dashboard_action, :proposed_action, :active, title: "Reinforce!")
create(:dashboard_executed_action, proposal: proposal, action: action)
visit progress_proposal_dashboard_path(proposal)
expect(page).to have_content(action.title)
find(:css, "#dashboard_action_#{action.id}_unexecute").click
expect(page).to have_css "#dashboard_action_#{action.id}_execute"
within "#proposed_actions_done" do
expect(page).to have_content "Reinforce!"
end
click_button "Unmark Reinforce! as done"
within "#proposed_actions_pending" do
expect(page).to have_content "Reinforce!"
end
expect(page).not_to have_button "Unmark Reinforce! as done"
expect(page).to have_button "Mark Reinforce! as done"
end
scenario "Dashboard progress dont show proposed actions with published_proposal: true" do
@@ -472,10 +461,10 @@ describe "Proposal's dashboard" do
end
scenario "On recommended actions section display proposed_action done on his section" do
action = create(:dashboard_action, :proposed_action, :active)
action = create(:dashboard_action, :proposed_action, :active, title: "Make progress")
visit recommended_actions_proposal_dashboard_path(proposal.to_param)
find(:css, "#dashboard_action_#{action.id}_execute").click
click_button "Mark Make progress as done"
within "#proposed_actions_done" do
expect(page).to have_content(action.title)

View File

@@ -22,6 +22,7 @@ describe "Legislation" do
scenario "empty process" do
process = create(:legislation_process, :empty,
result_publication_enabled: true,
result_publication_date: 1.day.ago,
end_date: Date.current - 1.day)
visit summary_legislation_process_path(process)

View File

@@ -27,18 +27,20 @@ describe "Account" do
expect(email).to have_text "Change your password"
end
scenario "Manager changes the password by hand (writen by them)" do
scenario "Manager manually writes the new password" do
user = create(:user, :level_three)
login_managed_user(user)
login_as_manager
click_link "Reset password manually"
find(:css, "input[id$='user_password']").set("new_password")
fill_in "Password", with: "new_password"
click_button "Save password"
expect(page).to have_content "Password reseted successfully"
expect(page).to have_link "Print password", href: "javascript:window.print();"
expect(page).to have_css "div.for-print-only", text: "new_password", visible: :hidden
logout
@@ -57,6 +59,19 @@ describe "Account" do
new_password = find_field("user_password").value
expect(page).to have_field "Password", type: :password
expect(page).to have_css "button[aria-pressed=false]", exact_text: "Show password"
click_button "Show password"
expect(page).to have_field "Password", type: :text
expect(page).to have_css "button[aria-pressed=true]", exact_text: "Show password"
click_button "Show password"
expect(page).to have_field "Password", type: :password
expect(page).to have_css "button[aria-pressed=false]", exact_text: "Show password"
click_button "Save password"
expect(page).to have_content "Password reseted successfully"
@@ -68,22 +83,6 @@ describe "Account" do
expect(page).to have_content "You have been signed in successfully."
end
scenario "The password is printed" do
user = create(:user, :level_three)
login_managed_user(user)
login_as_manager
click_link "Reset password manually"
find(:css, "input[id$='user_password']").set("another_new_password")
click_button "Save password"
expect(page).to have_content "Password reseted successfully"
expect(page).to have_link "Print password", href: "javascript:window.print();"
expect(page).to have_css("div.for-print-only", text: "another_new_password", visible: :hidden)
end
describe "When a user has not been selected" do
before do
Setting["feature.user.skip_verification"] = "true"