From d8fbc7e7b72c3f983569813efe443745085b8b8e Mon Sep 17 00:00:00 2001 From: Zsombor Welker Date: Tue, 19 Apr 2022 13:26:52 +0200 Subject: [PATCH] Add support for task annotations --- frontend/components/TaskDialog.vue | 52 +++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/frontend/components/TaskDialog.vue b/frontend/components/TaskDialog.vue index 97386d2..1a188bf 100644 --- a/frontend/components/TaskDialog.vue +++ b/frontend/components/TaskDialog.vue @@ -70,6 +70,36 @@ :disabled="!recur" /> + + + Annotations + + + + + + + mdi-plus + + + + + + + + + + @@ -123,6 +153,8 @@ export default defineComponent({ (str: string) => Boolean(str) || 'Required' ]; + const addAnnotationDescription = ref(''); + const recur = ref(Boolean(props.task?.recur)); const formData = ref({ description: '', @@ -131,6 +163,7 @@ export default defineComponent({ until: '', wait: '', tags: [] as string[], + annotations: [] as {entry: string; description: string}[], priority: 'N', recur: '', ...props.task @@ -144,12 +177,17 @@ export default defineComponent({ until: '', wait: '', tags: [] as string[], + annotations: [] as {entry: string; description: string}[], priority: 'N', recur: '', ...props.task }; recur.value = Boolean(props.task?.recur); - (formRef.value as any).resetValidation(); + if (formRef.value) { + (formRef.value as any).resetValidation(); + } + + addAnnotationDescription.value = ""; }; watch(() => props.task, () => { @@ -158,6 +196,15 @@ export default defineComponent({ const formRef = ref(null); + const addAnnotation = () => { + formData.value.annotations.push({ + entry: new Date().toISOString(), + description: addAnnotationDescription.value + }); + + addAnnotationDescription.value = ""; + }; + const closeDialog = () => { showDialog.value = false; reset(); @@ -167,6 +214,7 @@ export default defineComponent({ if (valid) { await context.root.$store.dispatch('updateTasks', [{ ...formData.value, + annotations: formData.value.annotations || [], project: formData.value.project || undefined, due: formData.value.due || undefined, until: formData.value.until || undefined, @@ -197,6 +245,8 @@ export default defineComponent({ priorities, recur, formData, + addAnnotationDescription, + addAnnotation, closeDialog, reset, submit,