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
app/assets/javascripts/wall.js.coffee
| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | Wall.notes_path = "/api/" + gon.api_version + "/projects/" + project_id + "/notes.json" |
| 10 | 10 | Wall.getContent() |
| 11 | 11 | Wall.initRefresh() |
| 12 | + Wall.initForm() | |
| 12 | 13 | |
| 13 | 14 | # |
| 14 | 15 | # Gets an initial set of notes. |
| ... | ... | @@ -28,6 +29,7 @@ |
| 28 | 29 | if $.inArray(note.id, Wall.note_ids) == -1 |
| 29 | 30 | Wall.note_ids.push(note.id) |
| 30 | 31 | Wall.renderNote(note) |
| 32 | + Wall.scrollDown() | |
| 31 | 33 | |
| 32 | 34 | complete: -> |
| 33 | 35 | $('.js-notes-busy').removeClass("loading") |
| ... | ... | @@ -35,8 +37,15 @@ |
| 35 | 37 | $('.js-notes-busy').addClass("loading") |
| 36 | 38 | |
| 37 | 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 | 49 | $('ul.notes').append(html) |
| 41 | 50 | |
| 42 | 51 | initRefresh: -> |
| ... | ... | @@ -44,3 +53,33 @@ |
| 44 | 53 | |
| 45 | 54 | refresh: -> |
| 46 | 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 | padding: 3px; |
| 11 | 11 | padding-bottom: 25px; |
| 12 | 12 | border: 1px solid #DDD; |
| 13 | - display: block; | |
| 14 | 13 | } |
| 15 | 14 | |
| 16 | 15 | .notes { |
| 17 | 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 | 40 | = link_to 'Wiki', project_wiki_path(@project, :home) |
| 41 | 41 | |
| 42 | 42 | - if @project.wall_enabled |
| 43 | - = nav_link(path: 'projects#wall') do | |
| 43 | + = nav_link(controller: :walls) do | |
| 44 | 44 | = link_to 'Wall', project_wall_path(@project) |
| 45 | 45 | |
| 46 | 46 | - if @project.snippets_enabled | ... | ... |
app/views/walls/show.html.haml
lib/api/entities.rb