From d8613a3603e004d70a693e6fd5ad127eb4c8ac7f Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Mon, 8 May 2023 14:52:06 +0200 Subject: [PATCH] add edit task view --- public/icons/edit.svg | 6 ++++ src/modules/task/components/TaskForm.vue | 9 +++--- src/router/index.ts | 6 ++++ src/views/task/EditTask.vue | 35 ++++++++++++++++++++++++ src/views/task/TaskView.vue | 21 +++++++++++--- 5 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 public/icons/edit.svg create mode 100644 src/views/task/EditTask.vue diff --git a/public/icons/edit.svg b/public/icons/edit.svg new file mode 100644 index 0000000..9f36b2d --- /dev/null +++ b/public/icons/edit.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/modules/task/components/TaskForm.vue b/src/modules/task/components/TaskForm.vue index 5b080ee..3ba9487 100644 --- a/src/modules/task/components/TaskForm.vue +++ b/src/modules/task/components/TaskForm.vue @@ -3,19 +3,20 @@ import EstimationTimeArrival from '@/components/EstimationTimeArrival.vue' import { computed, ref } from 'vue' import { useRouter } from 'vue-router' import type { Stepable } from '../interfaces/stepable' +import type { Taskable } from '../interfaces/taskable' import { Task } from '../models/task' import { useTaskStore } from '../stores/useTask.store' import StepInput from './StepInput.vue' const store = useTaskStore() const router = useRouter() -const props = defineProps<{ id: string }>() +const props = defineProps<{ id: string; initialTask?: Taskable }>() const id = computed(() => props.id) -const steps = ref([]) +const steps = ref(props.initialTask?.steps ?? []) -const title = ref('') -const link = ref('') +const title = ref(props.initialTask?.title ?? '') +const link = ref(props.initialTask?.link ?? '') const totalEstimation = computed(() => steps.value.map((step) => step.estimation).reduce((a, b) => a + b, 0) diff --git a/src/router/index.ts b/src/router/index.ts index bfc9e07..3f1c90e 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -25,6 +25,12 @@ export const router = createRouter({ props: true, component: () => import('../views/task/TaskView.vue') }, + { + path: '/task/:id/edit', + name: 'edit-task', + props: true, + component: () => import('../views/task/EditTask.vue') + }, { path: '/task/:taskId/record', name: 'record-view', diff --git a/src/views/task/EditTask.vue b/src/views/task/EditTask.vue new file mode 100644 index 0000000..482fe4f --- /dev/null +++ b/src/views/task/EditTask.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/src/views/task/TaskView.vue b/src/views/task/TaskView.vue index 6d227fe..cca7985 100644 --- a/src/views/task/TaskView.vue +++ b/src/views/task/TaskView.vue @@ -26,9 +26,22 @@ const deleteTask = () => {