From a15831eb33b5104e19f0b85b882dd8ec5336ba62 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Fri, 5 Jul 2024 15:27:36 +0200 Subject: [PATCH] feat: remove props destructuring from SingleTaskInProject --- .../tasks/partials/SingleTaskInProject.vue | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/tasks/partials/SingleTaskInProject.vue b/frontend/src/components/tasks/partials/SingleTaskInProject.vue index b98814861..d22c5261e 100644 --- a/frontend/src/components/tasks/partials/SingleTaskInProject.vue +++ b/frontend/src/components/tasks/partials/SingleTaskInProject.vue @@ -208,30 +208,31 @@ import {playPopSound} from '@/helpers/playPop' import {isEditorContentEmpty} from '@/helpers/editorContentEmpty' import {TASK_REPEAT_MODES} from '@/types/IRepeatMode' -const { - theTask, - isArchived = false, - showProject = false, - disabled = false, - canMarkAsDone = true, - allTasks = [], -} = defineProps<{ +const props = withDefaults(defineProps<{ theTask: ITask, isArchived?: boolean, showProject?: boolean, disabled?: boolean, canMarkAsDone?: boolean, allTasks?: ITask[], +}>(), { + isArchived: false, + showProject: false, + disabled: false, + canMarkAsDone: true, + allTasks: () => [], +}) + +const emit = defineEmits<{ + 'taskUpdated': [task: ITask], }>() -const emit = defineEmits(['taskUpdated']) - function getTaskById(taskId: number): ITask | undefined { - if (typeof allTasks === 'undefined' || allTasks.length === 0) { + if (typeof props.allTasks === 'undefined' || props.allTasks.length === 0) { return null } - return allTasks.find(t => t.id === taskId) + return props.allTasks.find(t => t.id === taskId) } const {t} = useI18n({useScope: 'global'}) @@ -243,14 +244,17 @@ const showDefer = ref(false) const isRepeating = computed(() => task.value.repeatAfter.amount > 0 || (task.value.repeatAfter.amount === 0 && task.value.repeatMode === TASK_REPEAT_MODES.REPEAT_MODE_MONTH)) watch( - () => theTask, + () => props.theTask, newVal => { task.value = newVal }, + { + immediate: true, + deep: true, + }, ) onMounted(() => { - task.value = theTask document.addEventListener('click', hideDeferDueDatePopup) }) @@ -265,7 +269,7 @@ const taskStore = useTaskStore() const project = computed(() => projectStore.projects[task.value.projectId]) const projectColor = computed(() => project.value ? project.value?.hexColor : '') -const showProjectSeparately = computed(() => !showProject && currentProject.value?.id !== task.value.projectId && project.value) +const showProjectSeparately = computed(() => !props.showProject && currentProject.value?.id !== task.value.projectId && project.value) const currentProject = computed(() => { return typeof baseStore.currentProject === 'undefined' ? {