Add from_comment field in attachments from comment
parent
c98ad12e1e
commit
9fb32124d4
|
@ -47,12 +47,12 @@ class AttachmentsFullService extends taiga.Service
|
||||||
else
|
else
|
||||||
@._attachmentsVisible = @._attachments.filter (it) -> !it.getIn(['file', 'is_deprecated'])
|
@._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) =>
|
return new Promise (resolve, reject) =>
|
||||||
if @attachmentsService.validate(file)
|
if @attachmentsService.validate(file)
|
||||||
@.uploadingAttachments.push(file)
|
@.uploadingAttachments.push(file)
|
||||||
|
|
||||||
promise = @attachmentsService.upload(file, objId, projectId, type)
|
promise = @attachmentsService.upload(file, objId, projectId, type, comment)
|
||||||
promise.then (file) =>
|
promise.then (file) =>
|
||||||
@.uploadingAttachments = @.uploadingAttachments.filter (uploading) ->
|
@.uploadingAttachments = @.uploadingAttachments.filter (uploading) ->
|
||||||
return uploading.name != file.get('name')
|
return uploading.name != file.get('name')
|
||||||
|
@ -62,7 +62,8 @@ class AttachmentsFullService extends taiga.Service
|
||||||
attachment = attachment.merge({
|
attachment = attachment.merge({
|
||||||
file: file,
|
file: file,
|
||||||
editable: editable,
|
editable: editable,
|
||||||
loading: false
|
loading: false,
|
||||||
|
from_comment: comment
|
||||||
})
|
})
|
||||||
|
|
||||||
@._attachments = @._attachments.push(attachment)
|
@._attachments = @._attachments.push(attachment)
|
||||||
|
|
|
@ -25,13 +25,14 @@
|
||||||
CommentEditWysiwyg = (attachmentsFullService) ->
|
CommentEditWysiwyg = (attachmentsFullService) ->
|
||||||
link = ($scope, $el, $attrs) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
types = {
|
types = {
|
||||||
|
epics: "epic",
|
||||||
userstories: "us",
|
userstories: "us",
|
||||||
issues: "issue",
|
issues: "issue",
|
||||||
tasks: "task"
|
tasks: "task"
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadFile = (file, cb) ->
|
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']))
|
cb(result.getIn(['file', 'name']), result.getIn(['file', 'url']))
|
||||||
|
|
||||||
$scope.uploadFiles = (files, cb) ->
|
$scope.uploadFiles = (files, cb) ->
|
||||||
|
|
|
@ -32,13 +32,14 @@ CommentWysiwyg = (attachmentsFullService) ->
|
||||||
$scope.vm.onAddComment({callback: cb})
|
$scope.vm.onAddComment({callback: cb})
|
||||||
|
|
||||||
types = {
|
types = {
|
||||||
|
epics: "epic",
|
||||||
userstories: "us",
|
userstories: "us",
|
||||||
issues: "issue",
|
issues: "issue",
|
||||||
tasks: "task"
|
tasks: "task"
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadFile = (file, cb) ->
|
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']))
|
cb(result.getIn(['file', 'name']), result.getIn(['file', 'url']))
|
||||||
|
|
||||||
$scope.onChange = (markdown) ->
|
$scope.onChange = (markdown) ->
|
||||||
|
|
|
@ -58,7 +58,7 @@ Resource = (urlsService, http, config, $rootScope, $q, storage) ->
|
||||||
|
|
||||||
return http.patch(url, patch)
|
return http.patch(url, patch)
|
||||||
|
|
||||||
service.create = (type, projectId, objectId, file) ->
|
service.create = (type, projectId, objectId, file, from_comment) ->
|
||||||
urlname = "attachments/#{type}"
|
urlname = "attachments/#{type}"
|
||||||
|
|
||||||
url = urlsService.resolve(urlname)
|
url = urlsService.resolve(urlname)
|
||||||
|
@ -116,6 +116,7 @@ Resource = (urlsService, http, config, $rootScope, $q, storage) ->
|
||||||
data.append("project", projectId)
|
data.append("project", projectId)
|
||||||
data.append("object_id", objectId)
|
data.append("object_id", objectId)
|
||||||
data.append("attached_file", file)
|
data.append("attached_file", file)
|
||||||
|
data.append("from_comment", from_comment)
|
||||||
|
|
||||||
xhr = new XMLHttpRequest()
|
xhr = new XMLHttpRequest()
|
||||||
xhr.upload.addEventListener("progress", uploadProgress, false)
|
xhr.upload.addEventListener("progress", uploadProgress, false)
|
||||||
|
|
|
@ -70,8 +70,8 @@ class AttachmentsService
|
||||||
|
|
||||||
@confirm.notify("error", message)
|
@confirm.notify("error", message)
|
||||||
|
|
||||||
upload: (file, objId, projectId, type) ->
|
upload: (file, objId, projectId, type, from_comment = false) ->
|
||||||
promise = @rs.attachments.create(type, projectId, objId, file)
|
promise = @rs.attachments.create(type, projectId, objId, file, from_comment)
|
||||||
|
|
||||||
promise.then null, @.saveError.bind(this, file)
|
promise.then null, @.saveError.bind(this, file)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue