add comments to commit

This commit is contained in:
Alexander Machehin 2015-03-18 20:49:10 +05:00
parent ed00ea0752
commit 10c28be905
3 changed files with 14 additions and 6 deletions

View File

@ -1,9 +1,13 @@
commentService = ($http) -> commentService = ($http) ->
getPath = (kind, project, commentable, id) -> getPath = (kind, project, commentable, id) ->
if kind is 'remove' or kind is 'update' if (kind is 'remove' or kind is 'update') and commentable.kind is 'issue'
return Routes.project_issue_comment_path(project, commentable.id, id) return Routes.project_issue_comment_path(project, commentable.id, id)
else if kind is 'add' else if kind is 'add' and commentable.kind is 'issue'
return Routes.project_issue_comments_path(project, commentable.id) return Routes.project_issue_comments_path(project, commentable.id)
else if (kind is 'remove' or kind is 'update') and commentable.kind is 'commit'
return Routes.project_commit_comment_path(project, commentable.id, id)
else if kind is 'add' and commentable.kind is 'commit'
return Routes.project_commit_comments_path(project, commentable.id)
{ {
add: (project, commentable, body) -> add: (project, commentable, body) ->
@ -24,7 +28,7 @@ commentService = ($http) ->
update: (project, commentable, id) -> update: (project, commentable, id) ->
path = getPath('update', project, commentable, id) path = getPath('update', project, commentable, id)
params = { comment: { body: $('#comment-'+id+'-body').val() }} params = { comment: { body: $('#comment-'+id+'-body').val() }}
$http.put(path, params) $http.patch(path, params)
remove: (project, commentable, id) -> remove: (project, commentable, id) ->
path = getPath('remove', project, commentable, id) path = getPath('remove', project, commentable, id)

View File

@ -170,7 +170,7 @@ CommentsController = (Comment, Preview, confirmMessage, $scope, compileHTML, $ro
vm.commentable = commentable vm.commentable = commentable
vm.processing = false vm.processing = false
vm.k = 10 vm.k = 10
if commentable.kind is 'issue' if commentable.kind is 'issue' or commentable.kind is 'commit'
list = $('#comments_list') list = $('#comments_list')
else if commentable.kind is 'pull' else if commentable.kind is 'pull'
list = $('#pull-activity') list = $('#pull-activity')

View File

@ -17,8 +17,12 @@
.both .both
#repo-wrapper #repo-wrapper
== render 'show' == render 'show'
- ctrl_params = "{ kind: 'commit', id: '#{@commit.id}' }"
-comments = @comments.select {|c| c.data.blank? } # dont work @comments.where(data: nil) -comments = @comments.select {|c| c.data.blank? } # dont work @comments.where(data: nil)
== render "projects/comments/list", list: comments, project: @project, commentable: @commit div[ ng-controller = 'CommentsController as commentsCtrl'
== render "projects/comments/add", project: @project, commentable: @commit if current_user ng-init = "commentsCtrl.init('#{@project.name_with_owner}', #{ctrl_params})" ]
== render "projects/comments/list", list: comments, project: @project, commentable: @commit
== render "projects/comments/add", project: @project, commentable: @commit if current_user
= hidden_field_tag :preview_url, project_md_preview_path(@project) = hidden_field_tag :preview_url, project_md_preview_path(@project)