This commit is contained in:
2020-04-22 15:13:00 +00:00
parent 69d0974215
commit 2f7e507474
3 changed files with 94 additions and 32 deletions

View File

@@ -71,7 +71,7 @@ todo: attachments - form key for hiding / showing customization
todo: attachment - rename a file or add notes after already uploaded
https://medium.com/js-dojo/upload-files-to-cloudinary-using-vue-vuetify-dd45472c4fd6
1578595824571
todo: ATTACHMENTS
- TODO: PLANNING - should attachments be actually attached in the db to their object? like Wiki was changed to do?
- is this even possible?

View File

@@ -392,6 +392,47 @@ export default {
handleError("DUPLICATE", error, route, reject);
});
});
},
///////////////////////////////////
// POST FILE ATTACHMENTS
// @param {ayId:objectid, ayType:objectType, files:[array of files]}
//
uploadAttachment(at) {
let that = this;
var files = at.files;
var data = new FormData();
for (var i = 0; i < files.length; i++) {
data.append(files[i].name, files[i]);
}
data.append("AttachToObjectType", at.ayaType);
data.append("AttachToObjectId", at.ayaId);
//-----------------
return new Promise(function postAttachmentToServer(resolve, reject) {
let fetchOptions = {
method: "post",
mode: "cors",
headers: {
Authorization: "Bearer " + window.$gz.store.state.apiToken
},
body: data
};
fetch(that.APIUrl("Attachment"), fetchOptions)
.then(that.status)
.then(that.json)
// eslint-disable-next-line
.then((response) => {
resolve(response);
})
.catch(function handlePostAttachment(error) {
handleError("POSTATTACHMENT", error, route, reject);
});
});
//---------------
}
//new functions above here

View File

@@ -69,7 +69,57 @@ export default {
data() {
return {
height: 300,
items: [
items: [],
notes: null,
tab: null,
uploadFiles: []
};
},
props: {
ayaType: Number,
ayaId: Number,
readonly: Boolean
},
methods: {
onResize() {
this.height = window.innerHeight * 0.8;
},
cardTextStyle() {
return "height: " + this.height + "px;overflow-y:auto;";
},
upload() {
let at = {
ayaId: this.ayaId,
ayaType: this.ayaType,
files: this.uploadFiles
};
window.$gz.api.uploadAttachment(at).then(res => {
//vm.formState.loading = false;
if (res.error) {
console.log(res.error);
// vm.formState.serverError = res.error;
// window.$gz.form.setErrorBoxErrors(vm);
} else {
console.log("SUCCESS");
}
});
// .catch(function handleSubmitError(error) {
// vm.formState.loading = false;
// window.$gz.errorHandler.handleFormError(error, vm);
// });
// if (this.uploadFiles.length > 0) {
// this.uploadFiles.forEach(file => {
// window.console.log(file);
// });
// }
},
aClick() {
console.log("CLICK");
}
}
/**[
{
icon: "fa-file-image",
title: "drawings.pdf",
@@ -130,35 +180,6 @@ export default {
// title: "4Work",
// subtitle: "Jan 28, 2014"
// }
],
notes: null,
tab: null,
uploadFiles: []
};
},
props: {
ayaType: Number,
ayaId: Number,
readonly: Boolean
},
methods: {
onResize() {
this.height = window.innerHeight * 0.8;
},
cardTextStyle() {
return "height: " + this.height + "px;overflow-y:auto;";
},
upload() {
if (this.uploadFiles.length > 0) {
this.uploadFiles.forEach(file => {
window.console.log(file);
});
}
},
aClick() {
console.log("CLICK");
}
}
], */
};
</script>