diff --git a/app/modules/components/attachment/attachment-gallery.jade b/app/modules/components/attachment/attachment-gallery.jade index 4a131ef2..5a4a9074 100644 --- a/app/modules/components/attachment/attachment-gallery.jade +++ b/app/modules/components/attachment/attachment-gallery.jade @@ -32,6 +32,8 @@ a.icon-delete( href="" title="{{'COMMON.DELETE' | translate}}" + ng-if="!vm.attachment.get('editable')" + tg-check-permission="modify_{{vm.type}}" ng-click="vm.delete()" ) tg-svg(svg-icon="icon-trash") diff --git a/app/modules/components/attachments-full/attachments-full.service.coffee b/app/modules/components/attachments-full/attachments-full.service.coffee index 2635f7c4..118330c4 100644 --- a/app/modules/components/attachments-full/attachments-full.service.coffee +++ b/app/modules/components/attachments-full/attachments-full.service.coffee @@ -47,12 +47,12 @@ class AttachmentsFullService extends taiga.Service else @._attachmentsVisible = @._attachments.filter (it) -> !it.getIn(['file', 'is_deprecated']) - addAttachment: (projectId, objId, type, file, editable = true) -> + addAttachment: (projectId, objId, type, file, editable = true, comment = false) -> return new Promise (resolve, reject) => if @attachmentsService.validate(file) @.uploadingAttachments.push(file) - promise = @attachmentsService.upload(file, objId, projectId, type) + promise = @attachmentsService.upload(file, objId, projectId, type, comment) promise.then (file) => @.uploadingAttachments = @.uploadingAttachments.filter (uploading) -> return uploading.name != file.get('name') @@ -62,7 +62,8 @@ class AttachmentsFullService extends taiga.Service attachment = attachment.merge({ file: file, editable: editable, - loading: false + loading: false, + from_comment: comment }) @._attachments = @._attachments.push(attachment) diff --git a/app/modules/components/wysiwyg/comment-edit-wysiwyg.directive.coffee b/app/modules/components/wysiwyg/comment-edit-wysiwyg.directive.coffee index 2bc170e6..845b44e5 100644 --- a/app/modules/components/wysiwyg/comment-edit-wysiwyg.directive.coffee +++ b/app/modules/components/wysiwyg/comment-edit-wysiwyg.directive.coffee @@ -25,13 +25,14 @@ CommentEditWysiwyg = (attachmentsFullService) -> link = ($scope, $el, $attrs) -> types = { + epics: "epic", userstories: "us", issues: "issue", tasks: "task" } uploadFile = (file, cb) -> - return attachmentsFullService.addAttachment($scope.vm.projectId, $scope.vm.comment.comment.id, types[$scope.vm.comment.comment._name], file).then (result) -> + return attachmentsFullService.addAttachment($scope.vm.projectId, $scope.vm.comment.comment.id, types[$scope.vm.comment.comment._name], file, true, true).then (result) -> cb(result.getIn(['file', 'name']), result.getIn(['file', 'url'])) $scope.uploadFiles = (files, cb) -> diff --git a/app/modules/components/wysiwyg/comment-wysiwyg.directive.coffee b/app/modules/components/wysiwyg/comment-wysiwyg.directive.coffee index c1240a63..7a7ae5bd 100644 --- a/app/modules/components/wysiwyg/comment-wysiwyg.directive.coffee +++ b/app/modules/components/wysiwyg/comment-wysiwyg.directive.coffee @@ -32,13 +32,14 @@ CommentWysiwyg = (attachmentsFullService) -> $scope.vm.onAddComment({callback: cb}) types = { + epics: "epic", userstories: "us", issues: "issue", tasks: "task" } uploadFile = (file, cb) -> - return attachmentsFullService.addAttachment($scope.vm.projectId, $scope.vm.type.id, types[$scope.vm.type._name], file).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'])) $scope.onChange = (markdown) -> diff --git a/app/modules/resources/attachments-resource.service.coffee b/app/modules/resources/attachments-resource.service.coffee index 94cb1bb2..ecdacbc3 100644 --- a/app/modules/resources/attachments-resource.service.coffee +++ b/app/modules/resources/attachments-resource.service.coffee @@ -58,7 +58,7 @@ Resource = (urlsService, http, config, $rootScope, $q, storage) -> return http.patch(url, patch) - service.create = (type, projectId, objectId, file) -> + service.create = (type, projectId, objectId, file, from_comment) -> urlname = "attachments/#{type}" url = urlsService.resolve(urlname) @@ -116,6 +116,7 @@ Resource = (urlsService, http, config, $rootScope, $q, storage) -> data.append("project", projectId) data.append("object_id", objectId) data.append("attached_file", file) + data.append("from_comment", from_comment) xhr = new XMLHttpRequest() xhr.upload.addEventListener("progress", uploadProgress, false) diff --git a/app/modules/services/attachments.service.coffee b/app/modules/services/attachments.service.coffee index 5ebfa0ce..89069785 100644 --- a/app/modules/services/attachments.service.coffee +++ b/app/modules/services/attachments.service.coffee @@ -70,8 +70,8 @@ class AttachmentsService @confirm.notify("error", message) - upload: (file, objId, projectId, type) -> - promise = @rs.attachments.create(type, projectId, objId, file) + upload: (file, objId, projectId, type, from_comment = false) -> + promise = @rs.attachments.create(type, projectId, objId, file, from_comment) promise.then null, @.saveError.bind(this, file)