From 52e65ba03142e4b71bd517508a665ae0f71432c8 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 1 Jun 2022 18:04:33 +0200 Subject: [PATCH 01/10] Add comments count on budget investments --- app/assets/stylesheets/participation.scss | 1 + app/components/budgets/investments/info_component.html.erb | 5 +++++ app/views/budgets/investments/_investment_detail.erb | 3 +++ config/locales/en/general.yml | 4 ++++ config/locales/es/general.yml | 4 ++++ spec/system/budgets/investments_spec.rb | 7 ++++++- 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index ae47166a1..7efc0f1e8 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -486,6 +486,7 @@ .debate, .proposal, .budget-investment, +.budget-investment-show, .legislation, .communities-show { margin: $line-height / 4 0; diff --git a/app/components/budgets/investments/info_component.html.erb b/app/components/budgets/investments/info_component.html.erb index 91e757cd0..e4f8922d3 100644 --- a/app/components/budgets/investments/info_component.html.erb +++ b/app/components/budgets/investments/info_component.html.erb @@ -1,5 +1,10 @@

<%= l investment.created_at.to_date %> +  •  + +   + <%= link_to t("shared.comments", count: investment.comments_count), + budget_investment_path(investment.budget, investment, anchor: "comments") %> <% if investment.author.hidden? || investment.author.erased? %>  •  diff --git a/app/views/budgets/investments/_investment_detail.erb b/app/views/budgets/investments/_investment_detail.erb index 28b8e8996..987dd3174 100644 --- a/app/views/budgets/investments/_investment_detail.erb +++ b/app/views/budgets/investments/_investment_detail.erb @@ -5,6 +5,9 @@  •  <%= l investment.created_at.to_date %>  •  +   + <%= link_to t("shared.comments", count: investment.comments_count), "#comments" %> +  •  <%= investment.heading.name %>  •  <% if local_assigns[:preview].nil? %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 20c977dc7..db573e42b 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -763,6 +763,10 @@ en: other: "%{count} languages in use" optional: "Optional fields" required: "Required fields" + comments: + one: "1 comment" + other: "%{count} comments" + zero: "No comments" social: facebook: "%{org} Facebook" twitter: "%{org} Twitter" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 8dc487a97..82ea3bbd7 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -763,6 +763,10 @@ es: other: "%{count} idiomas en uso" optional: "Campos opcionales" required: "Campos obligatorios" + comments: + one: "1 comentario" + other: "%{count} comentarios" + zero: "Sin comentarios" social: facebook: "Facebook de %{org}" twitter: "Twitter de %{org}" diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb index b1dd24db1..2395be61c 100644 --- a/spec/system/budgets/investments_spec.rb +++ b/spec/system/budgets/investments_spec.rb @@ -62,7 +62,11 @@ describe "Budget Investments" do investments.each do |investment| within("#budget-investments") do expect(page).to have_content investment.title - expect(page).to have_css("a[href='#{budget_investment_path(budget, id: investment.id)}']", text: investment.title) + expect(page).to have_content investment.comments_count + expect(page).to have_link "No comments", href: budget_investment_path(budget, id: investment.id, + anchor: "comments") + expect(page).to have_link investment.title, href: budget_investment_path(budget, id: investment.id) + expect(page).not_to have_content(unfeasible_investment.title) end end @@ -849,6 +853,7 @@ describe "Budget Investments" do expect(page).to have_content(investment.title) expect(page).to have_content(investment.description) expect(page).to have_content(investment.author.name) + expect(page).to have_content(investment.comments_count) expect(page).to have_content(investment.heading.name) within("#investment_code") do expect(page).to have_content(investment.id) From a32e249919804ba05f4faa62c4c6a0e259b4b3d4 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 21 Jul 2022 18:28:30 +0200 Subject: [PATCH 02/10] Remove   after icon-comments At some other time we will try to remove all the   For now we start with what we added after the comments icon. --- app/assets/stylesheets/layout.scss | 15 +++++++++++++++ .../budgets/investments/info_component.html.erb | 7 ++++--- app/views/admin/debates/show.html.erb | 5 +++-- .../budgets/investments/_investment_detail.erb | 5 +++-- app/views/debates/_debate.html.erb | 6 ++++-- app/views/debates/show.html.erb | 5 +++-- .../legislation/proposals/_proposal.html.erb | 8 +++++--- app/views/legislation/proposals/show.html.erb | 5 +++-- app/views/proposals/_info.html.erb | 5 +++-- app/views/proposals/_proposal.html.erb | 7 ++++--- app/views/topics/_topic.html.erb | 6 ++++-- app/views/topics/show.html.erb | 7 ++++--- 12 files changed, 55 insertions(+), 26 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 0377aa35f..a3cba7263 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2047,6 +2047,21 @@ table { width: 100%; } +.budget-investment-info, +.debate-info, +.investment-project-info, +.proposal-info, +.topic-info { + + .comments-count { + @include has-fa-icon(comments, regular); + + &::before { + margin-right: 0.3rem; + } + } +} + // 16. Flags // --------- diff --git a/app/components/budgets/investments/info_component.html.erb b/app/components/budgets/investments/info_component.html.erb index e4f8922d3..8de99aa8b 100644 --- a/app/components/budgets/investments/info_component.html.erb +++ b/app/components/budgets/investments/info_component.html.erb @@ -2,9 +2,10 @@ <%= l investment.created_at.to_date %>  •  -   - <%= link_to t("shared.comments", count: investment.comments_count), - budget_investment_path(investment.budget, investment, anchor: "comments") %> + + <%= link_to t("shared.comments", count: investment.comments_count), + budget_investment_path(investment.budget, investment, anchor: "comments") %> + <% if investment.author.hidden? || investment.author.erased? %>  •  diff --git a/app/views/admin/debates/show.html.erb b/app/views/admin/debates/show.html.erb index 3319a11cb..bf79aa1c0 100644 --- a/app/views/admin/debates/show.html.erb +++ b/app/views/admin/debates/show.html.erb @@ -17,8 +17,9 @@  •  <%= l @debate.created_at.to_date %>  •  -   - <%= link_to t("debates.show.comments", count: @debate.comments_count), debate_path(@debate, anchor: "comments") %> + + <%= link_to t("debates.show.comments", count: @debate.comments_count), debate_path(@debate, anchor: "comments") %> +  •  <%= render "shared/flag_actions", flaggable: @debate %> diff --git a/app/views/budgets/investments/_investment_detail.erb b/app/views/budgets/investments/_investment_detail.erb index 987dd3174..198387893 100644 --- a/app/views/budgets/investments/_investment_detail.erb +++ b/app/views/budgets/investments/_investment_detail.erb @@ -5,8 +5,9 @@  •  <%= l investment.created_at.to_date %>  •  -   - <%= link_to t("shared.comments", count: investment.comments_count), "#comments" %> + + <%= link_to t("shared.comments", count: investment.comments_count), "#comments" %> +  •  <%= investment.heading.name %>  •  diff --git a/app/views/debates/_debate.html.erb b/app/views/debates/_debate.html.erb index 83f865023..ef0087d8a 100644 --- a/app/views/debates/_debate.html.erb +++ b/app/views/debates/_debate.html.erb @@ -7,8 +7,10 @@

<%= link_to debate.title, debate %>

-   - <%= link_to t("debates.debate.comments", count: debate.comments_count), debate_path(debate, anchor: "comments") %> + + <%= link_to t("debates.debate.comments", count: debate.comments_count), + debate_path(debate, anchor: "comments") %> +  •  <%= l debate.created_at.to_date %> diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index 72fb918e7..c7c62c0df 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -26,8 +26,9 @@  •  <%= l @debate.created_at.to_date %>  •  -   - <%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %> + + <%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %> +  •  <%= render "shared/flag_actions", flaggable: @debate %> diff --git a/app/views/legislation/proposals/_proposal.html.erb b/app/views/legislation/proposals/_proposal.html.erb index 0142be99c..622293702 100644 --- a/app/views/legislation/proposals/_proposal.html.erb +++ b/app/views/legislation/proposals/_proposal.html.erb @@ -19,9 +19,11 @@ <% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>

<%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %>

-   - <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), legislation_process_proposal_path(proposal.legislation_process_id, proposal, anchor: "comments") %> - + + <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), + legislation_process_proposal_path(proposal.legislation_process_id, proposal, + anchor: "comments") %> +  •  <%= l proposal.created_at.to_date %> diff --git a/app/views/legislation/proposals/show.html.erb b/app/views/legislation/proposals/show.html.erb index 91a210d01..cfc953d16 100644 --- a/app/views/legislation/proposals/show.html.erb +++ b/app/views/legislation/proposals/show.html.erb @@ -44,8 +44,9 @@  •  <%= l @proposal.created_at.to_date %>  •  -   - <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> + + <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> + <% if current_user %>  •  diff --git a/app/views/proposals/_info.html.erb b/app/views/proposals/_info.html.erb index 15467348b..ab41e9d98 100644 --- a/app/views/proposals/_info.html.erb +++ b/app/views/proposals/_info.html.erb @@ -6,8 +6,9 @@ <% unless @proposal.selected? %>  •  -   - <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> + + <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> + <% end %> <% if current_user %> diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 0b3c8ec33..3adbe05af 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -21,9 +21,10 @@ <% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>

<%= link_to proposal.title, namespaced_proposal_path(proposal) %>

-   - <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), - namespaced_proposal_path(proposal, anchor: "comments") %> + + <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), + namespaced_proposal_path(proposal, anchor: "comments") %> +  •  <%= l proposal.created_at.to_date %> diff --git a/app/views/topics/_topic.html.erb b/app/views/topics/_topic.html.erb index 4082bf3f7..a2afb656f 100644 --- a/app/views/topics/_topic.html.erb +++ b/app/views/topics/_topic.html.erb @@ -5,8 +5,10 @@

<%= link_to topic.title, community_topic_path(@community, topic) %>

-   - <%= link_to t("community.show.topic.comments", count: topic.comments_count), community_topic_path(@community, topic, anchor: "comments") %> + + <%= link_to t("community.show.topic.comments", count: topic.comments_count), + community_topic_path(@community, topic, anchor: "comments") %> +  •  <%= I18n.l topic.created_at.to_date %>  •  diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 75c4b406b..a20e8815a 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -14,9 +14,10 @@  •  <%= l(@topic.created_at.to_date) %>  •  -   - <%= link_to t("community.show.topic.comments", count: @topic.comments_count), - community_topic_path(@community, @topic, anchor: "comments") %> + + <%= link_to t("community.show.topic.comments", count: @topic.comments_count), + community_topic_path(@community, @topic, anchor: "comments") %> +


<%= @topic.description %>

From 3deba3b189bbc4112d22776aa05782bb7acfa9f3 Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 22 Jul 2022 11:38:22 +0200 Subject: [PATCH 03/10] Unify comment icon on legislation annotation index Apply new structure in the section that shows the comments icon together with the number of comments so that it is easier to unify them into one component. In this case we make only the text clickable and not the icon as in the rest of the application. We're keeping the color and text-decoration so it looks the same way it has looked until now, but we might change it in the future. --- app/assets/stylesheets/layout.scss | 15 +++++++++++++++ app/assets/stylesheets/legislation_process.scss | 9 ++------- app/views/legislation/annotations/index.html.erb | 14 +++++++------- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index a3cba7263..555c19d08 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2050,6 +2050,7 @@ table { .budget-investment-info, .debate-info, .investment-project-info, +.legislation-comments, .proposal-info, .topic-info { @@ -2062,6 +2063,20 @@ table { } } +.legislation-comments { + + .comments-count { + + a { + text-decoration: underline; + } + + &::before { + color: #999; + } + } +} + // 16. Flags // --------- diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index 36a2298d1..6fe6a495d 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -806,13 +806,12 @@ .comment { margin-bottom: rem-calc(48); - a { + .expand-context a { span { text-decoration: underline; } - .icon-expand, - .icon-comments { + .icon-expand { text-decoration: none; color: #999; line-height: 0; @@ -822,10 +821,6 @@ margin-left: rem-calc(4); } - .icon-comments { - margin-right: rem-calc(4); - } - &:active, &:focus, &:hover { diff --git a/app/views/legislation/annotations/index.html.erb b/app/views/legislation/annotations/index.html.erb index 728da47c5..b935f6871 100644 --- a/app/views/legislation/annotations/index.html.erb +++ b/app/views/legislation/annotations/index.html.erb @@ -18,7 +18,7 @@ <% @annotations.each do |annotation| %>
<%= t("legislation.annotations.index.comments_about") %> - + <%= link_to legislation_process_draft_version_path(@process, @draft_version, anchor: "annotation-id-#{annotation.id}") do %> <%= t("legislation.annotations.index.see_in_context") %> @@ -27,12 +27,12 @@
<%= sanitize(annotation.context).presence || annotation.quote %>
- <%= link_to legislation_process_draft_version_annotation_path(@process, @draft_version, annotation) do %> - - - <%= t("legislation.annotations.index.comments_count", count: annotation.comments_count) %> - - <% end %> + + <%= link_to t("legislation.annotations.index.comments_count", count: annotation.comments_count), + legislation_process_draft_version_annotation_path(@process, + @draft_version, + annotation) %> +
<% end %> From 0ca17c6fae2de9c6c25e7580de5615b437aeadf3 Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 22 Jul 2022 11:59:03 +0200 Subject: [PATCH 04/10] Unify comment icon on legislation questions Remove unnecessary span class "debate-comments". We take advantage of this commit to also unify the format of the date that appears next to the comments with the rest of the application. The format that we removed is being used on the same page in the "Participation phases" tab (I guess that was the reason for putting it the same) but I think it makes more sense to use the date format that is used in this kind section in the rest of the application. --- app/assets/stylesheets/layout.scss | 1 + app/assets/stylesheets/legislation_process.scss | 4 ---- app/views/legislation/questions/_question.html.erb | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 555c19d08..d7198a0b4 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2049,6 +2049,7 @@ table { .budget-investment-info, .debate-info, +.debate-meta, .investment-project-info, .legislation-comments, .proposal-info, diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index 6fe6a495d..74658a167 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -153,10 +153,6 @@ .debate-meta a { font-size: $small-font-size; color: #6d6d6d; - - .icon-comments { - margin-right: rem-calc(3); - } } .debate-info { diff --git a/app/views/legislation/questions/_question.html.erb b/app/views/legislation/questions/_question.html.erb index 8ba65f15e..49a92fcba 100644 --- a/app/views/legislation/questions/_question.html.erb +++ b/app/views/legislation/questions/_question.html.erb @@ -6,9 +6,9 @@

<%= link_to question.title, legislation_process_question_path(question.process, question) %>

- + <%= link_to t("legislation.questions.question.comments", count: question.comments.count), legislation_process_question_path(question.process, question) %> - · <%= format_date question.created_at %> + · <%= l question.created_at.to_date %>
From e6f2c5474dfc8e6fcf7c4d3d209bb73633a0478e Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 22 Jul 2022 12:18:05 +0200 Subject: [PATCH 05/10] Unify comment icon on legislation summaries This was the only place in the application where the comments icon was included without the span with the class "icon-comments". We unified with the rest of the application and removed the "comments-count" class which is no longer needed. --- app/assets/stylesheets/layout.scss | 2 ++ app/assets/stylesheets/legislation_process.scss | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index d7198a0b4..ffb7f07f9 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2047,9 +2047,11 @@ table { width: 100%; } +.annotation-summary, .budget-investment-info, .debate-info, .debate-meta, +.debate-summary, .investment-project-info, .legislation-comments, .proposal-info, diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index 74658a167..68557d2b5 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -966,10 +966,6 @@ } } - .comments-count { - @include has-fa-icon(comments, regular); - } - .question-title:not(:only-child) { margin-bottom: $line-height / 2; } From aec317e5e621a10129c41664ea80ee3bdc478bd3 Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 22 Jul 2022 10:52:53 +0200 Subject: [PATCH 06/10] Unify annotations comment icon to new structure Apply new structure in the section that shows the comments icon together with the number of comments so that it is easier to unify them into one component. Please note that we updated the comment-number class to comments-count in order to simplify the css in the new component in the next commit. --- app/assets/stylesheets/layout.scss | 12 ++++++++++++ app/assets/stylesheets/legislation_process.scss | 10 ---------- .../legislation/annotations/_comment_header.html.erb | 9 +++------ app/views/legislation/annotations/_form.html.erb | 3 +-- app/views/legislation/annotations/comments.js.erb | 4 ++-- .../draft_versions/_comments_panel.html.erb | 3 +-- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index ffb7f07f9..4fd3010a4 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2080,6 +2080,18 @@ table { } } +.comment-header { + + .comments-count { + @include has-fa-icon(comment, solid); + + &::before { + margin-right: 0.3rem; + color: #838383; + } + } +} + // 16. Flags // --------- diff --git a/app/assets/stylesheets/legislation_process.scss b/app/assets/stylesheets/legislation_process.scss index 68557d2b5..2592c59e3 100644 --- a/app/assets/stylesheets/legislation_process.scss +++ b/app/assets/stylesheets/legislation_process.scss @@ -603,20 +603,10 @@ } .comment-header { - color: #838383; padding-bottom: rem-calc(8); margin-bottom: rem-calc(16); border-bottom: 1px solid $border; - .comment-number { - color: $text; - display: inline-block; - } - - .icon-comment { - margin-right: rem-calc(8); - } - a .icon-expand { color: #838383; font-size: $small-font-size; diff --git a/app/views/legislation/annotations/_comment_header.html.erb b/app/views/legislation/annotations/_comment_header.html.erb index 12a386206..c3ee785ec 100644 --- a/app/views/legislation/annotations/_comment_header.html.erb +++ b/app/views/legislation/annotations/_comment_header.html.erb @@ -1,9 +1,6 @@ - - -
- <%= t("legislation.annotations.comments.comments_count", - count: annotation.comments.roots.count) %> -
+ + <%= t("legislation.annotations.comments.comments_count", count: annotation.comments.roots.count) %> + <%= render "annotation_link", annotation: annotation %> diff --git a/app/views/legislation/annotations/_form.html.erb b/app/views/legislation/annotations/_form.html.erb index c843141f2..f71606283 100644 --- a/app/views/legislation/annotations/_form.html.erb +++ b/app/views/legislation/annotations/_form.html.erb @@ -1,7 +1,6 @@
- -
<%= t("legislation.annotations.comments.comments_count", count: 0) %>
+ <%= t("legislation.annotations.comments.comments_count", count: 0) %>
diff --git a/app/views/legislation/annotations/comments.js.erb b/app/views/legislation/annotations/comments.js.erb index 4e5a676c7..1e0985217 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 = $(".comment-number").text() + var current_comment_text = $(".comments-count").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); - $(".comment-number").text(new_comment_count_text) + $(".comments-count").text(new_comment_count_text) } <%= render "comments_box_form", comment: @comment, annotation: @annotation %> diff --git a/app/views/legislation/draft_versions/_comments_panel.html.erb b/app/views/legislation/draft_versions/_comments_panel.html.erb index 178fca4e3..d7187359e 100644 --- a/app/views/legislation/draft_versions/_comments_panel.html.erb +++ b/app/views/legislation/draft_versions/_comments_panel.html.erb @@ -7,8 +7,7 @@ From 2865ee286f59b5ae3952d02d9728b1053fd426dc Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 16 Aug 2022 12:46:08 +0200 Subject: [PATCH 07/10] Add comments count component Remove all the translations that are left over after having unified them in the component. --- app/assets/stylesheets/application.scss | 1 + app/assets/stylesheets/comments_count.scss | 26 +++++++++++ app/assets/stylesheets/layout.scss | 45 ------------------- .../investments/info_component.html.erb | 8 ++-- .../shared/comments_count_component.html.erb | 3 ++ .../shared/comments_count_component.rb | 12 +++++ app/views/admin/debates/show.html.erb | 7 +-- .../investments/_investment_detail.erb | 4 +- app/views/debates/_debate.html.erb | 8 ++-- app/views/debates/show.html.erb | 4 +- .../annotations/_comment_header.html.erb | 4 +- .../legislation/annotations/_form.html.erb | 2 +- .../legislation/annotations/index.html.erb | 10 ++--- .../processes/_summary_allegations.html.erb | 8 ++-- .../processes/_summary_debate.html.erb | 8 ++-- .../legislation/processes/summary.xlsx.axlsx | 4 +- .../legislation/proposals/_proposal.html.erb | 12 ++--- app/views/legislation/proposals/show.html.erb | 4 +- .../legislation/questions/_question.html.erb | 9 ++-- app/views/proposals/_info.html.erb | 4 +- app/views/proposals/_proposal.html.erb | 9 ++-- app/views/topics/_topic.html.erb | 8 ++-- app/views/topics/show.html.erb | 8 ++-- config/locales/en/community.yml | 4 -- config/locales/en/general.yml | 16 ------- config/locales/en/legislation.yml | 14 ------ config/locales/es/general.yml | 16 ------- config/locales/es/legislation.yml | 14 ------ .../shared/comments_count_component_spec.rb | 17 +++++++ 29 files changed, 115 insertions(+), 174 deletions(-) create mode 100644 app/assets/stylesheets/comments_count.scss create mode 100644 app/components/shared/comments_count_component.html.erb create mode 100644 app/components/shared/comments_count_component.rb create mode 100644 spec/components/shared/comments_count_component_spec.rb diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 38dadae41..16d710cb6 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -22,6 +22,7 @@ @import "annotator_overrides"; @import "autocomplete_overrides"; @import "banner"; +@import "comments_count"; @import "datepicker_overrides"; @import "layout"; @import "participation"; diff --git a/app/assets/stylesheets/comments_count.scss b/app/assets/stylesheets/comments_count.scss new file mode 100644 index 000000000..eb414fb1f --- /dev/null +++ b/app/assets/stylesheets/comments_count.scss @@ -0,0 +1,26 @@ +.comments-count { + @include has-fa-icon(comments, regular); + + &::before { + margin-right: 0.3rem; + } + + .legislation-comments & { + + a { + text-decoration: underline; + } + + &::before { + color: #999; + } + } + + .comment-header & { + @include has-fa-icon(comment, solid); + + &::before { + color: #838383; + } + } +} diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 4fd3010a4..0377aa35f 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -2047,51 +2047,6 @@ table { width: 100%; } -.annotation-summary, -.budget-investment-info, -.debate-info, -.debate-meta, -.debate-summary, -.investment-project-info, -.legislation-comments, -.proposal-info, -.topic-info { - - .comments-count { - @include has-fa-icon(comments, regular); - - &::before { - margin-right: 0.3rem; - } - } -} - -.legislation-comments { - - .comments-count { - - a { - text-decoration: underline; - } - - &::before { - color: #999; - } - } -} - -.comment-header { - - .comments-count { - @include has-fa-icon(comment, solid); - - &::before { - margin-right: 0.3rem; - color: #838383; - } - } -} - // 16. Flags // --------- diff --git a/app/components/budgets/investments/info_component.html.erb b/app/components/budgets/investments/info_component.html.erb index 8de99aa8b..f4c73a0ba 100644 --- a/app/components/budgets/investments/info_component.html.erb +++ b/app/components/budgets/investments/info_component.html.erb @@ -2,10 +2,10 @@ <%= l investment.created_at.to_date %>  •  - - <%= link_to t("shared.comments", count: investment.comments_count), - budget_investment_path(investment.budget, investment, anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + investment.comments_count, + url: budget_investment_path(investment.budget, investment, anchor: "comments") + ) %> <% if investment.author.hidden? || investment.author.erased? %>  •  diff --git a/app/components/shared/comments_count_component.html.erb b/app/components/shared/comments_count_component.html.erb new file mode 100644 index 000000000..a122d3db0 --- /dev/null +++ b/app/components/shared/comments_count_component.html.erb @@ -0,0 +1,3 @@ + + <%= link_to_if url.present?, text, url %> + diff --git a/app/components/shared/comments_count_component.rb b/app/components/shared/comments_count_component.rb new file mode 100644 index 000000000..58f14af48 --- /dev/null +++ b/app/components/shared/comments_count_component.rb @@ -0,0 +1,12 @@ +class Shared::CommentsCountComponent < ApplicationComponent + attr_reader :comments_count, :url + + def initialize(comments_count, url: nil) + @comments_count = comments_count + @url = url + end + + def text + t("shared.comments", count: comments_count) + end +end diff --git a/app/views/admin/debates/show.html.erb b/app/views/admin/debates/show.html.erb index bf79aa1c0..a9cd45d3e 100644 --- a/app/views/admin/debates/show.html.erb +++ b/app/views/admin/debates/show.html.erb @@ -17,9 +17,10 @@  •  <%= l @debate.created_at.to_date %>  •  - - <%= link_to t("debates.show.comments", count: @debate.comments_count), debate_path(@debate, anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + @debate.comments_count, + url: debate_path(@debate, anchor: "comments") + ) %>  •  <%= render "shared/flag_actions", flaggable: @debate %> diff --git a/app/views/budgets/investments/_investment_detail.erb b/app/views/budgets/investments/_investment_detail.erb index 198387893..046d1e659 100644 --- a/app/views/budgets/investments/_investment_detail.erb +++ b/app/views/budgets/investments/_investment_detail.erb @@ -5,9 +5,7 @@  •  <%= l investment.created_at.to_date %>  •  - - <%= link_to t("shared.comments", count: investment.comments_count), "#comments" %> - + <%= render Shared::CommentsCountComponent.new(investment.comments_count, url: "#comments") %>  •  <%= investment.heading.name %>  •  diff --git a/app/views/debates/_debate.html.erb b/app/views/debates/_debate.html.erb index ef0087d8a..ed5b0df94 100644 --- a/app/views/debates/_debate.html.erb +++ b/app/views/debates/_debate.html.erb @@ -7,10 +7,10 @@

<%= link_to debate.title, debate %>

- - <%= link_to t("debates.debate.comments", count: debate.comments_count), - debate_path(debate, anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + debate.comments_count, + url: debate_path(debate, anchor: "comments") + ) %>  •  <%= l debate.created_at.to_date %> diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index c7c62c0df..52f6dd160 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -26,9 +26,7 @@  •  <%= l @debate.created_at.to_date %>  •  - - <%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %> - + <%= render Shared::CommentsCountComponent.new(@debate.comments_count, url: "#comments") %>  •  <%= render "shared/flag_actions", flaggable: @debate %> diff --git a/app/views/legislation/annotations/_comment_header.html.erb b/app/views/legislation/annotations/_comment_header.html.erb index c3ee785ec..eea52733b 100644 --- a/app/views/legislation/annotations/_comment_header.html.erb +++ b/app/views/legislation/annotations/_comment_header.html.erb @@ -1,6 +1,4 @@ - - <%= t("legislation.annotations.comments.comments_count", count: annotation.comments.roots.count) %> - +<%= render Shared::CommentsCountComponent.new(annotation.comments.roots.count) %> <%= render "annotation_link", annotation: annotation %> diff --git a/app/views/legislation/annotations/_form.html.erb b/app/views/legislation/annotations/_form.html.erb index f71606283..839c66f61 100644 --- a/app/views/legislation/annotations/_form.html.erb +++ b/app/views/legislation/annotations/_form.html.erb @@ -1,6 +1,6 @@

- <%= t("legislation.annotations.comments.comments_count", count: 0) %> + <%= render Shared::CommentsCountComponent.new(0) %>
diff --git a/app/views/legislation/annotations/index.html.erb b/app/views/legislation/annotations/index.html.erb index b935f6871..e8903d082 100644 --- a/app/views/legislation/annotations/index.html.erb +++ b/app/views/legislation/annotations/index.html.erb @@ -27,12 +27,10 @@
<%= sanitize(annotation.context).presence || annotation.quote %>
- - <%= link_to t("legislation.annotations.index.comments_count", count: annotation.comments_count), - legislation_process_draft_version_annotation_path(@process, - @draft_version, - annotation) %> - + <%= render Shared::CommentsCountComponent.new( + annotation.comments_count, + url: legislation_process_draft_version_annotation_path(@process, @draft_version, annotation) + ) %>
<% end %> diff --git a/app/views/legislation/processes/_summary_allegations.html.erb b/app/views/legislation/processes/_summary_allegations.html.erb index 345542dc1..ae96f280a 100644 --- a/app/views/legislation/processes/_summary_allegations.html.erb +++ b/app/views/legislation/processes/_summary_allegations.html.erb @@ -14,10 +14,10 @@ <%= annotation.quote %>
- - <%= link_to t("legislation.summary.comments", count: annotation.comments.count), - polymorphic_path(annotation, anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + annotation.comments_count, + url: polymorphic_path(annotation, anchor: "comments") + ) %>
<%= render "summary_comments", comments: annotation_comments %> diff --git a/app/views/legislation/processes/_summary_debate.html.erb b/app/views/legislation/processes/_summary_debate.html.erb index 8530f192d..71bb2db8b 100644 --- a/app/views/legislation/processes/_summary_debate.html.erb +++ b/app/views/legislation/processes/_summary_debate.html.erb @@ -10,10 +10,10 @@

<%= link_to question.title, polymorphic_path(question) %>

- - <%= link_to t("legislation.summary.comments", count: question.comments.count), - polymorphic_path(question, anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + question.comments.count, + url: polymorphic_path(question, anchor: "comments") + ) %>
<%= render "summary_comments", comments: question.best_comments %> diff --git a/app/views/legislation/processes/summary.xlsx.axlsx b/app/views/legislation/processes/summary.xlsx.axlsx index 3aaf73e88..a36ddd338 100644 --- a/app/views/legislation/processes/summary.xlsx.axlsx +++ b/app/views/legislation/processes/summary.xlsx.axlsx @@ -6,7 +6,7 @@ xlsx_package.workbook.add_worksheet(name: "Summary") do |sheet| if @process.debate_phase.enabled? && @process.questions.any? sheet.add_row [t("legislation.summary.debate_phase"), t("legislation.summary.debates", count: @process.questions.count)], style: title @process.questions.each do |question| - sheet.add_row [question.title, t("legislation.summary.comments", count: question.comments.count)], style: link + sheet.add_row [question.title, t("shared.comments", count: question.comments.count)], style: link sheet.add_hyperlink location: legislation_process_question_url(question.process, question), ref: sheet.rows.last.cells.first sheet.add_hyperlink location: polymorphic_url(question, anchor: "comments"), ref: sheet.rows.last.cells.last sheet.add_row [t("legislation.summary.most_voted_comments")] if question.best_comments.any? @@ -34,7 +34,7 @@ xlsx_package.workbook.add_worksheet(name: "Summary") do |sheet| t("legislation.summary.top_comments", count: @comments.count)], style: title @comments.group_by(&:commentable).each do |annotation, annotation_comments| sheet.add_row [t("legislation.annotations.index.comments_about")] - sheet.add_row [annotation.quote, t("legislation.summary.comments", count: annotation.comments.count)] + sheet.add_row [annotation.quote, t("shared.comments", count: annotation.comments.count)] sheet.add_hyperlink location: polymorphic_url(annotation, anchor: "comments"), ref: sheet.rows.last.cells.last sheet.rows.last.cells.last.style = link diff --git a/app/views/legislation/proposals/_proposal.html.erb b/app/views/legislation/proposals/_proposal.html.erb index 622293702..11a3104f1 100644 --- a/app/views/legislation/proposals/_proposal.html.erb +++ b/app/views/legislation/proposals/_proposal.html.erb @@ -19,11 +19,13 @@ <% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>

<%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %>

- - <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), - legislation_process_proposal_path(proposal.legislation_process_id, proposal, - anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + proposal.comments_count, + url: legislation_process_proposal_path( + proposal.legislation_process_id, + proposal, + anchor: "comments") + ) %>  •  <%= l proposal.created_at.to_date %> diff --git a/app/views/legislation/proposals/show.html.erb b/app/views/legislation/proposals/show.html.erb index cfc953d16..9be3ee3b3 100644 --- a/app/views/legislation/proposals/show.html.erb +++ b/app/views/legislation/proposals/show.html.erb @@ -44,9 +44,7 @@  •  <%= l @proposal.created_at.to_date %>  •  - - <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> - + <%= render Shared::CommentsCountComponent.new(@proposal.comments_count, url: "#comments") %> <% if current_user %>  •  diff --git a/app/views/legislation/questions/_question.html.erb b/app/views/legislation/questions/_question.html.erb index 49a92fcba..7c91b52ca 100644 --- a/app/views/legislation/questions/_question.html.erb +++ b/app/views/legislation/questions/_question.html.erb @@ -6,9 +6,10 @@

<%= link_to question.title, legislation_process_question_path(question.process, question) %>

- - <%= link_to t("legislation.questions.question.comments", count: question.comments.count), - legislation_process_question_path(question.process, question) %> - · <%= l question.created_at.to_date %> + <%= render Shared::CommentsCountComponent.new( + question.comments.count, + url: legislation_process_question_path(question.process, question) + ) %> + · <%= l question.created_at.to_date %>
diff --git a/app/views/proposals/_info.html.erb b/app/views/proposals/_info.html.erb index ab41e9d98..88b31d6e2 100644 --- a/app/views/proposals/_info.html.erb +++ b/app/views/proposals/_info.html.erb @@ -6,9 +6,7 @@ <% unless @proposal.selected? %>  •  - - <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> - + <%= render Shared::CommentsCountComponent.new(@proposal.comments_count, url: "#comments") %> <% end %> <% if current_user %> diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 3adbe05af..76e3e4acc 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -21,11 +21,10 @@ <% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>

<%= link_to proposal.title, namespaced_proposal_path(proposal) %>

- - <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), - namespaced_proposal_path(proposal, anchor: "comments") %> - - + <%= render Shared::CommentsCountComponent.new( + proposal.comments_count, + url: namespaced_proposal_path(proposal, anchor: "comments") + ) %>  •  <%= l proposal.created_at.to_date %> diff --git a/app/views/topics/_topic.html.erb b/app/views/topics/_topic.html.erb index a2afb656f..ddd6ce6d8 100644 --- a/app/views/topics/_topic.html.erb +++ b/app/views/topics/_topic.html.erb @@ -5,10 +5,10 @@

<%= link_to topic.title, community_topic_path(@community, topic) %>

- - <%= link_to t("community.show.topic.comments", count: topic.comments_count), - community_topic_path(@community, topic, anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + topic.comments_count, + url: community_topic_path(@community, topic, anchor: "comments") + ) %>  •  <%= I18n.l topic.created_at.to_date %>  •  diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index a20e8815a..51242bd0a 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -14,10 +14,10 @@  •  <%= l(@topic.created_at.to_date) %>  •  - - <%= link_to t("community.show.topic.comments", count: @topic.comments_count), - community_topic_path(@community, @topic, anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + @topic.comments_count, + url: community_topic_path(@community, @topic, anchor: "comments") + ) %>


<%= @topic.description %>

diff --git a/config/locales/en/community.yml b/config/locales/en/community.yml index 49ee30fa6..3c6a440dc 100644 --- a/config/locales/en/community.yml +++ b/config/locales/en/community.yml @@ -25,10 +25,6 @@ en: topic: edit: Edit topic destroy: Delete topic - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments author: Author back: Back to %{community} %{proposal} topic: diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index db573e42b..96b0655c9 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -69,10 +69,6 @@ en: form: submit_button: Start a debate debate: - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments votes: one: 1 vote other: "%{count} votes" @@ -128,10 +124,6 @@ en: start_new: Start a debate show: author_deleted: User deleted - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments comments_title: Comments edit_debate_link: Edit flag: This debate has been flagged as inappropriate by several users. @@ -396,10 +388,6 @@ en: edit: "Before it gets shared you'll be able to change the text as you like." view_proposal: Not now, go to my proposal already_supported: You have already supported this proposal. Share it! - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments support: Support support_label: "Support %{proposal}" support_title: Support this proposal @@ -420,10 +408,6 @@ en: show: author_deleted: User deleted code: "Proposal code:" - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments comments_tab: Comments dashboard_proposal_link: Dashboard flag: This proposal has been flagged as inappropriate by several users. diff --git a/config/locales/en/legislation.yml b/config/locales/en/legislation.yml index 8fd58bc28..ea6ad838f 100644 --- a/config/locales/en/legislation.yml +++ b/config/locales/en/legislation.yml @@ -4,9 +4,6 @@ en: comments: see_all: See all see_complete: See complete - comments_count: - one: "%{count} comment" - other: "%{count} comments" replies_count: one: "%{count} reply" other: "%{count} replies" @@ -18,9 +15,6 @@ en: title: Comments comments_about: Comments about see_in_context: See in context - comments_count: - one: "%{count} comment" - other: "%{count} comments" show: title: Comment version_chooser: @@ -92,10 +86,6 @@ en: form: leave_comment: Leave your answer question: - comments: - zero: No comments - one: "%{count} comment" - other: "%{count} comments" debate: Debate show: answer_question: Submit answer @@ -134,10 +124,6 @@ en: zero: "No proposals" one: "%{count} proposal" other: "%{count} proposals" - comments: - zero: "No comments" - one: "%{count} comment" - other: "%{count} comments" download: "Download summary" top_comments: zero: "No comments" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 82ea3bbd7..ebfbd6749 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -69,10 +69,6 @@ es: form: submit_button: Empieza un debate debate: - comments: - zero: Sin comentarios - one: 1 Comentario - other: "%{count} Comentarios" votes: zero: Sin votos one: 1 voto @@ -128,10 +124,6 @@ es: start_new: Empezar un debate show: author_deleted: Usuario eliminado - comments: - zero: Sin comentarios - one: 1 Comentario - other: "%{count} Comentarios" comments_title: Comentarios edit_debate_link: Editar debate flag: Este debate ha sido marcado como inapropiado por varios usuarios. @@ -396,10 +388,6 @@ es: edit: "Antes de que se publique podrás modificar el texto a tu gusto." view_proposal: Ahora no, ir a mi propuesta already_supported: '¡Ya has apoyado esta propuesta, compártela!' - comments: - zero: Sin comentarios - one: 1 Comentario - other: "%{count} Comentarios" support: Apoyar support_label: "Apoyar %{proposal}" support_title: Apoyar esta propuesta @@ -420,10 +408,6 @@ es: show: author_deleted: Usuario eliminado code: "Código de la propuesta:" - comments: - zero: Sin comentarios - one: 1 Comentario - other: "%{count} Comentarios" comments_tab: Comentarios dashboard_proposal_link: Panel de control flag: Esta propuesta ha sido marcada como inapropiada por varios usuarios. diff --git a/config/locales/es/legislation.yml b/config/locales/es/legislation.yml index 33693570e..575c6e8af 100644 --- a/config/locales/es/legislation.yml +++ b/config/locales/es/legislation.yml @@ -4,9 +4,6 @@ es: comments: see_all: Ver todos see_complete: Ver completo - comments_count: - one: "%{count} comentario" - other: "%{count} comentarios" replies_count: one: "%{count} respuesta" other: "%{count} respuestas" @@ -18,9 +15,6 @@ es: title: Comentarios comments_about: Comentarios sobre see_in_context: Ver en contexto - comments_count: - one: "%{count} comentario" - other: "%{count} comentarios" show: title: Comentario version_chooser: @@ -92,10 +86,6 @@ es: form: leave_comment: Deja tu respuesta question: - comments: - zero: Sin comentarios - one: "%{count} comentario" - other: "%{count} comentarios" debate: Debate show: answer_question: Enviar respuesta @@ -134,10 +124,6 @@ es: zero: "No hay propuestas" one: "%{count} propuesta" other: "%{count} propuestas" - comments: - zero: "No hay comentarios" - one: "%{count} comentario" - other: "%{count} comentarios" download: "Descargar resumen" top_comments: zero: "No hay comentarios" diff --git a/spec/components/shared/comments_count_component_spec.rb b/spec/components/shared/comments_count_component_spec.rb new file mode 100644 index 000000000..15451363f --- /dev/null +++ b/spec/components/shared/comments_count_component_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +describe Shared::CommentsCountComponent do + it "renders a link when a URL is given" do + render_inline Shared::CommentsCountComponent.new(0, url: "http://www.url.com") + + expect(page.find(".comments-count")).to have_content "No comments" + expect(page.find(".comments-count")).to have_link "No comments", href: "http://www.url.com" + end + + it "renders plain text when no URL is given" do + render_inline Shared::CommentsCountComponent.new(1) + + expect(page.find(".comments-count")).to have_content "1 comment" + expect(page.find(".comments-count")).not_to have_link "1 comment" + end +end From 34d9d95cf0c0fd1be16e10f54e49a4c5bec3f677 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 16 Aug 2022 12:49:41 +0200 Subject: [PATCH 08/10] Add missing file extension for investment detail partial Change the file extension from .erb to .html.erb so that it is the same as the other files. --- .../{_investment_detail.erb => _investment_detail.html.erb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/views/budgets/investments/{_investment_detail.erb => _investment_detail.html.erb} (100%) diff --git a/app/views/budgets/investments/_investment_detail.erb b/app/views/budgets/investments/_investment_detail.html.erb similarity index 100% rename from app/views/budgets/investments/_investment_detail.erb rename to app/views/budgets/investments/_investment_detail.html.erb From af00dd94db040420dd77a109a90b63dbca68c7a7 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 16 Aug 2022 12:55:02 +0200 Subject: [PATCH 09/10] Unify the order in which we display information In the rest of the similar sections of the application we show the date first and then the information of the comments. --- app/views/debates/_debate.html.erb | 4 ++-- app/views/legislation/proposals/_proposal.html.erb | 4 ++-- app/views/proposals/_proposal.html.erb | 4 ++-- app/views/topics/_topic.html.erb | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/debates/_debate.html.erb b/app/views/debates/_debate.html.erb index ed5b0df94..905c3ec79 100644 --- a/app/views/debates/_debate.html.erb +++ b/app/views/debates/_debate.html.erb @@ -7,12 +7,12 @@

<%= link_to debate.title, debate %>

+ <%= l debate.created_at.to_date %> +  •  <%= render Shared::CommentsCountComponent.new( debate.comments_count, url: debate_path(debate, anchor: "comments") ) %> -  •  - <%= l debate.created_at.to_date %> <% if debate.author.hidden? || debate.author.erased? %>  •  diff --git a/app/views/legislation/proposals/_proposal.html.erb b/app/views/legislation/proposals/_proposal.html.erb index 11a3104f1..3df7e5c1b 100644 --- a/app/views/legislation/proposals/_proposal.html.erb +++ b/app/views/legislation/proposals/_proposal.html.erb @@ -19,6 +19,8 @@ <% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>

<%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %>

+ <%= l proposal.created_at.to_date %> +  •  <%= render Shared::CommentsCountComponent.new( proposal.comments_count, url: legislation_process_proposal_path( @@ -26,8 +28,6 @@ proposal, anchor: "comments") ) %> -  •  - <%= l proposal.created_at.to_date %> <% if proposal.author.hidden? || proposal.author.erased? %>  •  diff --git a/app/views/proposals/_proposal.html.erb b/app/views/proposals/_proposal.html.erb index 76e3e4acc..934baced9 100644 --- a/app/views/proposals/_proposal.html.erb +++ b/app/views/proposals/_proposal.html.erb @@ -21,12 +21,12 @@ <% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>

<%= link_to proposal.title, namespaced_proposal_path(proposal) %>

+ <%= l proposal.created_at.to_date %> +  •  <%= render Shared::CommentsCountComponent.new( proposal.comments_count, url: namespaced_proposal_path(proposal, anchor: "comments") ) %> -  •  - <%= l proposal.created_at.to_date %> <% if proposal.author.hidden? || proposal.author.erased? %>  •  diff --git a/app/views/topics/_topic.html.erb b/app/views/topics/_topic.html.erb index ddd6ce6d8..cb18551d2 100644 --- a/app/views/topics/_topic.html.erb +++ b/app/views/topics/_topic.html.erb @@ -5,13 +5,13 @@

<%= link_to topic.title, community_topic_path(@community, topic) %>

+ <%= I18n.l topic.created_at.to_date %> +  •  <%= render Shared::CommentsCountComponent.new( topic.comments_count, url: community_topic_path(@community, topic, anchor: "comments") ) %>  •  - <%= I18n.l topic.created_at.to_date %> -  •  <%= topic.author.name %>

From 9f90125fa75b40d595d8d84a8eaea0161cc3dff0 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 16 Aug 2022 13:29:40 +0200 Subject: [PATCH 10/10] Add attribute anchor to link Anchor needs to be added to the link to redirect directly to the comments section. --- app/views/legislation/questions/_question.html.erb | 2 +- spec/system/legislation/questions_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/legislation/questions/_question.html.erb b/app/views/legislation/questions/_question.html.erb index 7c91b52ca..aa910883c 100644 --- a/app/views/legislation/questions/_question.html.erb +++ b/app/views/legislation/questions/_question.html.erb @@ -8,7 +8,7 @@
<%= render Shared::CommentsCountComponent.new( question.comments.count, - url: legislation_process_question_path(question.process, question) + url: legislation_process_question_path(question.process, question, anchor: "comments") ) %> · <%= l question.created_at.to_date %>
diff --git a/spec/system/legislation/questions_spec.rb b/spec/system/legislation/questions_spec.rb index bbf55184c..b217ad7f4 100644 --- a/spec/system/legislation/questions_spec.rb +++ b/spec/system/legislation/questions_spec.rb @@ -109,5 +109,15 @@ describe "Legislation" do expect(page).not_to have_selector(:link_or_button, "Submit answer") end + + scenario "render link to questions comments with anchor" do + question = create(:legislation_question, process: process, title: "Question without comments") + + visit legislation_process_path(process) + + expect(page).to have_link "No comments", href: legislation_process_question_path(process, + question, + anchor: "comments") + end end end