Fix uploadfile in comments

stable
Álex Hermida 2018-12-04 09:57:09 +01:00 committed by Alex Hermida
parent bd56b45516
commit a02d24ee1e
2 changed files with 9 additions and 12 deletions

View File

@ -17,18 +17,19 @@
# File: components/wysiwyg/comment-wysiwyg.directive.coffee # File: components/wysiwyg/comment-wysiwyg.directive.coffee
### ###
CommentWysiwyg = ($modelTransform, $rootscope, $confirm, attachmentsFullService) -> CommentWysiwyg = ($modelTransform, $rootscope, attachmentsFullService) ->
link = ($scope, $el, $attrs) -> link = ($scope, $el, $attrs) ->
$scope.editableDescription = false $scope.editableDescription = false
$scope.saveComment = (description, cb) -> $scope.saveComment = (description, cb) ->
$scope.content = '' $scope.content = ''
$scope.type.comment = description $scope.vm.type.comment = description
transform = $modelTransform.save (item) -> return transform = $modelTransform.save (item) -> return
transform.then -> transform.then ->
if $scope.onAddComment if $scope.vm.onAddComment
$scope.onAddComment() $scope.vm.onAddComment()
$rootscope.$broadcast("object:updated")
transform.finally(cb) transform.finally(cb)
types = { types = {
@ -39,11 +40,11 @@ CommentWysiwyg = ($modelTransform, $rootscope, $confirm, attachmentsFullService)
} }
uploadFile = (file, cb) -> uploadFile = (file, cb) ->
return attachmentsFullService.addAttachment($scope.vm.projectId, $scope.type.id, types[$scope.type._name], file, true, true).then (result) -> return attachmentsFullService.addAttachment($scope.vm.projectId, $scope.vm.type.id, types[$scope.vm.type._name], file, true, true).then (result) ->
cb(result.getIn(['file', 'name']), result.getIn(['file', 'url'])) cb(result.getIn(['file', 'name']), result.getIn(['file', 'url']))
$scope.onChange = (markdown) -> $scope.onChange = (markdown) ->
$scope.type.comment = markdown $scope.vm.type.comment = markdown
$scope.uploadFiles = (files, cb) -> $scope.uploadFiles = (files, cb) ->
for file in files for file in files
@ -51,16 +52,13 @@ CommentWysiwyg = ($modelTransform, $rootscope, $confirm, attachmentsFullService)
$scope.content = '' $scope.content = ''
$scope.$watch "type", (value) -> $scope.$watch "vm.type", (value) ->
return if not value return if not value
$scope.storageKey = "comment-" + value.project + "-" + value.id + "-" + value._name $scope.storageKey = "comment-" + value.project + "-" + value.id + "-" + value._name
return { return {
scope: { scope: true,
type: '=',
onAddComment: '&'
},
link: link, link: link,
template: """ template: """
<div> <div>

View File

@ -18,6 +18,5 @@ section.comments
tg-comment-wysiwyg( tg-comment-wysiwyg(
tg-check-permission="{{::vm.canAddCommentPermission}}" tg-check-permission="{{::vm.canAddCommentPermission}}"
on-add-comment="vm.onAddComment()"
type="vm.type" type="vm.type"
) )