This commit is contained in:
Matej Glasnák committed 2023-02-01 15:04:03 +01:00
1 parent 3902cbd601
commit 63394d3a8a
6 files changed
+264 -35

No files matched your search

+16 -35
View File
@@ -23,6 +23,10 @@ export default {
},
methods: {
onChange($event) {
this.files = $event.target.files
},
async createWithoutFile() {
const masterTask = this._getMastertaskObject()
@@ -34,47 +38,24 @@ export default {
if (!this.files) return alert('No files uploaded')
const masterTask = this._getMastertaskObject()
masterTask.data.files = this.files
masterTask.files = this.files
await axios.post('https://taskmanager.internal.studiotem.com/api/v1/mastertasks', this._objectToFormData(masterTask))
console.log(await this.$axios.get_data('v1/mastertasks'))
console.log(await this.$axios.post_auth_data('v1/mastertasks', masterTask))
},
_getMastertaskObject() {
const employees = [{
id: 1,
duration: 1000
}]
return {
data: {
name: `name-${3}`,
description: `description`,
duration: 1231,
deadline: moment().format('YYYY-MM-DD HH:MM:SS'),
project_id: 1,
team_id: 1,
employees: employees
}
name: `name-${3}`,
description: `description`,
duration: 1231,
deadline: moment().format('YYYY-MM-DD HH:MM:SS'),
project_id: 1,
team_id: 1,
employees: [{
id: 1,
duration: 1000
}]
}
},
onChange($event) {
this.files = $event.target.files
},
_buildFormData(formData, data, parentKey) {
if (data && typeof data === 'object' && !(data instanceof Date) && !(data instanceof File))
Object.keys(data).forEach(key => this._buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key));
else
formData.append(parentKey, data == null ? '' : data);
},
_objectToFormData(data) {
const formData = new FormData()
this._buildFormData(formData, data)
return formData
}
}
}