Commit 8a23682fc5212918c931888bb7b468d167d19c33
1 parent
ca1e3d05
Exists in
master
and in
4 other branches
refactored too
Showing
11 changed files
with
56 additions
and
53 deletions
Show diff stats
app/assets/stylesheets/projects.css.scss
app/controllers/commits_controller.rb
... | ... | @@ -28,12 +28,15 @@ class CommitsController < ApplicationController |
28 | 28 | |
29 | 29 | def show |
30 | 30 | @commit = project.repo.commits(params[:id]).first |
31 | - @notes = project.notes.where(:noteable_id => @commit.id, :noteable_type => "Commit") | |
31 | + @notes = project.notes.where(:noteable_id => @commit.id, :noteable_type => "Commit").order("created_at DESC").limit(20) | |
32 | 32 | @note = @project.notes.new(:noteable_id => @commit.id, :noteable_type => "Commit") |
33 | 33 | |
34 | - respond_to do |format| | |
35 | - format.html # show.html.erb | |
36 | - format.js | |
34 | + respond_to do |format| | |
35 | + format.html | |
36 | + format.js do | |
37 | + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] | |
38 | + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] | |
39 | + end | |
37 | 40 | end |
38 | 41 | end |
39 | 42 | end | ... | ... |
app/controllers/issues_controller.rb
... | ... | @@ -35,8 +35,16 @@ class IssuesController < ApplicationController |
35 | 35 | end |
36 | 36 | |
37 | 37 | def show |
38 | - @notes = @issue.notes.order("created_at ASC") | |
38 | + @notes = @issue.notes.order("created_at DESC").limit(20) | |
39 | 39 | @note = @project.notes.new(:noteable => @issue) |
40 | + | |
41 | + respond_to do |format| | |
42 | + format.html | |
43 | + format.js do | |
44 | + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] | |
45 | + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] | |
46 | + end | |
47 | + end | |
40 | 48 | end |
41 | 49 | |
42 | 50 | def create | ... | ... |
app/views/commits/show.js.haml
1 | --#:plain | |
2 | - $("#side-commit-preview").remove(); | |
3 | - var side = $("<div id='side-commit-preview'></div>"); | |
4 | - side.html("#{escape_javascript(render "commits/show")}"); | |
5 | - $("##{dom_id(@project)}").parent().append(side); | |
6 | - $("##{dom_id(@project)}").addClass("span-14"); | |
7 | -:plain | |
8 | - $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); | |
1 | += render "notes/load" | ... | ... |
app/views/issues/show.html.haml
1 | 1 | %h2 |
2 | 2 | = "Issue ##{@issue.id} - #{html_escape(@issue.title)}" |
3 | 3 | .left.width-65p |
4 | - -#= simple_format html_escape(@issue.content) | |
5 | 4 | .issue_notes= render "notes/notes" |
5 | + | |
6 | + .loading{ :style => "display:none;"} | |
7 | + %center= image_tag "ajax-loader.gif" | |
6 | 8 | .right.width-30p |
7 | 9 | .span-8 |
8 | 10 | - if @issue.closed |
... | ... | @@ -55,3 +57,12 @@ |
55 | 57 | .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" |
56 | 58 | .clear |
57 | 59 | |
60 | +:javascript | |
61 | + $(function(){ | |
62 | + $("#note_note").live("click", function(){ | |
63 | + $(this).css("height", "100px"); | |
64 | + $('.attach_holder').show(); | |
65 | + }); | |
66 | + | |
67 | + NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id}); | |
68 | + }); | ... | ... |
app/views/issues/show.js.haml
... | ... | @@ -0,0 +1,10 @@ |
1 | +- unless @notes.blank? | |
2 | + | |
3 | + - if params[:last_id] | |
4 | + :plain | |
5 | + NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); | |
6 | + | |
7 | + - if params[:first_id] | |
8 | + :plain | |
9 | + NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); | |
10 | + | ... | ... |
app/views/notes/_notes.html.haml
1 | -- if controller.action_name == "wall" | |
2 | - %ul#notes-list= render "notes/notes_list" | |
3 | - | |
4 | -- else | |
5 | - %ul#notes-list= render "notes/notes_list" | |
6 | - %br | |
7 | - %br | |
8 | - - if can? current_user, :write_note, @project | |
9 | - = render "notes/form" | |
1 | +- if can? current_user, :write_note, @project | |
2 | + = render "notes/form" | |
3 | +.clear | |
4 | +%hr | |
5 | +%ul#notes-list= render "notes/notes_list" | |
10 | 6 | |
11 | 7 | :javascript |
12 | 8 | $('.delete-note').live('ajax:success', function() { |
... | ... | @@ -20,8 +16,11 @@ |
20 | 16 | $("#submit_note").removeAttr("disabled"); |
21 | 17 | }) |
22 | 18 | |
23 | --#- if ["issues", "projects"].include?(controller.controller_name) | |
24 | - :javascript | |
25 | - $(function(){ | |
26 | - var int =self.setInterval("updatePage('ref=#{params[:ref]}')", 20000); | |
19 | + $(function(){ | |
20 | + $("#note_note").live("click", function(){ | |
21 | + $(this).css("height", "100px"); | |
22 | + $('.attach_holder').show(); | |
27 | 23 | }); |
24 | + | |
25 | + NoteList.init("wall", #{@notes.last.try(:id) || 0}, #{@notes.first.try(:id) || 0}); | |
26 | + }); | ... | ... |
app/views/notes/create.js.haml
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | :plain |
3 | 3 | $("#new_note .errors").remove(); |
4 | 4 | $('#note_note').val(""); |
5 | + NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}"); | |
5 | 6 | - else |
6 | 7 | :plain |
7 | 8 | $("#new_note").replaceWith("#{escape_javascript(render('form'))}"); | ... | ... |
app/views/projects/wall.html.haml
1 | 1 | %div.wall_page |
2 | - - if can? current_user, :write_note, @project | |
3 | - = render "notes/form" | |
4 | - .clear | |
5 | - %hr | |
6 | -= render "notes/notes" | |
2 | + = render "notes/notes" | |
7 | 3 | |
8 | 4 | .loading{ :style => "display:none;"} |
9 | 5 | %center= image_tag "ajax-loader.gif" |
10 | 6 | |
11 | -:javascript | |
12 | - $(function(){ | |
13 | - $("#note_note").live("click", function(){ | |
14 | - $(this).css("height", "100px"); | |
15 | - $('.attach_holder').show(); | |
16 | - }); | |
17 | - | |
18 | - NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id}); | |
19 | - }); | ... | ... |
app/views/projects/wall.js.haml
1 | -- unless @notes.blank? | |
2 | - | |
3 | - - if params[:last_id] | |
4 | - :plain | |
5 | - NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); | |
6 | - | |
7 | - - if params[:first_id] | |
8 | - :plain | |
9 | - NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}"); | |
1 | += render "notes/load" | ... | ... |