diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index b9e69ddf9..491944c03 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -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 \ No newline at end of file +end diff --git a/app/views/comments/_comment_tree.html.erb b/app/views/comments/_comment_tree.html.erb index 0581809fb..746ab9225 100644 --- a/app/views/comments/_comment_tree.html.erb +++ b/app/views/comments/_comment_tree.html.erb @@ -6,7 +6,7 @@

- <%= t("debates.show.comments_title") %> + <%= comment_tree_title_text(commentable) %> (<%= commentable.comments_count %>)

diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index e3399c383..9d9767e73 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -2,13 +2,13 @@ <% css_id = parent_or_commentable_dom_id(parent_id, commentable) %>
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 %>
diff --git a/app/views/legislation/annotations/show.html.erb b/app/views/legislation/annotations/show.html.erb index cdfa04447..e03304e59 100644 --- a/app/views/legislation/annotations/show.html.erb +++ b/app/views/legislation/annotations/show.html.erb @@ -27,7 +27,7 @@
- <%= render 'legislation/shared/comments', commentable: @annotation %> + <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %>
diff --git a/app/views/legislation/questions/show.html.erb b/app/views/legislation/questions/show.html.erb index c74bd9efa..b99e7b17f 100644 --- a/app/views/legislation/questions/show.html.erb +++ b/app/views/legislation/questions/show.html.erb @@ -47,7 +47,7 @@ - - <%= render 'legislation/shared/comments', commentable: @question %> + + <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %> diff --git a/app/views/legislation/shared/_comments.html.erb b/app/views/legislation/shared/_comments.html.erb deleted file mode 100644 index 25b4ce18d..000000000 --- a/app/views/legislation/shared/_comments.html.erb +++ /dev/null @@ -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 %> -
-
-

- <%= t("legislation.shared.comments") %> - (<%= commentable.comments_count %>) -

- - <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> - - <% if user_signed_in? %> - <%= render 'comments/form', {commentable: commentable, parent_id: nil, toggeable: false} %> - <% else %> -
- -
- <%= 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 %> -
- <% end %> - - <% @comment_tree.root_comments.each do |comment| %> - <%= render 'comments/comment', comment: comment %> - <% end %> - <%= paginate @comment_tree.root_comments %> -
-
-<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 30cdbcb69..2f192cb0c 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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: diff --git a/config/locales/es.yml b/config/locales/es.yml index 17832f708..7c418521f 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -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: diff --git a/config/locales/legislation.en.yml b/config/locales/legislation.en.yml index 8185377bf..294d35104 100644 --- a/config/locales/legislation.en.yml +++ b/config/locales/legislation.en.yml @@ -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 diff --git a/config/locales/legislation.es.yml b/config/locales/legislation.es.yml index c84607c3d..6f0d5d5e7 100644 --- a/config/locales/legislation.es.yml +++ b/config/locales/legislation.es.yml @@ -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 diff --git a/spec/features/comments/legislation_questions_spec.rb b/spec/features/comments/legislation_questions_spec.rb index c8f929b9e..253c25b99 100644 --- a/spec/features/comments/legislation_questions_spec.rb +++ b/spec/features/comments/legislation_questions_spec.rb @@ -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!" diff --git a/spec/features/legislation/questions_spec.rb b/spec/features/legislation/questions_spec.rb index c9513e9de..77503b5a9 100644 --- a/spec/features/legislation/questions_spec.rb +++ b/spec/features/legislation/questions_spec.rb @@ -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