Implement updating files

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-06-14 10:27:02 +02:00
parent c816b15bfa
commit 581fa011e3
4 changed files with 52 additions and 31 deletions

View File

@@ -35,28 +35,21 @@ export default class FileService {
runUpload (fileItem, attachmentId) {
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment');
if (typeof attachmentId !== 'undefined') {
fileItem.method = 'UPDATE';
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment/' + attachmentId);
} else {
fileItem.formData = [
{
requesttoken: oc_requesttoken,
type: 'deck_file',
}
];
}
fileItem.formData = [
fileItem.headers =
{
requesttoken: oc_requesttoken,
type: 'deck_file',
};
}
];
this.uploader.uploadItem(fileItem);
};
runUpdate (fileItem) {
fileItem.url = OC.generateUrl('/apps/deck/cards/' + fileItem.cardId + '/attachment');
fileItem.formData = [
{
requesttoken: oc_requesttoken,
type: 'deck_file',
}
];
this.uploader.uploadItem(fileItem);
};
@@ -97,6 +90,11 @@ export default class FileService {
};
onSuccessItem(item, response) {
let attachments = this.cardservice.get(item.cardId).attachments;
let index = attachments.indexOf(attachments.find(attachment => attachment.id === response.id));
if (~index) {
attachments = attachments.splice(index, 1);
}
this.cardservice.get(item.cardId).attachments.push(response);
};