Merge branch 'notes_refactoring'
This commit is contained in:
commit
21c141afb1
27 changed files with 130 additions and 81 deletions
|
@ -16,6 +16,7 @@
|
|||
- if @comments_allowed
|
||||
- comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse
|
||||
- unless comments.empty?
|
||||
- comments.each do |note|
|
||||
- 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 }
|
||||
|
|
|
@ -21,13 +21,13 @@
|
|||
%p.cgray
|
||||
Showing #{pluralize(@commit.diffs.count, "changed file")}
|
||||
= render "commits/diffs", :diffs => @commit.diffs
|
||||
= render "notes/notes"
|
||||
= render "notes/notes", :tid => @commit.id, :tt => "commit"
|
||||
= render "notes/per_line_form"
|
||||
|
||||
|
||||
:javascript
|
||||
$(document).ready(function(){
|
||||
$(".line_note_link").live("click", function(e) {
|
||||
$(".line_note_link, .line_note_reply_link").live("click", function(e) {
|
||||
var form = $(".per_line_form");
|
||||
$(this).parent().parent().after(form);
|
||||
form.find("#note_line_code").val($(this).attr("line_code"));
|
||||
|
|
|
@ -41,5 +41,4 @@
|
|||
%div= simple_format @issue.title
|
||||
|
||||
|
||||
.issue_notes= render "notes/notes"
|
||||
|
||||
.issue_notes= render "notes/notes", :tid => @issue.id, :tt => "issue"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
= render "notes/load"
|
|
@ -63,10 +63,7 @@
|
|||
%img{:src => "/assets/ajax-loader-facebook.gif", :class => "dashboard-loader"}
|
||||
|
||||
.merge-request-notes
|
||||
.merge_request_notes= render "notes/notes"
|
||||
.loading{ :style => "display:none;"}
|
||||
%center= image_tag "ajax-loader.gif"
|
||||
.clear
|
||||
.merge_request_notes= render "notes/notes", :tid => @merge_request.id, :tt => "merge_request"
|
||||
|
||||
.merge-request-diffs
|
||||
|
||||
|
@ -75,3 +72,15 @@
|
|||
$(function(){
|
||||
MergeRequest.init();
|
||||
})
|
||||
|
||||
= render "notes/per_line_form"
|
||||
:javascript
|
||||
$(document).ready(function(){
|
||||
$(".line_note_link, .line_note_reply_link").live("click", function(e) {
|
||||
var form = $(".per_line_form");
|
||||
$(this).parent().parent().after(form);
|
||||
form.find("#note_line_code").val($(this).attr("line_code"));
|
||||
form.show();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
|
9
app/views/notes/_create_common.js.haml
Normal file
9
app/views/notes/_create_common.js.haml
Normal file
|
@ -0,0 +1,9 @@
|
|||
- if note.valid?
|
||||
:plain
|
||||
$("#new_note .errors").remove();
|
||||
$('#new_note textarea').val("");
|
||||
NoteList.prepend(#{note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => note})}");
|
||||
- else
|
||||
:plain
|
||||
$("#new_note").replaceWith("#{escape_javascript(render('form'))}");
|
||||
|
8
app/views/notes/_create_line.js.haml
Normal file
8
app/views/notes/_create_line.js.haml
Normal file
|
@ -0,0 +1,8 @@
|
|||
- if note.valid?
|
||||
:plain
|
||||
$(".per_line_form").hide();
|
||||
$('#new_note 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})}");
|
|
@ -2,7 +2,9 @@
|
|||
= render "notes/form"
|
||||
.clear
|
||||
%hr
|
||||
%ul#notes-list= render "notes/notes_list"
|
||||
%ul#notes-list
|
||||
.loading
|
||||
|
||||
|
||||
:javascript
|
||||
$('.delete-note').live('ajax:success', function() {
|
||||
|
@ -22,5 +24,5 @@
|
|||
$('.attach_holder').show();
|
||||
});
|
||||
|
||||
NoteList.init("wall", #{@notes.last.try(:id) || 0}, #{@notes.first.try(:id) || 0});
|
||||
NoteList.init("#{tid}", "#{tt}", "#{project_notes_path(@project)}");
|
||||
});
|
||||
|
|
3
app/views/notes/_reply_button.html.haml
Normal file
3
app/views/notes/_reply_button.html.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
%tr.line_notes_row.reply
|
||||
%td{:colspan => 3}
|
||||
= link_to "Reply", "#", :class => "line_note_reply_link", "line_code" => line_code, :title => "Add note for this line"
|
|
@ -6,7 +6,7 @@
|
|||
= time_ago_in_words(note.updated_at)
|
||||
ago
|
||||
- if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
|
||||
= link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note right"
|
||||
%strong= link_to "Remove", [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "cred delete-note btn small"
|
||||
|
||||
%div.note-title
|
||||
= markdown(note.note)
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
- if @note.valid?
|
||||
- if @note.line_code
|
||||
:plain
|
||||
$(".per_line_form").hide();
|
||||
$('#new_note textarea').val("");
|
||||
$(".#{@note.line_code}").parent().after("#{escape_javascript(render :partial => "notes/per_line_show", :locals => {:note => @note})}");
|
||||
- else
|
||||
:plain
|
||||
$("#new_note .errors").remove();
|
||||
$('#new_note textarea').val("");
|
||||
NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}");
|
||||
- else
|
||||
- unless @note.line_code
|
||||
:plain
|
||||
$("#new_note").replaceWith("#{escape_javascript(render('form'))}");
|
||||
- if @note.line_code
|
||||
= render "create_line", :note => @note
|
||||
- else
|
||||
= render "create_common", :note => @note
|
||||
|
||||
-# Enable submit button
|
||||
:plain
|
||||
$("#submit_note").removeAttr("disabled");
|
||||
|
|
|
@ -1,6 +1,2 @@
|
|||
%div.wall_page
|
||||
= render "notes/notes"
|
||||
|
||||
.loading{ :style => "display:none;"}
|
||||
%center= image_tag "ajax-loader.gif"
|
||||
|
||||
= render "notes/notes", :tid => nil, :tt => "wall"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
= render "notes/load"
|
|
@ -14,8 +14,5 @@
|
|||
.data.no-padding
|
||||
:erb
|
||||
<%= raw @snippet.colorize %>
|
||||
.clear
|
||||
%br
|
||||
.snippet_notes= render "notes/notes"
|
||||
|
||||
.clear
|
||||
= render "notes/notes", :tid => @snippet.id, :tt => "snippet"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue