Show parent comment responses when a new reply is added
When a user replies to a comment whose responses was hidden at the moment of reply form submission and although the reply were correctly added to the DOM it was hidden because was added to a collapsed list. This solution is about showing all responses of parent comment after adding the new comment to the DOM so the user can see new reply into the screen. (This is not applicable to root comments which cannot be collapsed)
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
App.Comments = {
|
||||
add_comment: function(parent_selector, response_html) {
|
||||
$(parent_selector + " .comment-list:first").prepend($(response_html));
|
||||
var hidden_responses = $(parent_selector + " .comment-list:first").is(":hidden");
|
||||
if (parent_selector && hidden_responses) {
|
||||
$(parent_selector).find(".comment-list:first").toggle("slow");
|
||||
}
|
||||
this.update_comments_count();
|
||||
},
|
||||
update_comments_count: function() {
|
||||
|
||||
@@ -257,6 +257,23 @@ describe "Commenting Budget::Investments" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply show parent comments responses when hidden", :js do
|
||||
comment = create(:comment, commentable: investment)
|
||||
create(:comment, commentable: investment, parent: comment)
|
||||
|
||||
login_as(create(:user))
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link text: "1 response (collapse)"
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("It will be done next week.")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: investment, user: user)
|
||||
|
||||
|
||||
@@ -231,6 +231,23 @@ describe "Internal valuation comments on Budget::Investments" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply show parent comments responses when hidden", :js do
|
||||
comment = create(:comment, :valuation, author: admin_user, commentable: investment)
|
||||
create(:comment, :valuation, author: admin_user, commentable: investment, parent: comment)
|
||||
|
||||
login_as(valuator_user)
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link text: "1 response (collapse)"
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("It will be done next week.")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply without comment text", :js do
|
||||
comment = create(:comment, :valuation, author: admin_user, commentable: investment)
|
||||
|
||||
|
||||
@@ -296,6 +296,23 @@ describe "Commenting debates" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply show parent comments responses when hidden", :js do
|
||||
comment = create(:comment, commentable: debate)
|
||||
create(:comment, commentable: debate, parent: comment)
|
||||
|
||||
login_as(create(:user))
|
||||
visit debate_path(debate)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link text: "1 response (collapse)"
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("It will be done next week.")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: debate, user: user)
|
||||
|
||||
|
||||
@@ -297,6 +297,27 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply show parent comments responses when hidden", :js do
|
||||
manuela = create(:user, :level_two, username: "Manuela")
|
||||
legislation_annotation = create(:legislation_annotation)
|
||||
comment = legislation_annotation.comments.first
|
||||
create(:comment, commentable: legislation_annotation, parent: comment)
|
||||
|
||||
login_as(manuela)
|
||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link text: "1 response (collapse)"
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("It will be done next week.")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = legislation_annotation.comments.first
|
||||
|
||||
|
||||
@@ -276,6 +276,24 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply show parent comments responses when hidden", :js do
|
||||
manuela = create(:user, :level_two, username: "Manuela")
|
||||
comment = create(:comment, commentable: legislation_question)
|
||||
create(:comment, commentable: legislation_question, parent: comment)
|
||||
|
||||
login_as(manuela)
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link text: "1 response (collapse)"
|
||||
click_link "Reply"
|
||||
fill_in "Leave your answer", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("It will be done next week.")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: legislation_question, user: user)
|
||||
|
||||
|
||||
@@ -255,6 +255,23 @@ describe "Commenting polls" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply show parent comments responses when hidden", :js do
|
||||
comment = create(:comment, commentable: poll)
|
||||
create(:comment, commentable: poll, parent: comment)
|
||||
|
||||
login_as(create(:user))
|
||||
visit poll_path(poll)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link text: "1 response (collapse)"
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("It will be done next week.")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: poll, user: user)
|
||||
|
||||
|
||||
@@ -253,6 +253,23 @@ describe "Commenting proposals" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply show parent comments responses when hidden", :js do
|
||||
comment = create(:comment, commentable: proposal)
|
||||
create(:comment, commentable: proposal, parent: comment)
|
||||
|
||||
login_as(create(:user))
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link text: "1 response (collapse)"
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("It will be done next week.")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: proposal, user: user)
|
||||
|
||||
|
||||
@@ -281,6 +281,25 @@ describe "Commenting topics from proposals" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Reply show parent comments responses when hidden", :js do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
comment = create(:comment, commentable: topic)
|
||||
create(:comment, commentable: topic, parent: comment)
|
||||
|
||||
login_as(create(:user))
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within ".comment", text: comment.body do
|
||||
click_link text: "1 response (collapse)"
|
||||
click_link "Reply"
|
||||
fill_in "Leave your comment", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
|
||||
expect(page).to have_content("It will be done next week.")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on reply", :js do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
|
||||
Reference in New Issue
Block a user