From 4408115f41170d4df9d44c3ffa4b9cd83c7f6e05 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 4 Mar 2020 21:29:40 +0100 Subject: [PATCH] Add creating new related tasks --- src/components/tasks/TaskDetailView.vue | 1 + src/components/tasks/edit-task.vue | 1 + .../tasks/reusable/relatedTasks.vue | 73 ++++++++++++------- 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/components/tasks/TaskDetailView.vue b/src/components/tasks/TaskDetailView.vue index 0ea807b3..52f94527 100644 --- a/src/components/tasks/TaskDetailView.vue +++ b/src/components/tasks/TaskDetailView.vue @@ -193,6 +193,7 @@ diff --git a/src/components/tasks/reusable/relatedTasks.vue b/src/components/tasks/reusable/relatedTasks.vue index 191c5171..64ba27e2 100644 --- a/src/components/tasks/reusable/relatedTasks.vue +++ b/src/components/tasks/reusable/relatedTasks.vue @@ -2,27 +2,31 @@
-
- - - No task found. Consider changing the search query. - -
+
+ + + No task found. Consider changing the search query. + +
@@ -57,7 +61,9 @@
-

No task relations yet.

+

+ No task relations yet. +

{}, + default: () => { + }, }, showNoRelationsNotice: { type: Boolean, default: false, }, + listId: { + type: Number, + default: 0, + } }, created() { this.taskService = new TaskService() @@ -171,7 +182,7 @@ }) this.taskRelationService.delete(rel) .then(r => { - Object.keys(this.relatedTasks).forEach(relationKind => { + Object.keys(this.relatedTasks).forEach(relationKind => { for (const t in this.relatedTasks[relationKind]) { if (this.relatedTasks[relationKind][t].id === this.relationToDelete.other_task_id && relationKind === this.relationToDelete.relation_kind) { this.relatedTasks[relationKind].splice(t, 1) @@ -187,7 +198,17 @@ this.showDeleteModal = false }) }, - + createAndRelateTask(text) { + const newTask = new TaskModel({text: text, listID: this.listId}) + this.taskService.create(newTask) + .then(r => { + this.newTaskRelationTask = r + this.addTaskRelation() + }) + .catch(e => { + this.error(e, this) + }) + }, }, }