diff --git a/app/assets/javascripts/notes.js b/app/assets/javascripts/notes.js index 2485f70797d6d08d97f5af33c9e6d5ca4c3755e2..f5005ec2c949d3183a776e0f210ac55b883d00e1 100644 --- a/app/assets/javascripts/notes.js +++ b/app/assets/javascripts/notes.js @@ -4,7 +4,6 @@ var NoteList = { target_params: null, target_id: 0, target_type: null, - loading_more_disabled: false, init: function(tid, tt, path) { NoteList.notes_path = path + ".js"; diff --git a/app/assets/javascripts/wall.js.coffee b/app/assets/javascripts/wall.js.coffee index 43d50b6ba293fe5369ea74b0d469261a2475a07b..dca071e3b3459a1fc670532ce15062dc23de0cb6 100644 --- a/app/assets/javascripts/wall.js.coffee +++ b/app/assets/javascripts/wall.js.coffee @@ -9,6 +9,7 @@ Wall.notes_path = "/api/" + gon.api_version + "/projects/" + project_id + "/notes.json" Wall.getContent() Wall.initRefresh() + Wall.initForm() # # Gets an initial set of notes. @@ -28,6 +29,7 @@ if $.inArray(note.id, Wall.note_ids) == -1 Wall.note_ids.push(note.id) Wall.renderNote(note) + Wall.scrollDown() complete: -> $('.js-notes-busy').removeClass("loading") @@ -35,8 +37,15 @@ $('.js-notes-busy').addClass("loading") renderNote: (note) -> - author = '<strong>' + note.author.name + ': </strong>' - html = '<li>' + author + note.body + '</li>' + author = '<strong class="wall-author">' + note.author.name + '</strong>' + body = '<span class="wall-text">' + note.body + '</span>' + file = '' + + if note.attachment + file = '<span class="wall-file"><a href="/files/note/' + note.id + '/' + note.attachment + '">' + note.attachment + '</a></span>' + + html = '<li>' + author + body + file + '</li>' + $('ul.notes').append(html) initRefresh: -> @@ -44,3 +53,33 @@ refresh: -> Wall.getContent() + + scrollDown: -> + notes = $('ul.notes') + $('body').scrollTop(notes.height()) + + initForm: -> + form = $('.new_note') + form.find("#target_type").val('wall') + + # remove unnecessary fields and buttons + form.find("#note_line_code").remove() + form.find(".js-close-discussion-note-form").remove() + form.find('.js-notify-commit-author').remove() + + form.on 'ajax:success', -> + Wall.refresh() + form.find(".js-note-text").val("").trigger("input") + + form.on 'ajax:complete', -> + form.find(".js-comment-button").removeAttr('disabled') + form.find(".js-comment-button").removeClass('disabled') + + form.on "click", ".js-choose-note-attachment-button", -> + form.find(".js-note-attachment-input").click() + + form.on "change", ".js-note-attachment-input", -> + filename = $(this).val().replace(/^.*[\\\/]/, '') + form.find(".js-attachment-filename").text(filename) + + form.show() diff --git a/app/assets/stylesheets/sections/wall.scss b/app/assets/stylesheets/sections/wall.scss index ea663742ee62580d894daa283f61bf7c308c833d..31b25309cdcfa9709e43758d3db7dc0d6a5035ce 100644 --- a/app/assets/stylesheets/sections/wall.scss +++ b/app/assets/stylesheets/sections/wall.scss @@ -10,10 +10,20 @@ padding: 3px; padding-bottom: 25px; border: 1px solid #DDD; - display: block; } .notes { margin-bottom: 160px; + + .wall-author { + color: #666; + margin-right: 10px; + border-right: 1px solid #CCC; + padding-right: 5px + } + + .wall-file { + float: right; + } } } diff --git a/app/views/layouts/project_resource.html.haml b/app/views/layouts/project_resource.html.haml index 568693356f910817e68bbf0e36156c2528502e73..ca2f6e9a70203ed966618e822545355178f728c8 100644 --- a/app/views/layouts/project_resource.html.haml +++ b/app/views/layouts/project_resource.html.haml @@ -40,7 +40,7 @@ = link_to 'Wiki', project_wiki_path(@project, :home) - if @project.wall_enabled - = nav_link(path: 'projects#wall') do + = nav_link(controller: :walls) do = link_to 'Wall', project_wall_path(@project) - if @project.snippets_enabled diff --git a/app/views/walls/show.html.haml b/app/views/walls/show.html.haml index 525cb2da3e0bdf4c4f871653f3d77b5934ed6152..ed52e3d8e20e1f911660f64f1294d22922ca66e9 100644 --- a/app/views/walls/show.html.haml +++ b/app/views/walls/show.html.haml @@ -3,7 +3,8 @@ .notes-busy.js-notes-busy .js-main-target-form - = render "notes/form" + - if can? current_user, :write_note, @project + = render "notes/form" :javascript $(function(){ diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 42dae53b4d15facecceaf4fb13f7612be33bf5ad..3fe4abc3e2ab97a231cd0ae88f2d71c5a5bbc9cb 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -95,6 +95,7 @@ module Gitlab class Note < Grape::Entity expose :id expose :note, as: :body + expose :attachment_identifier, as: :attachment expose :author, using: Entities::UserBasic expose :created_at end