Change texts for legislation questions comments

This commit is contained in:
Amaia Castro
2017-01-17 15:03:48 +01:00
parent 108d788985
commit 53e9837db3
12 changed files with 48 additions and 49 deletions

View File

@@ -1,11 +1,31 @@
module CommentsHelper
def comment_tree_title_text(commentable)
if commentable.class == Legislation::Question
t("legislation.questions.comments.comments_title")
else
t("comments_helper.comments_title")
end
end
def leave_comment_text(commentable)
if commentable.class == Legislation::Question
t("legislation.questions.comments.form.leave_comment")
else
t("comments.form.leave_comment")
end
end
def comment_link_text(parent_id)
parent_id.present? ? t("comments_helper.reply_link") : t("comments_helper.comment_link")
end
def comment_button_text(parent_id)
parent_id.present? ? t("comments_helper.reply_button") : t("comments_helper.comment_button")
def comment_button_text(parent_id, commentable)
if commentable.class == Legislation::Question
parent_id.present? ? t("comments_helper.reply_button") : t("legislation.questions.comments.comment_button")
else
parent_id.present? ? t("comments_helper.reply_button") : t("comments_helper.comment_button")
end
end
def parent_or_commentable_dom_id(parent_id, commentable)
@@ -48,4 +68,4 @@ module CommentsHelper
end
end
end
end

View File

@@ -6,7 +6,7 @@
<div class="row">
<div id="comments" class="small-12 column">
<h2>
<%= t("debates.show.comments_title") %>
<%= comment_tree_title_text(commentable) %>
<span class="js-comments-count">(<%= commentable.comments_count %>)</span>
</h2>

View File

@@ -2,13 +2,13 @@
<% css_id = parent_or_commentable_dom_id(parent_id, commentable) %>
<div id="js-comment-form-<%= css_id %>" <%= "style='display:none'".html_safe if toggeable %> class="comment-form">
<%= form_for Comment.new, remote: true do |f| %>
<%= label_tag "comment-body-#{css_id}", t("comments.form.leave_comment") %>
<%= label_tag "comment-body-#{css_id}", leave_comment_text(commentable) %>
<%= f.text_area :body, id: "comment-body-#{css_id}", maxlength: Comment.body_max_length, label: false %>
<%= f.hidden_field :commentable_type, value: commentable.class.name %>
<%= f.hidden_field :commentable_id, value: commentable.id %>
<%= f.hidden_field :parent_id, value: parent_id %>
<%= f.submit comment_button_text(parent_id), class: "button" %>
<%= f.submit comment_button_text(parent_id, commentable), class: "button" %>
<% if can? :comment_as_moderator, commentable %>
<div class="float-right">

View File

@@ -27,7 +27,7 @@
</div>
</div>
<%= render 'legislation/shared/comments', commentable: @annotation %>
<%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %>
</div>
</div>

View File

@@ -47,7 +47,7 @@
</div>
</aside>
</div>
<%= render 'legislation/shared/comments', commentable: @question %>
<%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %>
</section>

View File

@@ -1,29 +0,0 @@
<% cache [locale_and_user_status, @current_order, commentable_cache_key(commentable), @comment_tree.comments, @comment_tree.comment_authors, commentable.comments_count, @comment_flags] do %>
<div class="row comments">
<div id="comments" class="small-12 column">
<h3>
<%= t("legislation.shared.comments") %>
<span class="js-comments-count">(<%= commentable.comments_count %>)</span>
</h3>
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render 'comments/form', {commentable: commentable, parent_id: nil, toggeable: false} %>
<% else %>
<br>
<div data-alert class="callout primary">
<%= t("debates.show.login_to_comment",
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
</div>
<% end %>
<% @comment_tree.root_comments.each do |comment| %>
<%= render 'comments/comment', comment: comment %>
<% end %>
<%= paginate @comment_tree.root_comments %>
</div>
</div>
<% end %>

View File

@@ -62,6 +62,7 @@ en:
comments_helper:
comment_button: Publish comment
comment_link: Comment
comments_title: Comments
reply_button: Publish reply
reply_link: Reply
debates:

View File

@@ -62,6 +62,7 @@ es:
comments_helper:
comment_button: Publicar comentario
comment_link: Comentar
comments_title: Comentarios
reply_button: Publicar respuesta
reply_link: Responder
debates:

View File

@@ -81,6 +81,11 @@ en:
allegations_dates: Allegations
final_publication_date: Final result publication
questions:
comments:
comment_button: Publish answer
comments_title: Open answers
form:
leave_comment: Leave your answer
question:
comments:
zero: No comments
@@ -105,5 +110,3 @@ en:
verified_only: Only verified users can participate, %{verify_account}.
verify_account: verify your account
debate_phase_not_open: Debate phase has finished and answers are not accepted anymore
shared:
comments: Comments

View File

@@ -81,6 +81,11 @@ es:
allegations_dates: Alegaciones
final_publication_date: Publicación resultados
questions:
comments:
comment_button: Publicar respuesta
comments_title: Respuestas abiertas
form:
leave_comment: Deja tu respuesta
question:
comments:
zero: Sin comentarios
@@ -105,5 +110,3 @@ es:
verified_only: Solo los usuarios verificados pueden participar en el debate, %{verify_account}.
verify_account: verifica tu cuenta
debate_phase_not_open: La fase de debate previo ya ha finalizado y en este momento no se aceptan respuestas
shared:
comments: Comentarios

View File

@@ -164,7 +164,7 @@ feature 'Commenting legislation questions' do
visit legislation_process_question_path(legislation_question.process, legislation_question)
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: 'Have you thought about...?'
click_button 'Publish comment'
click_button 'Publish answer'
within "#comments" do
expect(page).to have_content 'Have you thought about...?'
@@ -176,7 +176,7 @@ feature 'Commenting legislation questions' do
login_as(user)
visit legislation_process_question_path(legislation_question.process, legislation_question)
click_button 'Publish comment'
click_button 'Publish answer'
expect(page).to have_content "Can't be blank"
end
@@ -295,11 +295,11 @@ feature 'Commenting legislation questions' do
visit legislation_process_question_path(legislation_question.process, legislation_question)
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: 'Testing submit button!'
click_button 'Publish comment'
click_button 'Publish answer'
# The button's text should now be "..."
# This should be checked before the Ajax request is finished
expect(page).to_not have_button 'Publish comment'
expect(page).to_not have_button 'Publish answer'
expect(page).to have_content('Testing submit button!')
end
@@ -313,7 +313,7 @@ feature 'Commenting legislation questions' do
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "I am moderating!"
check "comment-as-moderator-legislation_question_#{legislation_question.id}"
click_button "Publish comment"
click_button "Publish answer"
within "#comments" do
expect(page).to have_content "I am moderating!"
@@ -369,7 +369,7 @@ feature 'Commenting legislation questions' do
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "I am your Admin!"
check "comment-as-administrator-legislation_question_#{legislation_question.id}"
click_button "Publish comment"
click_button "Publish answer"
within "#comments" do
expect(page).to have_content "I am your Admin!"

View File

@@ -38,7 +38,7 @@ feature 'Legislation' do
visit legislation_process_question_path(@process, @process.questions.first)
expect(page).to have_content("Question 1")
expect(page).to have_content("Comments (0)")
expect(page).to have_content("Open answers (0)")
end
scenario 'shows next question link in question page' do