diff --git a/src/components/tasks/mixins/attachmentUpload.js b/src/components/tasks/mixins/attachmentUpload.js deleted file mode 100644 index 4ba36882..00000000 --- a/src/components/tasks/mixins/attachmentUpload.js +++ /dev/null @@ -1,39 +0,0 @@ -import AttachmentModel from '../../../models/attachment' -import AttachmentService from '../../../services/attachment' -import {generateAttachmentUrl} from '@/helpers/generateAttachmentUrl' - -export default { - methods: { - attachmentUpload(file, onSuccess) { - const files = [file] - - const attachmentService = new AttachmentService() - - this.createAttachment(attachmentService, files, onSuccess) - }, - createAttachment(attachmentService, files, onSuccess = () => {}) { - const attachmentModel = new AttachmentModel({taskId: this.taskId}) - attachmentService.create(attachmentModel, files) - .then(r => { - console.debug(`Uploaded attachments for task ${this.taskId}, response was`, r) - if (r.success !== null) { - r.success.forEach(a => { - this.$store.dispatch('tasks/addTaskAttachment', { - taskId: this.taskId, - attachment: a, - }) - onSuccess(generateAttachmentUrl(this.taskId, a.id)) - }) - } - if (r.errors !== null) { - r.errors.forEach(m => { - this.error(m) - }) - } - }) - .catch(e => { - this.error(e) - }) - }, - }, -} \ No newline at end of file diff --git a/src/components/tasks/partials/attachments.vue b/src/components/tasks/partials/attachments.vue index aa93494f..1e6e82b1 100644 --- a/src/components/tasks/partials/attachments.vue +++ b/src/components/tasks/partials/attachments.vue @@ -138,19 +138,16 @@ import AttachmentService from '../../../services/attachment' import AttachmentModel from '../../../models/attachment' import User from '../../misc/user' -import attachmentUpload from '@/components/tasks/mixins/attachmentUpload' -import {generateAttachmentUrl} from '@/helpers/generateAttachmentUrl' import {mapState} from 'vuex' import copy from 'copy-to-clipboard' +import { uploadFiles, generateAttachmentUrl } from '@/helpers/attachments' + export default { name: 'attachments', components: { User, }, - mixins: [ - attachmentUpload, - ], data() { return { attachmentService: AttachmentService, @@ -221,7 +218,7 @@ export default { this.uploadFiles(this.$refs.files.files) }, uploadFiles(files) { - this.createAttachment(this.attachmentService, files) + uploadFiles(this.attachmentService, this.taskId, files) }, deleteAttachment() { this.attachmentService diff --git a/src/components/tasks/partials/comments.vue b/src/components/tasks/partials/comments.vue index e0379c1e..433e362a 100644 --- a/src/components/tasks/partials/comments.vue +++ b/src/components/tasks/partials/comments.vue @@ -151,9 +151,9 @@