Commit 124a5e270e581bf3928559bd2de2c9c973c30952
1 parent
4d378f3c
Exists in
master
and in
4 other branches
add attachemnts support for wall
Showing
6 changed files
with
56 additions
and
6 deletions
Show diff stats
app/assets/javascripts/notes.js
@@ -4,7 +4,6 @@ var NoteList = { | @@ -4,7 +4,6 @@ var NoteList = { | ||
4 | target_params: null, | 4 | target_params: null, |
5 | target_id: 0, | 5 | target_id: 0, |
6 | target_type: null, | 6 | target_type: null, |
7 | - loading_more_disabled: false, | ||
8 | 7 | ||
9 | init: function(tid, tt, path) { | 8 | init: function(tid, tt, path) { |
10 | NoteList.notes_path = path + ".js"; | 9 | NoteList.notes_path = path + ".js"; |
app/assets/javascripts/wall.js.coffee
@@ -9,6 +9,7 @@ | @@ -9,6 +9,7 @@ | ||
9 | Wall.notes_path = "/api/" + gon.api_version + "/projects/" + project_id + "/notes.json" | 9 | Wall.notes_path = "/api/" + gon.api_version + "/projects/" + project_id + "/notes.json" |
10 | Wall.getContent() | 10 | Wall.getContent() |
11 | Wall.initRefresh() | 11 | Wall.initRefresh() |
12 | + Wall.initForm() | ||
12 | 13 | ||
13 | # | 14 | # |
14 | # Gets an initial set of notes. | 15 | # Gets an initial set of notes. |
@@ -28,6 +29,7 @@ | @@ -28,6 +29,7 @@ | ||
28 | if $.inArray(note.id, Wall.note_ids) == -1 | 29 | if $.inArray(note.id, Wall.note_ids) == -1 |
29 | Wall.note_ids.push(note.id) | 30 | Wall.note_ids.push(note.id) |
30 | Wall.renderNote(note) | 31 | Wall.renderNote(note) |
32 | + Wall.scrollDown() | ||
31 | 33 | ||
32 | complete: -> | 34 | complete: -> |
33 | $('.js-notes-busy').removeClass("loading") | 35 | $('.js-notes-busy').removeClass("loading") |
@@ -35,8 +37,15 @@ | @@ -35,8 +37,15 @@ | ||
35 | $('.js-notes-busy').addClass("loading") | 37 | $('.js-notes-busy').addClass("loading") |
36 | 38 | ||
37 | renderNote: (note) -> | 39 | renderNote: (note) -> |
38 | - author = '<strong>' + note.author.name + ': </strong>' | ||
39 | - html = '<li>' + author + note.body + '</li>' | 40 | + author = '<strong class="wall-author">' + note.author.name + '</strong>' |
41 | + body = '<span class="wall-text">' + note.body + '</span>' | ||
42 | + file = '' | ||
43 | + | ||
44 | + if note.attachment | ||
45 | + file = '<span class="wall-file"><a href="/files/note/' + note.id + '/' + note.attachment + '">' + note.attachment + '</a></span>' | ||
46 | + | ||
47 | + html = '<li>' + author + body + file + '</li>' | ||
48 | + | ||
40 | $('ul.notes').append(html) | 49 | $('ul.notes').append(html) |
41 | 50 | ||
42 | initRefresh: -> | 51 | initRefresh: -> |
@@ -44,3 +53,33 @@ | @@ -44,3 +53,33 @@ | ||
44 | 53 | ||
45 | refresh: -> | 54 | refresh: -> |
46 | Wall.getContent() | 55 | Wall.getContent() |
56 | + | ||
57 | + scrollDown: -> | ||
58 | + notes = $('ul.notes') | ||
59 | + $('body').scrollTop(notes.height()) | ||
60 | + | ||
61 | + initForm: -> | ||
62 | + form = $('.new_note') | ||
63 | + form.find("#target_type").val('wall') | ||
64 | + | ||
65 | + # remove unnecessary fields and buttons | ||
66 | + form.find("#note_line_code").remove() | ||
67 | + form.find(".js-close-discussion-note-form").remove() | ||
68 | + form.find('.js-notify-commit-author').remove() | ||
69 | + | ||
70 | + form.on 'ajax:success', -> | ||
71 | + Wall.refresh() | ||
72 | + form.find(".js-note-text").val("").trigger("input") | ||
73 | + | ||
74 | + form.on 'ajax:complete', -> | ||
75 | + form.find(".js-comment-button").removeAttr('disabled') | ||
76 | + form.find(".js-comment-button").removeClass('disabled') | ||
77 | + | ||
78 | + form.on "click", ".js-choose-note-attachment-button", -> | ||
79 | + form.find(".js-note-attachment-input").click() | ||
80 | + | ||
81 | + form.on "change", ".js-note-attachment-input", -> | ||
82 | + filename = $(this).val().replace(/^.*[\\\/]/, '') | ||
83 | + form.find(".js-attachment-filename").text(filename) | ||
84 | + | ||
85 | + form.show() |
app/assets/stylesheets/sections/wall.scss
@@ -10,10 +10,20 @@ | @@ -10,10 +10,20 @@ | ||
10 | padding: 3px; | 10 | padding: 3px; |
11 | padding-bottom: 25px; | 11 | padding-bottom: 25px; |
12 | border: 1px solid #DDD; | 12 | border: 1px solid #DDD; |
13 | - display: block; | ||
14 | } | 13 | } |
15 | 14 | ||
16 | .notes { | 15 | .notes { |
17 | margin-bottom: 160px; | 16 | margin-bottom: 160px; |
17 | + | ||
18 | + .wall-author { | ||
19 | + color: #666; | ||
20 | + margin-right: 10px; | ||
21 | + border-right: 1px solid #CCC; | ||
22 | + padding-right: 5px | ||
23 | + } | ||
24 | + | ||
25 | + .wall-file { | ||
26 | + float: right; | ||
27 | + } | ||
18 | } | 28 | } |
19 | } | 29 | } |
app/views/layouts/project_resource.html.haml
@@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
40 | = link_to 'Wiki', project_wiki_path(@project, :home) | 40 | = link_to 'Wiki', project_wiki_path(@project, :home) |
41 | 41 | ||
42 | - if @project.wall_enabled | 42 | - if @project.wall_enabled |
43 | - = nav_link(path: 'projects#wall') do | 43 | + = nav_link(controller: :walls) do |
44 | = link_to 'Wall', project_wall_path(@project) | 44 | = link_to 'Wall', project_wall_path(@project) |
45 | 45 | ||
46 | - if @project.snippets_enabled | 46 | - if @project.snippets_enabled |
app/views/walls/show.html.haml
@@ -3,7 +3,8 @@ | @@ -3,7 +3,8 @@ | ||
3 | .notes-busy.js-notes-busy | 3 | .notes-busy.js-notes-busy |
4 | 4 | ||
5 | .js-main-target-form | 5 | .js-main-target-form |
6 | - = render "notes/form" | 6 | + - if can? current_user, :write_note, @project |
7 | + = render "notes/form" | ||
7 | 8 | ||
8 | :javascript | 9 | :javascript |
9 | $(function(){ | 10 | $(function(){ |
lib/api/entities.rb
@@ -95,6 +95,7 @@ module Gitlab | @@ -95,6 +95,7 @@ module Gitlab | ||
95 | class Note < Grape::Entity | 95 | class Note < Grape::Entity |
96 | expose :id | 96 | expose :id |
97 | expose :note, as: :body | 97 | expose :note, as: :body |
98 | + expose :attachment_identifier, as: :attachment | ||
98 | expose :author, using: Entities::UserBasic | 99 | expose :author, using: Entities::UserBasic |
99 | expose :created_at | 100 | expose :created_at |
100 | end | 101 | end |