Commit 6d9715d8 authored by Douwe Maan's avatar Douwe Maan

Show existing discussion when adding new comment on line with a hidden resolved discussion

parent ce1843b7
...@@ -224,7 +224,12 @@ ...@@ -224,7 +224,12 @@
}); });
$body.on("click", ".js-toggle-diff-comments", function(e) { $body.on("click", ".js-toggle-diff-comments", function(e) {
$(this).toggleClass('active'); $(this).toggleClass('active');
$(this).closest(".diff-file").find(".notes_holder").toggle(); var notesHolders = $(this).closest(".diff-file").find(".notes_holder");
if ($(this).hasClass('active')) {
notesHolders.show();
} else {
notesHolders.hide();
}
return e.preventDefault(); return e.preventDefault();
}); });
$document.off("click", '.js-confirm-danger'); $document.off("click", '.js-confirm-danger');
......
...@@ -637,16 +637,19 @@ ...@@ -637,16 +637,19 @@
nextRow = row.next(); nextRow = row.next();
hasNotes = nextRow.is(".notes_holder"); hasNotes = nextRow.is(".notes_holder");
addForm = false; addForm = false;
targetContent = ".notes_content"; notesContentSelector = ".notes_content";
rowCssToAdd = "<tr class=\"notes_holder js-temp-notes-holder\"><td class=\"notes_line\" colspan=\"2\"></td><td class=\"notes_content\"></td></tr>"; rowCssToAdd = "<tr class=\"notes_holder js-temp-notes-holder\"><td class=\"notes_line\" colspan=\"2\"></td><td class=\"notes_content\"><div class=\"content\"></div></td></tr>";
if (this.isParallelView()) { if (this.isParallelView()) {
lineType = $link.data("lineType"); lineType = $link.data("lineType");
targetContent += "." + lineType; notesContentSelector += "." + lineType;
rowCssToAdd = "<tr class=\"notes_holder js-temp-notes-holder\"><td class=\"notes_line\"></td><td class=\"notes_content parallel old\"></td><td class=\"notes_line\"></td><td class=\"notes_content parallel new\"></td></tr>"; rowCssToAdd = "<tr class=\"notes_holder js-temp-notes-holder\"><td class=\"notes_line old\"></td><td class=\"notes_content parallel old\"><div class=\"content\"></div></td><td class=\"notes_line new\"></td><td class=\"notes_content parallel new\"><div class=\"content\"></div></td></tr>";
} }
notesContentSelector += " .content";
if (hasNotes) { if (hasNotes) {
notesContent = nextRow.find(targetContent); nextRow.show();
notesContent = nextRow.find(notesContentSelector);
if (notesContent.length) { if (notesContent.length) {
notesContent.show();
replyButton = notesContent.find(".js-discussion-reply-button:visible"); replyButton = notesContent.find(".js-discussion-reply-button:visible");
if (replyButton.length) { if (replyButton.length) {
e.target = replyButton[0]; e.target = replyButton[0];
...@@ -660,11 +663,13 @@ ...@@ -660,11 +663,13 @@
} }
} else { } else {
row.after(rowCssToAdd); row.after(rowCssToAdd);
nextRow = row.next();
notesContent = nextRow.find(notesContentSelector);
addForm = true; addForm = true;
} }
if (addForm) { if (addForm) {
newForm = this.formClone.clone(); newForm = this.formClone.clone();
newForm.appendTo(row.next().find(targetContent)); newForm.appendTo(notesContent);
return this.setupDiscussionNoteForm($link, newForm); return this.setupDiscussionNoteForm($link, newForm);
} }
}; };
......
...@@ -88,7 +88,6 @@ class Note < ActiveRecord::Base ...@@ -88,7 +88,6 @@ class Note < ActiveRecord::Base
def grouped_diff_discussions def grouped_diff_discussions
active_notes = diff_notes.fresh.select(&:active?) active_notes = diff_notes.fresh.select(&:active?)
Discussion.for_diff_notes(active_notes). Discussion.for_diff_notes(active_notes).
reject(&:resolved?).
map { |d| [d.line_code, d] }.to_h map { |d| [d.line_code, d] }.to_h
end end
......
%tr.notes_holder - expanded = local_assigns.fetch(:expanded, discussion.expanded?)
%tr.notes_holder{class: ('hide' unless expanded)}
%td.notes_line{ colspan: 2 } %td.notes_line{ colspan: 2 }
%td.notes_content %td.notes_content
%ul.notes{ data: { discussion_id: discussion.id } } .content
= render partial: "projects/notes/note", collection: discussion.notes, as: :note = render "discussions/notes", discussion: discussion
.discussion-reply-holder
.discussion-with-resolve-btn{ role: "group" }
.btn-group{ role: "group" }
= link_to_reply_discussion(discussion)
.btn-group{ role: "group" }
= render "discussions/resolve_all", discussion: discussion
= render "discussions/jump_to_next", discussion: discussion
...@@ -11,4 +11,4 @@ ...@@ -11,4 +11,4 @@
= render "projects/diffs/line", line: line, diff_file: diff_file, plain: true = render "projects/diffs/line", line: line, diff_file: diff_file, plain: true
- if discussion.for_line?(line) - if discussion.for_line?(line)
= render "discussions/diff_discussion", discussion: discussion = render "discussions/diff_discussion", discussion: discussion, expanded: true
...@@ -44,4 +44,5 @@ ...@@ -44,4 +44,5 @@
- if discussion.diff_discussion? && discussion.diff_file - if discussion.diff_discussion? && discussion.diff_file
= render "discussions/diff_with_notes", discussion: discussion = render "discussions/diff_with_notes", discussion: discussion
- else - else
= render "discussions/notes", discussion: discussion .panel.panel-default
= render "discussions/notes", discussion: discussion
.panel.panel-default %ul.notes{ data: { discussion_id: discussion.id } }
.notes{ data: { discussion_id: discussion.id } } = render partial: "projects/notes/note", collection: discussion.notes, as: :note
%ul.notes.timeline
= render partial: "projects/notes/note", collection: discussion.notes, as: :note
.discussion-reply-holder .discussion-reply-holder
- if discussion.diff_discussion?
- line_type = local_assigns.fetch(:line_type, nil)
.btn-group-justified.discussion-with-resolve-btn{ role: "group" }
.btn-group{ role: "group" }
= link_to_reply_discussion(discussion, line_type)
.btn-group{ role: "group" }
= render "discussions/resolve_all", discussion: discussion
= render "discussions/jump_to_next", discussion: discussion
- else
= link_to_reply_discussion(discussion) = link_to_reply_discussion(discussion)
%tr.notes_holder - expanded = discussion_left.try(:expanded?) || discussion_right.try(:expanded?)
%tr.notes_holder{class: ('hide' unless expanded)}
- if discussion_left - if discussion_left
%td.notes_line.old %td.notes_line.old
%td.notes_content.parallel.old %td.notes_content.parallel.old
%ul.notes{ data: { discussion_id: discussion_left.id } } .content{class: ('hide' unless discussion_left.expanded?)}
= render partial: "projects/notes/note", collection: discussion_left.notes, as: :note = render "discussions/notes", discussion: discussion_left, line_type: 'old'
.discussion-reply-holder
.btn-group-justified.discussion-with-resolve-btn{ role: "group" }
.btn-group{ role: "group" }
= link_to_reply_discussion(discussion_left, 'old')
.btn-group{ role: "group" }
= render "discussions/resolve_all", discussion: discussion_left
= render "discussions/jump_to_next", discussion: discussion_left
- else - else
%td.notes_line.old= "" %td.notes_line.old= ""
%td.notes_content.parallel.old= "" %td.notes_content.parallel.old
.content
- if discussion_right - if discussion_right
%td.notes_line.new %td.notes_line.new
%td.notes_content.parallel.new %td.notes_content.parallel.new
%ul.notes{ data: { discussion_id: discussion_right.id } } .content{class: ('hide' unless discussion_right.expanded?)}
= render partial: "projects/notes/note", collection: discussion_right.notes, as: :note = render "discussions/notes", discussion: discussion_right, line_type: 'new'
.discussion-reply-holder
.btn-group-justified.discussion-with-resolve-btn{ role: "group" }
.btn-group{ role: "group" }
= link_to_reply_discussion(discussion_right, 'new')
.btn-group{ role: "group" }
= render "discussions/resolve_all", discussion: discussion_right
= render "discussions/jump_to_next", discussion: discussion_right
- else - else
%td.notes_line.new= "" %td.notes_line.new= ""
%td.notes_content.parallel.new= "" %td.notes_content.parallel.new
.content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment