Merge branch 'change-notes-order' of https://github.com/riyad/gitlabhq into riyad-change-notes-order
This commit is contained in:
commit
caeb65b189
32 changed files with 384 additions and 270 deletions
|
@ -13,14 +13,11 @@
|
|||
%td.old_line
|
||||
= link_to raw(type == "new" ? " " : line_old), "##{line_code}", id: line_code
|
||||
- if @comments_allowed
|
||||
= link_to "", "#", class: "line_note_link", "line_code" => line_code, title: "Add note for this line"
|
||||
= render "notes/per_line_note_link", line_code: line_code
|
||||
%td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code
|
||||
%td.line_content{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line} "
|
||||
|
||||
- if @comments_allowed
|
||||
- comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse
|
||||
- comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at)
|
||||
- unless comments.empty?
|
||||
- comments.each_with_index do |note, i|
|
||||
= render "notes/reply_button", line_code: line_code if i.zero?
|
||||
= render "notes/per_line_show", note: note
|
||||
- @line_notes.reject!{ |n| n == note }
|
||||
= render "notes/per_line_notes_with_reply", notes: comments
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
= render "commits/commit_box"
|
||||
= render "commits/diffs", diffs: @commit.diffs
|
||||
= render "notes/notes", tid: @commit.id, tt: "commit"
|
||||
= render "notes/notes_with_form", tid: @commit.id, tt: "commit"
|
||||
= render "notes/per_line_form"
|
||||
|
||||
|
||||
|
|
|
@ -61,4 +61,4 @@
|
|||
= markdown @issue.description
|
||||
|
||||
|
||||
.issue_notes#notes= render "notes/notes", tid: @issue.id, tt: "issue"
|
||||
.issue_notes#notes= render "notes/notes_with_form", tid: @issue.id, tt: "issue"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
Diff
|
||||
|
||||
.merge_request_notes#notes{ class: (controller.action_name == 'show') ? "" : "hide" }
|
||||
= render("notes/notes", tid: @merge_request.id, tt: "merge_request")
|
||||
= render("notes/notes_with_form", tid: @merge_request.id, tt: "merge_request")
|
||||
.merge-request-diffs
|
||||
= render "merge_requests/show/diffs" if @diffs
|
||||
.status
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
:plain
|
||||
$(".merge-request-notes").html("#{escape_javascript(render("notes/notes", tid: @merge_request.id, tt: "merge_request"))}");
|
||||
$(".merge-request-notes").html("#{escape_javascript(render notes/notes_with_form", tid: @merge_request.id, tt: "merge_request")}");
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
$('.note-form-holder #preview-link').text('Preview');
|
||||
$('.note-form-holder #preview-note').hide();
|
||||
$('.note-form-holder').show();
|
||||
NoteList.prepend(#{note.id}, "#{escape_javascript(render partial: "notes/show", locals: {note: note})}");
|
||||
NoteList.appendNewNote(#{note.id}, "#{escape_javascript(render "notes/note", note: note)}");
|
||||
|
||||
- else
|
||||
:plain
|
||||
$(".note-form-holder").replaceWith("#{escape_javascript(render('form'))}");
|
||||
$(".note-form-holder").replaceWith("#{escape_javascript(render 'form')}");
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
- if note.valid?
|
||||
:plain
|
||||
$(".per_line_form").hide();
|
||||
$('.line-note-form-holder textarea').val("");
|
||||
$("a.line_note_reply_link[line_code='#{note.line_code}']").closest("tr").remove();
|
||||
var trEl = $(".#{note.line_code}").parent();
|
||||
trEl.after("#{escape_javascript(render partial: "notes/per_line_show", locals: {note: note})}");
|
||||
trEl.after("#{escape_javascript(render partial: "notes/reply_button", locals: {line_code: note.line_code})}");
|
19
app/views/notes/_create_per_line_note.js.haml
Normal file
19
app/views/notes/_create_per_line_note.js.haml
Normal file
|
@ -0,0 +1,19 @@
|
|||
- if note.valid?
|
||||
:plain
|
||||
// hide and reset the form
|
||||
$(".per_line_form").hide();
|
||||
$('.line-note-form-holder textarea').val("");
|
||||
|
||||
// find the reply button for this line
|
||||
// (might not be there if this is the first note)
|
||||
var trRpl = $("a.line_note_reply_link[data-line-code='#{note.line_code}']").closest("tr");
|
||||
if (trRpl.size() == 0) {
|
||||
// find the commented line ...
|
||||
var trEl = $(".#{note.line_code}").parent();
|
||||
// ... and insert the note and the reply button after it
|
||||
trEl.after("#{escape_javascript(render "notes/per_line_reply_button", line_code: note.line_code)}");
|
||||
trEl.after("#{escape_javascript(render "notes/per_line_note", note: note)}");
|
||||
} else {
|
||||
// instert new note before reply button
|
||||
trRpl.before("#{escape_javascript(render "notes/per_line_note", note: note)}");
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
- unless @notes.blank?
|
||||
- if params[:last_id]
|
||||
:plain
|
||||
NoteList.replace("#{escape_javascript(render(partial: 'notes/notes_list'))}");
|
||||
|
||||
- elsif params[:first_id]
|
||||
:plain
|
||||
NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(partial: 'notes/notes_list'))}");
|
||||
|
||||
- else
|
||||
:plain
|
||||
NoteList.setContent(#{@notes.last.id}, #{@notes.first.id}, "#{escape_javascript(render(partial: 'notes/notes_list'))}");
|
||||
|
||||
- else
|
||||
- if params[:first_id]
|
||||
:plain
|
||||
NoteList.append(#{params[:first_id]}, "");
|
|
@ -1,13 +1,4 @@
|
|||
- if can? current_user, :write_note, @project
|
||||
= render "notes/form"
|
||||
.clear
|
||||
%hr
|
||||
%ul#new_notes_list
|
||||
%ul#notes-list
|
||||
.status
|
||||
- @notes.each do |note|
|
||||
- next unless note.author
|
||||
= render "note", note: note
|
||||
|
||||
|
||||
:javascript
|
||||
$(function(){
|
||||
NoteList.init("#{tid}", "#{tt}", "#{project_notes_path(@project)}");
|
||||
});
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
- @notes.each do |note|
|
||||
- next unless note.author
|
||||
= render partial: "notes/show", locals: {note: note}
|
||||
|
11
app/views/notes/_notes_with_form.html.haml
Normal file
11
app/views/notes/_notes_with_form.html.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
%ul#notes-list
|
||||
%ul#new-notes-list
|
||||
.notes-status
|
||||
|
||||
- if can? current_user, :write_note, @project
|
||||
= render "notes/common_form"
|
||||
|
||||
:javascript
|
||||
$(function(){
|
||||
NoteList.init("#{tid}", "#{tt}", "#{project_notes_path(@project)}");
|
||||
});
|
5
app/views/notes/_per_line_note.html.haml
Normal file
5
app/views/notes/_per_line_note.html.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
%tr.line_notes_row
|
||||
%td{colspan: 3}
|
||||
%ul
|
||||
= render "notes/note", note: note
|
||||
|
1
app/views/notes/_per_line_note_link.html.haml
Normal file
1
app/views/notes/_per_line_note_link.html.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= link_to "", "#", class: "line_note_link", data: { line_code: line_code }, title: "Add note for this line"
|
3
app/views/notes/_per_line_notes_with_reply.html.haml
Normal file
3
app/views/notes/_per_line_notes_with_reply.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
- notes.each do |note|
|
||||
= render "notes/per_line_note", note: note
|
||||
= render "notes/per_line_reply_button", line_code: notes.first.line_code
|
4
app/views/notes/_per_line_reply_button.html.haml
Normal file
4
app/views/notes/_per_line_reply_button.html.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
%tr.line_notes_row.reply
|
||||
%td{colspan: 3}
|
||||
%i.icon-comment
|
||||
= link_to "Reply", "#", class: "line_note_reply_link", data: { line_code: line_code }, title: "Add note for this line"
|
|
@ -1,5 +0,0 @@
|
|||
%tr.line_notes_row
|
||||
%td{colspan: 3}
|
||||
%ul
|
||||
= render partial: "notes/show", locals: {note: note}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
%tr.line_notes_row.reply
|
||||
%td{colspan: 3}
|
||||
%i.icon-comment
|
||||
= link_to "Reply", "#", class: "line_note_reply_link", "line_code" => line_code, title: "Add note for this line"
|
11
app/views/notes/_reversed_notes_with_form.html.haml
Normal file
11
app/views/notes/_reversed_notes_with_form.html.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
- if can? current_user, :write_note, @project
|
||||
= render "notes/common_form"
|
||||
|
||||
%ul.reversed#new-notes-list
|
||||
%ul.reversed#notes-list
|
||||
.notes-status
|
||||
|
||||
:javascript
|
||||
$(function(){
|
||||
NoteList.init("#{tid}", "#{tt}", "#{project_notes_path(@project)}");
|
||||
});
|
|
@ -1,7 +1,7 @@
|
|||
- if @note.line_code
|
||||
= render "create_line", note: @note
|
||||
= render "create_per_line_note", note: @note
|
||||
- else
|
||||
= render "create_common", note: @note
|
||||
= render "create_common_note", note: @note
|
||||
|
||||
-# Enable submit button
|
||||
:plain
|
||||
|
|
|
@ -1 +1,17 @@
|
|||
= render "notes/load"
|
||||
- unless @notes.blank?
|
||||
- if loading_more_notes?
|
||||
:plain
|
||||
NoteList.appendMoreNotes(#{@notes.last.id}, "#{escape_javascript(render 'notes/notes')}");
|
||||
|
||||
- elsif loading_new_notes?
|
||||
:plain
|
||||
NoteList.replaceNewNotes("#{escape_javascript(render 'notes/notes')}");
|
||||
|
||||
- else
|
||||
:plain
|
||||
NoteList.setContent(#{@notes.first.id}, #{@notes.last.id}, "#{escape_javascript(render 'notes/notes')}");
|
||||
|
||||
- else
|
||||
- if loading_more_notes?
|
||||
:plain
|
||||
NoteList.finishedLoadingMore();
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
%div.wall_page
|
||||
= render "notes/notes", tid: nil, tt: "wall"
|
||||
= render "notes/reversed_notes_with_form", tid: nil, tt: "wall"
|
||||
|
|
|
@ -17,4 +17,4 @@
|
|||
%div{class: current_user.dark_scheme ? "black" : ""}
|
||||
= raw @snippet.colorize(options: { linenos: 'True'})
|
||||
|
||||
= render "notes/notes", tid: @snippet.id, tt: "snippet"
|
||||
= render "notes/notes_with_form", tid: @snippet.id, tt: "snippet"
|
||||
|
|
|
@ -21,4 +21,4 @@
|
|||
Delete this page
|
||||
|
||||
%hr
|
||||
.wiki_notes#notes= render "notes/notes", tid: @wiki.id, tt: "wiki"
|
||||
.wiki_notes#notes= render "notes/notes_with_form", tid: @wiki.id, tt: "wiki"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue