[sub & master task] saved data in LS + build for stage

This commit is contained in:
romankko2 committed 2024-08-01 17:41:51 +02:00
1 parent 8b1b1a7fb4
commit 7dcd9eda4d
3 files changed
+60 -12

No files matched your search

@@ -282,7 +282,25 @@ export default {
// this.mastertask.project_code = project.code
} else {
this.mastertask = { employees: [], duration: 0, _deadline_time: '17:00' }
const savedMastertask = localStorage.getItem('mastertaskData')
try {
if (savedMastertask) {
const parsedMastertask = JSON.parse(savedMastertask)
this.mastertask = parsedMastertask
// If the parsed result is not an object, reset to default
if (typeof this.mastertask !== 'object' || this.mastertask === null) {
throw new Error('Parsed mastertask is not an object')
}
this.$nextTick(() => {
this.$refs['description']?.setHTML(this.mastertask.description || '');
})
} else {
throw new Error('mastertaskData is null or undefined')
}
} catch (error) {
console.error('Error parsing mastertaskData:', error);
this.mastertask = { employees: [], duration: 0, _deadline_time: '17:00' }
}
}
this.editMode = editMode || !this.mastertask.id
@@ -319,6 +337,7 @@ export default {
this.mastertask.deadline = moment(this.mastertask.deadline).format('YYYY-MM-DD HH:MM:SS')
if (this.mastertask.id) await this.$axios.patch_auth_form(`v1/mastertasks/${this.mastertask.id}`, this.mastertask)
else await this.$axios.post_auth_data('v1/mastertasks', this.mastertask)
localStorage.removeItem('mastertaskData')
this.$emit('master-task-edited', this.mastertask)
this.closeModal()
@@ -394,12 +413,14 @@ export default {
})
},
// mastertask: {
// handler(value) {
// console.log(value.description)
// },
// deep: true
// }
mastertask: {
handler(val) {
if (this.editMode && !this.mastertask?.id) {
localStorage.setItem('mastertaskData', JSON.stringify(val))
}
},
deep: true
}
}
}
</script>