diff --git a/app/assets/javascripts/managers.js b/app/assets/javascripts/managers.js index 78774bb29..2926c8e0a 100644 --- a/app/assets/javascripts/managers.js +++ b/app/assets/javascripts/managers.js @@ -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"))); }); } }; diff --git a/app/assets/stylesheets/dashboard.scss b/app/assets/stylesheets/dashboard.scss index 5bc379bee..4c819c306 100644 --- a/app/assets/stylesheets/dashboard.scss +++ b/app/assets/stylesheets/dashboard.scss @@ -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; } } diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index 5e7f78fc7..b752d3688 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -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 { diff --git a/app/assets/stylesheets/management/account/edit_password_manually.scss b/app/assets/stylesheets/management/account/edit_password_manually.scss index 581fd2579..21c1b4900 100644 --- a/app/assets/stylesheets/management/account/edit_password_manually.scss +++ b/app/assets/stylesheets/management/account/edit_password_manually.scss @@ -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; + } } diff --git a/app/components/management/account/edit_password_manually_component.html.erb b/app/components/management/account/edit_password_manually_component.html.erb index 484974695..497145ec2 100644 --- a/app/components/management/account/edit_password_manually_component.html.erb +++ b/app/components/management/account/edit_password_manually_component.html.erb @@ -10,7 +10,9 @@
<%= f.password_field :password, class: "input-group-field", label: false, value: nil %> - +
diff --git a/app/components/shared/banner_component.html.erb b/app/components/shared/banner_component.html.erb index fe020302a..cbea18d0e 100644 --- a/app/components/shared/banner_component.html.erb +++ b/app/components/shared/banner_component.html.erb @@ -1,5 +1,3 @@ -<% if banner %> - -<% end %> + diff --git a/app/components/shared/banner_component.rb b/app/components/shared/banner_component.rb index de61e1602..21aba7c65 100644 --- a/app/components/shared/banner_component.rb +++ b/app/components/shared/banner_component.rb @@ -13,6 +13,10 @@ class Shared::BannerComponent < ApplicationComponent end end + def render? + banner && (banner.title.present? || banner.description.present?) + end + private def link diff --git a/app/models/legislation/process.rb b/app/models/legislation/process.rb index f59ddf377..d4cf5284f 100644 --- a/app/models/legislation/process.rb +++ b/app/models/legislation/process.rb @@ -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?" diff --git a/app/views/dashboard/_proposed_action.html.erb b/app/views/dashboard/_proposed_action.html.erb index 082ddf0ed..1a351829c 100644 --- a/app/views/dashboard/_proposed_action.html.erb +++ b/app/views/dashboard/_proposed_action.html.erb @@ -1,18 +1,18 @@
<% 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, - class: "checked-link" do %> - + <%= button_to unexecute_proposal_dashboard_action_path(proposal, proposed_action), + class: "checked-link" do %> + + <%= t("dashboard.recommended_actions.unexecute", name: proposed_action.title) %> + <% end %> <% else %> - <%= link_to execute_proposal_dashboard_action_path(proposal, proposed_action), - id: "#{dom_id(proposed_action)}_execute", - method: :post, - class: "unchecked-link" do %> - + <%= button_to execute_proposal_dashboard_action_path(proposal, proposed_action), + class: "unchecked-link" do %> + + <%= t("dashboard.recommended_actions.execute", name: proposed_action.title) %> + <% end %> <% end %>
diff --git a/app/views/legislation/annotations/_annotation_link.html.erb b/app/views/legislation/annotations/_annotation_link.html.erb deleted file mode 100644 index b047f52cb..000000000 --- a/app/views/legislation/annotations/_annotation_link.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<%= link_to legislation_process_draft_version_annotation_path(annotation.draft_version.process, annotation.draft_version, annotation, sub_annotation_ids: "") do %> - -<% end %> diff --git a/app/views/legislation/annotations/_comment_header.html.erb b/app/views/legislation/annotations/_comment_header.html.erb index f767cf7a3..80d55cdb9 100644 --- a/app/views/legislation/annotations/_comment_header.html.erb +++ b/app/views/legislation/annotations/_comment_header.html.erb @@ -1,5 +1,8 @@ -<%= render Shared::CommentsCountComponent.new(annotation.comments.roots.count) %> - - <%= 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: "" + ) + ) %> diff --git a/app/views/legislation/annotations/comments.js.erb b/app/views/legislation/annotations/comments.js.erb index 1e0985217..46550b8cd 100644 --- a/app/views/legislation/annotations/comments.js.erb +++ b/app/views/legislation/annotations/comments.js.erb @@ -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 %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 4ee75c137..163091a05 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -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 diff --git a/config/locales/en/management.yml b/config/locales/en/management.yml index 3cf7506a3..06e9ab967 100644 --- a/config/locales/en/management.yml +++ b/config/locales/en/management.yml @@ -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: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 458f437a8..1b803c460 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -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 diff --git a/config/locales/es/management.yml b/config/locales/es/management.yml index 895268f16..e7510f6cc 100644 --- a/config/locales/es/management.yml +++ b/config/locales/es/management.yml @@ -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: diff --git a/spec/components/shared/banner_component_spec.rb b/spec/components/shared/banner_component_spec.rb index 6d2512373..403a45e9d 100644 --- a/spec/components/shared/banner_component_spec.rb +++ b/spec/components/shared/banner_component_spec.rb @@ -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, diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb index 5b62b98f4..511e5aa62 100644 --- a/spec/models/legislation/process_spec.rb +++ b/spec/models/legislation/process_spec.rb @@ -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 diff --git a/spec/system/comments/legislation_annotations_spec.rb b/spec/system/comments/legislation_annotations_spec.rb index 22d169430..d547d282e 100644 --- a/spec/system/comments/legislation_annotations_spec.rb +++ b/spec/system/comments/legislation_annotations_spec.rb @@ -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" diff --git a/spec/system/dashboard/dashboard_spec.rb b/spec/system/dashboard/dashboard_spec.rb index aaf7cfb28..b318c1dc7 100644 --- a/spec/system/dashboard/dashboard_spec.rb +++ b/spec/system/dashboard/dashboard_spec.rb @@ -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) + expect(page).to have_content "Expand!" end - 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) + expect(page).to have_content "Expand!" end - 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) diff --git a/spec/system/legislation/summary_spec.rb b/spec/system/legislation/summary_spec.rb index 36c9ffe28..a521d0827 100644 --- a/spec/system/legislation/summary_spec.rb +++ b/spec/system/legislation/summary_spec.rb @@ -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) diff --git a/spec/system/management/account_spec.rb b/spec/system/management/account_spec.rb index 9350137db..100c3502c 100644 --- a/spec/system/management/account_spec.rb +++ b/spec/system/management/account_spec.rb @@ -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"