Merge pull request #4839 from consul/comments_count_investment
Add comments count on budget investments
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
@import "annotator_overrides";
|
@import "annotator_overrides";
|
||||||
@import "autocomplete_overrides";
|
@import "autocomplete_overrides";
|
||||||
@import "banner";
|
@import "banner";
|
||||||
|
@import "comments_count";
|
||||||
@import "datepicker_overrides";
|
@import "datepicker_overrides";
|
||||||
@import "layout";
|
@import "layout";
|
||||||
@import "participation";
|
@import "participation";
|
||||||
|
|||||||
26
app/assets/stylesheets/comments_count.scss
Normal file
26
app/assets/stylesheets/comments_count.scss
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -153,10 +153,6 @@
|
|||||||
.debate-meta a {
|
.debate-meta a {
|
||||||
font-size: $small-font-size;
|
font-size: $small-font-size;
|
||||||
color: #6d6d6d;
|
color: #6d6d6d;
|
||||||
|
|
||||||
.icon-comments {
|
|
||||||
margin-right: rem-calc(3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.debate-info {
|
.debate-info {
|
||||||
@@ -607,20 +603,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.comment-header {
|
.comment-header {
|
||||||
color: #838383;
|
|
||||||
padding-bottom: rem-calc(8);
|
padding-bottom: rem-calc(8);
|
||||||
margin-bottom: rem-calc(16);
|
margin-bottom: rem-calc(16);
|
||||||
border-bottom: 1px solid $border;
|
border-bottom: 1px solid $border;
|
||||||
|
|
||||||
.comment-number {
|
|
||||||
color: $text;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-comment {
|
|
||||||
margin-right: rem-calc(8);
|
|
||||||
}
|
|
||||||
|
|
||||||
a .icon-expand {
|
a .icon-expand {
|
||||||
color: #838383;
|
color: #838383;
|
||||||
font-size: $small-font-size;
|
font-size: $small-font-size;
|
||||||
@@ -806,13 +792,12 @@
|
|||||||
.comment {
|
.comment {
|
||||||
margin-bottom: rem-calc(48);
|
margin-bottom: rem-calc(48);
|
||||||
|
|
||||||
a {
|
.expand-context a {
|
||||||
span {
|
span {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-expand,
|
.icon-expand {
|
||||||
.icon-comments {
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #999;
|
color: #999;
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
@@ -822,10 +807,6 @@
|
|||||||
margin-left: rem-calc(4);
|
margin-left: rem-calc(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-comments {
|
|
||||||
margin-right: rem-calc(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active,
|
&:active,
|
||||||
&:focus,
|
&:focus,
|
||||||
&:hover {
|
&:hover {
|
||||||
@@ -975,10 +956,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.comments-count {
|
|
||||||
@include has-fa-icon(comments, regular);
|
|
||||||
}
|
|
||||||
|
|
||||||
.question-title:not(:only-child) {
|
.question-title:not(:only-child) {
|
||||||
margin-bottom: $line-height / 2;
|
margin-bottom: $line-height / 2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -486,6 +486,7 @@
|
|||||||
.debate,
|
.debate,
|
||||||
.proposal,
|
.proposal,
|
||||||
.budget-investment,
|
.budget-investment,
|
||||||
|
.budget-investment-show,
|
||||||
.legislation,
|
.legislation,
|
||||||
.communities-show {
|
.communities-show {
|
||||||
margin: $line-height / 4 0;
|
margin: $line-height / 4 0;
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
<p class="investment-project-info">
|
<p class="investment-project-info">
|
||||||
<%= l investment.created_at.to_date %>
|
<%= l investment.created_at.to_date %>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
|
||||||
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
|
investment.comments_count,
|
||||||
|
url: budget_investment_path(investment.budget, investment, anchor: "comments")
|
||||||
|
) %>
|
||||||
|
|
||||||
<% if investment.author.hidden? || investment.author.erased? %>
|
<% if investment.author.hidden? || investment.author.erased? %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
|
|||||||
3
app/components/shared/comments_count_component.html.erb
Normal file
3
app/components/shared/comments_count_component.html.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<span class="comments-count">
|
||||||
|
<%= link_to_if url.present?, text, url %>
|
||||||
|
</span>
|
||||||
12
app/components/shared/comments_count_component.rb
Normal file
12
app/components/shared/comments_count_component.rb
Normal file
@@ -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
|
||||||
@@ -17,8 +17,10 @@
|
|||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= l @debate.created_at.to_date %>
|
<%= l @debate.created_at.to_date %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<span class="icon-comments"></span>
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
<%= link_to t("debates.show.comments", count: @debate.comments_count), debate_path(@debate, anchor: "comments") %>
|
@debate.comments_count,
|
||||||
|
url: debate_path(@debate, anchor: "comments")
|
||||||
|
) %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<span class="js-flag-actions">
|
<span class="js-flag-actions">
|
||||||
<%= render "shared/flag_actions", flaggable: @debate %>
|
<%= render "shared/flag_actions", flaggable: @debate %>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= l investment.created_at.to_date %>
|
<%= l investment.created_at.to_date %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
|
<%= render Shared::CommentsCountComponent.new(investment.comments_count, url: "#comments") %>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
<%= investment.heading.name %>
|
<%= investment.heading.name %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<% if local_assigns[:preview].nil? %>
|
<% if local_assigns[:preview].nil? %>
|
||||||
@@ -7,10 +7,12 @@
|
|||||||
<div class="debate-content">
|
<div class="debate-content">
|
||||||
<h3><%= link_to debate.title, debate %></h3>
|
<h3><%= link_to debate.title, debate %></h3>
|
||||||
<p class="debate-info">
|
<p class="debate-info">
|
||||||
<span class="icon-comments"></span>
|
|
||||||
<%= link_to t("debates.debate.comments", count: debate.comments_count), debate_path(debate, anchor: "comments") %>
|
|
||||||
<span class="bullet"> • </span>
|
|
||||||
<%= l debate.created_at.to_date %>
|
<%= l debate.created_at.to_date %>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
|
debate.comments_count,
|
||||||
|
url: debate_path(debate, anchor: "comments")
|
||||||
|
) %>
|
||||||
|
|
||||||
<% if debate.author.hidden? || debate.author.erased? %>
|
<% if debate.author.hidden? || debate.author.erased? %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
|
|||||||
@@ -26,8 +26,7 @@
|
|||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= l @debate.created_at.to_date %>
|
<%= l @debate.created_at.to_date %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<span class="icon-comments"></span>
|
<%= render Shared::CommentsCountComponent.new(@debate.comments_count, url: "#comments") %>
|
||||||
<%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %>
|
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<span class="js-flag-actions">
|
<span class="js-flag-actions">
|
||||||
<%= render "shared/flag_actions", flaggable: @debate %>
|
<%= render "shared/flag_actions", flaggable: @debate %>
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
<span class="icon-comment" aria-hidden="true"></span>
|
<%= render Shared::CommentsCountComponent.new(annotation.comments.roots.count) %>
|
||||||
|
|
||||||
<div class="comment-number">
|
|
||||||
<%= t("legislation.annotations.comments.comments_count",
|
|
||||||
count: annotation.comments.roots.count) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span id="annotation-link" data-sub-annotation-ids="8">
|
<span id="annotation-link" data-sub-annotation-ids="8">
|
||||||
<%= render "annotation_link", annotation: annotation %>
|
<%= render "annotation_link", annotation: annotation %>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<div class="comment-box">
|
<div class="comment-box">
|
||||||
<div class="comment-header">
|
<div class="comment-header">
|
||||||
<span class="icon-comment" aria-hidden="true"></span>
|
<%= render Shared::CommentsCountComponent.new(0) %>
|
||||||
<div class="comment-number"><%= t("legislation.annotations.comments.comments_count", count: 0) %></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="comments-wrapper">
|
<div class="comments-wrapper">
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ if ($(".comment").length == 0) {
|
|||||||
|
|
||||||
$("#annotation-link a").attr("href", new_annotation_link)
|
$("#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 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 = parseInt(current_comment_count) + parseInt(<%= @annotation.comments.roots.count %>)
|
||||||
var new_comment_count_text = current_comment_text.replace(/(\d+)/, new_comment_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 %>
|
<%= render "comments_box_form", comment: @comment, annotation: @annotation %>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<% @annotations.each do |annotation| %>
|
<% @annotations.each do |annotation| %>
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<strong><%= t("legislation.annotations.index.comments_about") %></strong>
|
<strong><%= t("legislation.annotations.index.comments_about") %></strong>
|
||||||
<span class="float-right">
|
<span class="float-right expand-context">
|
||||||
<%= link_to legislation_process_draft_version_path(@process, @draft_version, anchor: "annotation-id-#{annotation.id}") do %>
|
<%= link_to legislation_process_draft_version_path(@process, @draft_version, anchor: "annotation-id-#{annotation.id}") do %>
|
||||||
<span><%= t("legislation.annotations.index.see_in_context") %></span>
|
<span><%= t("legislation.annotations.index.see_in_context") %></span>
|
||||||
<span class="icon-expand" aria-hidden="true"></span>
|
<span class="icon-expand" aria-hidden="true"></span>
|
||||||
@@ -27,12 +27,10 @@
|
|||||||
<div class="comment-section">
|
<div class="comment-section">
|
||||||
<%= sanitize(annotation.context).presence || annotation.quote %>
|
<%= sanitize(annotation.context).presence || annotation.quote %>
|
||||||
</div>
|
</div>
|
||||||
<%= link_to legislation_process_draft_version_annotation_path(@process, @draft_version, annotation) do %>
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
<span class="icon-comments" aria-hidden="true"></span>
|
annotation.comments_count,
|
||||||
<span>
|
url: legislation_process_draft_version_annotation_path(@process, @draft_version, annotation)
|
||||||
<%= t("legislation.annotations.index.comments_count", count: annotation.comments_count) %>
|
) %>
|
||||||
</span>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
<div id="comments-box" class="comments-box-container" style="display: none;">
|
<div id="comments-box" class="comments-box-container" style="display: none;">
|
||||||
<div class="comment-box">
|
<div class="comment-box">
|
||||||
<div class="comment-header">
|
<div class="comment-header">
|
||||||
<span class="icon-comment" aria-hidden="true"></span>
|
<span class="comments-count"><%= t("legislation.draft_versions.show.loading_comments") %></span>
|
||||||
<div class="comment-number"><%= t("legislation.draft_versions.show.loading_comments") %></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,10 +14,10 @@
|
|||||||
<%= annotation.quote %>
|
<%= annotation.quote %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<span class="comments-count">
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
<%= link_to t("legislation.summary.comments", count: annotation.comments.count),
|
annotation.comments_count,
|
||||||
polymorphic_path(annotation, anchor: "comments") %>
|
url: polymorphic_path(annotation, anchor: "comments")
|
||||||
</span>
|
) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render "summary_comments", comments: annotation_comments %>
|
<%= render "summary_comments", comments: annotation_comments %>
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
<div class="debate-summary">
|
<div class="debate-summary">
|
||||||
<div class="question-title">
|
<div class="question-title">
|
||||||
<h4><%= link_to question.title, polymorphic_path(question) %></h4>
|
<h4><%= link_to question.title, polymorphic_path(question) %></h4>
|
||||||
<span class="comments-count">
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
<%= link_to t("legislation.summary.comments", count: question.comments.count),
|
question.comments.count,
|
||||||
polymorphic_path(question, anchor: "comments") %>
|
url: polymorphic_path(question, anchor: "comments")
|
||||||
</span>
|
) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render "summary_comments", comments: question.best_comments %>
|
<%= render "summary_comments", comments: question.best_comments %>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ xlsx_package.workbook.add_worksheet(name: "Summary") do |sheet|
|
|||||||
if @process.debate_phase.enabled? && @process.questions.any?
|
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
|
sheet.add_row [t("legislation.summary.debate_phase"), t("legislation.summary.debates", count: @process.questions.count)], style: title
|
||||||
@process.questions.each do |question|
|
@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: 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_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?
|
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
|
t("legislation.summary.top_comments", count: @comments.count)], style: title
|
||||||
@comments.group_by(&:commentable).each do |annotation, annotation_comments|
|
@comments.group_by(&:commentable).each do |annotation, annotation_comments|
|
||||||
sheet.add_row [t("legislation.annotations.index.comments_about")]
|
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.add_hyperlink location: polymorphic_url(annotation, anchor: "comments"), ref: sheet.rows.last.cells.last
|
||||||
sheet.rows.last.cells.last.style = link
|
sheet.rows.last.cells.last.style = link
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,15 @@
|
|||||||
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
||||||
<h3><%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %></h3>
|
<h3><%= link_to proposal.title, legislation_process_proposal_path(proposal.legislation_process_id, proposal) %></h3>
|
||||||
<p class="proposal-info">
|
<p class="proposal-info">
|
||||||
<span class="icon-comments"></span>
|
|
||||||
<%= link_to t("proposals.proposal.comments", count: proposal.comments_count), legislation_process_proposal_path(proposal.legislation_process_id, proposal, anchor: "comments") %>
|
|
||||||
|
|
||||||
<span class="bullet"> • </span>
|
|
||||||
<%= l proposal.created_at.to_date %>
|
<%= l proposal.created_at.to_date %>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
|
proposal.comments_count,
|
||||||
|
url: legislation_process_proposal_path(
|
||||||
|
proposal.legislation_process_id,
|
||||||
|
proposal,
|
||||||
|
anchor: "comments")
|
||||||
|
) %>
|
||||||
|
|
||||||
<% if proposal.author.hidden? || proposal.author.erased? %>
|
<% if proposal.author.hidden? || proposal.author.erased? %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
|
|||||||
@@ -44,8 +44,7 @@
|
|||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= l @proposal.created_at.to_date %>
|
<%= l @proposal.created_at.to_date %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<span class="icon-comments"></span>
|
<%= render Shared::CommentsCountComponent.new(@proposal.comments_count, url: "#comments") %>
|
||||||
<%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %>
|
|
||||||
|
|
||||||
<% if current_user %>
|
<% if current_user %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
|
|||||||
@@ -6,9 +6,10 @@
|
|||||||
<h4><%= link_to question.title, legislation_process_question_path(question.process, question) %></h4>
|
<h4><%= link_to question.title, legislation_process_question_path(question.process, question) %></h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="debate-meta">
|
<div class="debate-meta">
|
||||||
<span class="icon-comments" aria-hidden="true"></span> <span class="debate-comments">
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
<%= link_to t("legislation.questions.question.comments", count: question.comments.count),
|
question.comments.count,
|
||||||
legislation_process_question_path(question.process, question) %>
|
url: legislation_process_question_path(question.process, question, anchor: "comments")
|
||||||
</span> · <span class="debate-date"><%= format_date question.created_at %></span>
|
) %>
|
||||||
|
· <span class="debate-date"><%= l question.created_at.to_date %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,8 +6,7 @@
|
|||||||
|
|
||||||
<% unless @proposal.selected? %>
|
<% unless @proposal.selected? %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<span class="icon-comments"></span>
|
<%= render Shared::CommentsCountComponent.new(@proposal.comments_count, url: "#comments") %>
|
||||||
<%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if current_user %>
|
<% if current_user %>
|
||||||
|
|||||||
@@ -21,12 +21,12 @@
|
|||||||
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
<% cache [locale_and_user_status(proposal), "index", proposal, proposal.author] do %>
|
||||||
<h3><%= link_to proposal.title, namespaced_proposal_path(proposal) %></h3>
|
<h3><%= link_to proposal.title, namespaced_proposal_path(proposal) %></h3>
|
||||||
<p class="proposal-info">
|
<p class="proposal-info">
|
||||||
<span class="icon-comments"></span>
|
|
||||||
<%= link_to t("proposals.proposal.comments", count: proposal.comments_count),
|
|
||||||
namespaced_proposal_path(proposal, anchor: "comments") %>
|
|
||||||
|
|
||||||
<span class="bullet"> • </span>
|
|
||||||
<%= l proposal.created_at.to_date %>
|
<%= l proposal.created_at.to_date %>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
|
proposal.comments_count,
|
||||||
|
url: namespaced_proposal_path(proposal, anchor: "comments")
|
||||||
|
) %>
|
||||||
|
|
||||||
<% if proposal.author.hidden? || proposal.author.erased? %>
|
<% if proposal.author.hidden? || proposal.author.erased? %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
<h3><%= link_to topic.title, community_topic_path(@community, topic) %></h3>
|
<h3><%= link_to topic.title, community_topic_path(@community, topic) %></h3>
|
||||||
|
|
||||||
<p class="topic-info">
|
<p class="topic-info">
|
||||||
<span class="icon-comments"></span>
|
|
||||||
<%= link_to t("community.show.topic.comments", count: topic.comments_count), community_topic_path(@community, topic, anchor: "comments") %>
|
|
||||||
<span class="bullet"> • </span>
|
|
||||||
<%= I18n.l topic.created_at.to_date %>
|
<%= I18n.l topic.created_at.to_date %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
|
topic.comments_count,
|
||||||
|
url: community_topic_path(@community, topic, anchor: "comments")
|
||||||
|
) %>
|
||||||
|
<span class="bullet"> • </span>
|
||||||
<%= topic.author.name %>
|
<%= topic.author.name %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,10 @@
|
|||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<%= l(@topic.created_at.to_date) %>
|
<%= l(@topic.created_at.to_date) %>
|
||||||
<span class="bullet"> • </span>
|
<span class="bullet"> • </span>
|
||||||
<span class="icon-comments"></span>
|
<%= render Shared::CommentsCountComponent.new(
|
||||||
<%= link_to t("community.show.topic.comments", count: @topic.comments_count),
|
@topic.comments_count,
|
||||||
community_topic_path(@community, @topic, anchor: "comments") %>
|
url: community_topic_path(@community, @topic, anchor: "comments")
|
||||||
|
) %>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<p><%= @topic.description %></p>
|
<p><%= @topic.description %></p>
|
||||||
|
|||||||
@@ -25,10 +25,6 @@ en:
|
|||||||
topic:
|
topic:
|
||||||
edit: Edit topic
|
edit: Edit topic
|
||||||
destroy: Delete topic
|
destroy: Delete topic
|
||||||
comments:
|
|
||||||
one: 1 comment
|
|
||||||
other: "%{count} comments"
|
|
||||||
zero: No comments
|
|
||||||
author: Author
|
author: Author
|
||||||
back: Back to %{community} %{proposal}
|
back: Back to %{community} %{proposal}
|
||||||
topic:
|
topic:
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ en:
|
|||||||
form:
|
form:
|
||||||
submit_button: Start a debate
|
submit_button: Start a debate
|
||||||
debate:
|
debate:
|
||||||
comments:
|
|
||||||
one: 1 comment
|
|
||||||
other: "%{count} comments"
|
|
||||||
zero: No comments
|
|
||||||
votes:
|
votes:
|
||||||
one: 1 vote
|
one: 1 vote
|
||||||
other: "%{count} votes"
|
other: "%{count} votes"
|
||||||
@@ -128,10 +124,6 @@ en:
|
|||||||
start_new: Start a debate
|
start_new: Start a debate
|
||||||
show:
|
show:
|
||||||
author_deleted: User deleted
|
author_deleted: User deleted
|
||||||
comments:
|
|
||||||
one: 1 comment
|
|
||||||
other: "%{count} comments"
|
|
||||||
zero: No comments
|
|
||||||
comments_title: Comments
|
comments_title: Comments
|
||||||
edit_debate_link: Edit
|
edit_debate_link: Edit
|
||||||
flag: This debate has been flagged as inappropriate by several users.
|
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."
|
edit: "Before it gets shared you'll be able to change the text as you like."
|
||||||
view_proposal: Not now, go to my proposal
|
view_proposal: Not now, go to my proposal
|
||||||
already_supported: You have already supported this proposal. Share it!
|
already_supported: You have already supported this proposal. Share it!
|
||||||
comments:
|
|
||||||
one: 1 comment
|
|
||||||
other: "%{count} comments"
|
|
||||||
zero: No comments
|
|
||||||
support: Support
|
support: Support
|
||||||
support_label: "Support %{proposal}"
|
support_label: "Support %{proposal}"
|
||||||
support_title: Support this proposal
|
support_title: Support this proposal
|
||||||
@@ -420,10 +408,6 @@ en:
|
|||||||
show:
|
show:
|
||||||
author_deleted: User deleted
|
author_deleted: User deleted
|
||||||
code: "Proposal code:"
|
code: "Proposal code:"
|
||||||
comments:
|
|
||||||
one: 1 comment
|
|
||||||
other: "%{count} comments"
|
|
||||||
zero: No comments
|
|
||||||
comments_tab: Comments
|
comments_tab: Comments
|
||||||
dashboard_proposal_link: Dashboard
|
dashboard_proposal_link: Dashboard
|
||||||
flag: This proposal has been flagged as inappropriate by several users.
|
flag: This proposal has been flagged as inappropriate by several users.
|
||||||
@@ -763,6 +747,10 @@ en:
|
|||||||
other: "%{count} languages in use"
|
other: "%{count} languages in use"
|
||||||
optional: "Optional fields"
|
optional: "Optional fields"
|
||||||
required: "Required fields"
|
required: "Required fields"
|
||||||
|
comments:
|
||||||
|
one: "1 comment"
|
||||||
|
other: "%{count} comments"
|
||||||
|
zero: "No comments"
|
||||||
social:
|
social:
|
||||||
facebook: "%{org} Facebook"
|
facebook: "%{org} Facebook"
|
||||||
twitter: "%{org} Twitter"
|
twitter: "%{org} Twitter"
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ en:
|
|||||||
comments:
|
comments:
|
||||||
see_all: See all
|
see_all: See all
|
||||||
see_complete: See complete
|
see_complete: See complete
|
||||||
comments_count:
|
|
||||||
one: "%{count} comment"
|
|
||||||
other: "%{count} comments"
|
|
||||||
replies_count:
|
replies_count:
|
||||||
one: "%{count} reply"
|
one: "%{count} reply"
|
||||||
other: "%{count} replies"
|
other: "%{count} replies"
|
||||||
@@ -18,9 +15,6 @@ en:
|
|||||||
title: Comments
|
title: Comments
|
||||||
comments_about: Comments about
|
comments_about: Comments about
|
||||||
see_in_context: See in context
|
see_in_context: See in context
|
||||||
comments_count:
|
|
||||||
one: "%{count} comment"
|
|
||||||
other: "%{count} comments"
|
|
||||||
show:
|
show:
|
||||||
title: Comment
|
title: Comment
|
||||||
version_chooser:
|
version_chooser:
|
||||||
@@ -92,10 +86,6 @@ en:
|
|||||||
form:
|
form:
|
||||||
leave_comment: Leave your answer
|
leave_comment: Leave your answer
|
||||||
question:
|
question:
|
||||||
comments:
|
|
||||||
zero: No comments
|
|
||||||
one: "%{count} comment"
|
|
||||||
other: "%{count} comments"
|
|
||||||
debate: Debate
|
debate: Debate
|
||||||
show:
|
show:
|
||||||
answer_question: Submit answer
|
answer_question: Submit answer
|
||||||
@@ -134,10 +124,6 @@ en:
|
|||||||
zero: "No proposals"
|
zero: "No proposals"
|
||||||
one: "%{count} proposal"
|
one: "%{count} proposal"
|
||||||
other: "%{count} proposals"
|
other: "%{count} proposals"
|
||||||
comments:
|
|
||||||
zero: "No comments"
|
|
||||||
one: "%{count} comment"
|
|
||||||
other: "%{count} comments"
|
|
||||||
download: "Download summary"
|
download: "Download summary"
|
||||||
top_comments:
|
top_comments:
|
||||||
zero: "No comments"
|
zero: "No comments"
|
||||||
|
|||||||
@@ -69,10 +69,6 @@ es:
|
|||||||
form:
|
form:
|
||||||
submit_button: Empieza un debate
|
submit_button: Empieza un debate
|
||||||
debate:
|
debate:
|
||||||
comments:
|
|
||||||
zero: Sin comentarios
|
|
||||||
one: 1 Comentario
|
|
||||||
other: "%{count} Comentarios"
|
|
||||||
votes:
|
votes:
|
||||||
zero: Sin votos
|
zero: Sin votos
|
||||||
one: 1 voto
|
one: 1 voto
|
||||||
@@ -128,10 +124,6 @@ es:
|
|||||||
start_new: Empezar un debate
|
start_new: Empezar un debate
|
||||||
show:
|
show:
|
||||||
author_deleted: Usuario eliminado
|
author_deleted: Usuario eliminado
|
||||||
comments:
|
|
||||||
zero: Sin comentarios
|
|
||||||
one: 1 Comentario
|
|
||||||
other: "%{count} Comentarios"
|
|
||||||
comments_title: Comentarios
|
comments_title: Comentarios
|
||||||
edit_debate_link: Editar debate
|
edit_debate_link: Editar debate
|
||||||
flag: Este debate ha sido marcado como inapropiado por varios usuarios.
|
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."
|
edit: "Antes de que se publique podrás modificar el texto a tu gusto."
|
||||||
view_proposal: Ahora no, ir a mi propuesta
|
view_proposal: Ahora no, ir a mi propuesta
|
||||||
already_supported: '¡Ya has apoyado esta propuesta, compártela!'
|
already_supported: '¡Ya has apoyado esta propuesta, compártela!'
|
||||||
comments:
|
|
||||||
zero: Sin comentarios
|
|
||||||
one: 1 Comentario
|
|
||||||
other: "%{count} Comentarios"
|
|
||||||
support: Apoyar
|
support: Apoyar
|
||||||
support_label: "Apoyar %{proposal}"
|
support_label: "Apoyar %{proposal}"
|
||||||
support_title: Apoyar esta propuesta
|
support_title: Apoyar esta propuesta
|
||||||
@@ -420,10 +408,6 @@ es:
|
|||||||
show:
|
show:
|
||||||
author_deleted: Usuario eliminado
|
author_deleted: Usuario eliminado
|
||||||
code: "Código de la propuesta:"
|
code: "Código de la propuesta:"
|
||||||
comments:
|
|
||||||
zero: Sin comentarios
|
|
||||||
one: 1 Comentario
|
|
||||||
other: "%{count} Comentarios"
|
|
||||||
comments_tab: Comentarios
|
comments_tab: Comentarios
|
||||||
dashboard_proposal_link: Panel de control
|
dashboard_proposal_link: Panel de control
|
||||||
flag: Esta propuesta ha sido marcada como inapropiada por varios usuarios.
|
flag: Esta propuesta ha sido marcada como inapropiada por varios usuarios.
|
||||||
@@ -763,6 +747,10 @@ es:
|
|||||||
other: "%{count} idiomas en uso"
|
other: "%{count} idiomas en uso"
|
||||||
optional: "Campos opcionales"
|
optional: "Campos opcionales"
|
||||||
required: "Campos obligatorios"
|
required: "Campos obligatorios"
|
||||||
|
comments:
|
||||||
|
one: "1 comentario"
|
||||||
|
other: "%{count} comentarios"
|
||||||
|
zero: "Sin comentarios"
|
||||||
social:
|
social:
|
||||||
facebook: "Facebook de %{org}"
|
facebook: "Facebook de %{org}"
|
||||||
twitter: "Twitter de %{org}"
|
twitter: "Twitter de %{org}"
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ es:
|
|||||||
comments:
|
comments:
|
||||||
see_all: Ver todos
|
see_all: Ver todos
|
||||||
see_complete: Ver completo
|
see_complete: Ver completo
|
||||||
comments_count:
|
|
||||||
one: "%{count} comentario"
|
|
||||||
other: "%{count} comentarios"
|
|
||||||
replies_count:
|
replies_count:
|
||||||
one: "%{count} respuesta"
|
one: "%{count} respuesta"
|
||||||
other: "%{count} respuestas"
|
other: "%{count} respuestas"
|
||||||
@@ -18,9 +15,6 @@ es:
|
|||||||
title: Comentarios
|
title: Comentarios
|
||||||
comments_about: Comentarios sobre
|
comments_about: Comentarios sobre
|
||||||
see_in_context: Ver en contexto
|
see_in_context: Ver en contexto
|
||||||
comments_count:
|
|
||||||
one: "%{count} comentario"
|
|
||||||
other: "%{count} comentarios"
|
|
||||||
show:
|
show:
|
||||||
title: Comentario
|
title: Comentario
|
||||||
version_chooser:
|
version_chooser:
|
||||||
@@ -92,10 +86,6 @@ es:
|
|||||||
form:
|
form:
|
||||||
leave_comment: Deja tu respuesta
|
leave_comment: Deja tu respuesta
|
||||||
question:
|
question:
|
||||||
comments:
|
|
||||||
zero: Sin comentarios
|
|
||||||
one: "%{count} comentario"
|
|
||||||
other: "%{count} comentarios"
|
|
||||||
debate: Debate
|
debate: Debate
|
||||||
show:
|
show:
|
||||||
answer_question: Enviar respuesta
|
answer_question: Enviar respuesta
|
||||||
@@ -134,10 +124,6 @@ es:
|
|||||||
zero: "No hay propuestas"
|
zero: "No hay propuestas"
|
||||||
one: "%{count} propuesta"
|
one: "%{count} propuesta"
|
||||||
other: "%{count} propuestas"
|
other: "%{count} propuestas"
|
||||||
comments:
|
|
||||||
zero: "No hay comentarios"
|
|
||||||
one: "%{count} comentario"
|
|
||||||
other: "%{count} comentarios"
|
|
||||||
download: "Descargar resumen"
|
download: "Descargar resumen"
|
||||||
top_comments:
|
top_comments:
|
||||||
zero: "No hay comentarios"
|
zero: "No hay comentarios"
|
||||||
|
|||||||
17
spec/components/shared/comments_count_component_spec.rb
Normal file
17
spec/components/shared/comments_count_component_spec.rb
Normal file
@@ -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
|
||||||
@@ -62,7 +62,11 @@ describe "Budget Investments" do
|
|||||||
investments.each do |investment|
|
investments.each do |investment|
|
||||||
within("#budget-investments") do
|
within("#budget-investments") do
|
||||||
expect(page).to have_content investment.title
|
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)
|
expect(page).not_to have_content(unfeasible_investment.title)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -849,6 +853,7 @@ describe "Budget Investments" do
|
|||||||
expect(page).to have_content(investment.title)
|
expect(page).to have_content(investment.title)
|
||||||
expect(page).to have_content(investment.description)
|
expect(page).to have_content(investment.description)
|
||||||
expect(page).to have_content(investment.author.name)
|
expect(page).to have_content(investment.author.name)
|
||||||
|
expect(page).to have_content(investment.comments_count)
|
||||||
expect(page).to have_content(investment.heading.name)
|
expect(page).to have_content(investment.heading.name)
|
||||||
within("#investment_code") do
|
within("#investment_code") do
|
||||||
expect(page).to have_content(investment.id)
|
expect(page).to have_content(investment.id)
|
||||||
|
|||||||
@@ -109,5 +109,15 @@ describe "Legislation" do
|
|||||||
|
|
||||||
expect(page).not_to have_selector(:link_or_button, "Submit answer")
|
expect(page).not_to have_selector(:link_or_button, "Submit answer")
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user