fixed updating, added deleting

This commit is contained in:
Markus Thielen 2023-03-17 18:01:20 +01:00
parent 44b8dc0c2f
commit 3bb07e7d47
Signed by: markus
GPG Key ID: 3D4980D3EC9C8E26
2 changed files with 25 additions and 7 deletions

View File

@ -69,7 +69,7 @@
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
</button> </button>
<ul class="dropdown-menu"> <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> </ul>
</div> </div>
</div> </div>
@ -158,7 +158,8 @@ export default {
gqlQuery( gqlQuery(
request request
).then(data => { ).then(data => {
task.id = data.id; /* save the task's id */
task.id = data.Task.id;
}).catch(e => { }).catch(e => {
const errMsg = `Failed to save task: ${e}`; const errMsg = `Failed to save task: ${e}`;
console.error(errMsg); 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) * Show a message nox (Bootstrap modal)
*/ */

View File

@ -145,11 +145,6 @@ export async function storeInit(session) {
showError(e); showError(e);
}); });
/* Check if we already have a list named "Default". */
} }