diff --git a/src/components/Todo.vue b/src/components/Todo.vue index f647e7e..527a645 100644 --- a/src/components/Todo.vue +++ b/src/components/Todo.vue @@ -69,7 +69,7 @@ @@ -158,7 +158,8 @@ export default { gqlQuery( request ).then(data => { - task.id = data.id; + /* save the task's id */ + task.id = data.Task.id; }).catch(e => { const errMsg = `Failed to save task: ${e}`; console.error(errMsg); @@ -166,6 +167,28 @@ export default { }); }, + /** + * Delete a task. + * @param task - task to delete as an object from the store. + */ + deleteTask(task) { + if (task.id !== NEW_TASK_ID) { + /* Task must be also deleted from the server */ + gqlQuery(`mutation { + deleteTask(id: "${task.id}") { + id + } + }`); + } + + /* delete task from the store. */ + const idx = store.tasks.findIndex(item => item.id === task.id); + if (idx !== -1) { + store.tasks.splice(idx, 1); + } + + }, + /** * Show a message nox (Bootstrap modal) */ diff --git a/src/store.js b/src/store.js index d0cb3d1..b89620e 100644 --- a/src/store.js +++ b/src/store.js @@ -145,11 +145,6 @@ export async function storeInit(session) { showError(e); }); - - /* Check if we already have a list named "Default". */ - - - }