fixed updating, added deleting
This commit is contained in:
parent
44b8dc0c2f
commit
3bb07e7d47
@ -69,7 +69,7 @@
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a class="dropdown-item" href="#">Delete this item</a></li>
|
||||
<li><a class="dropdown-item" href="#" @click="deleteTask(task)">Delete this item</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -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)
|
||||
*/
|
||||
|
@ -145,11 +145,6 @@ export async function storeInit(session) {
|
||||
showError(e);
|
||||
});
|
||||
|
||||
|
||||
/* Check if we already have a list named "Default". */
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user