mirror of
https://github.com/DCsunset/taskwarrior-webui.git
synced 2025-08-19 06:53:06 +02:00
feat(frontend): add snackbar and updateTasks
This commit is contained in:
parent
c82b1ef0ac
commit
0b2efb515b
1 changed files with 22 additions and 1 deletions
|
@ -3,7 +3,12 @@ import { Task } from 'taskwarrior-lib';
|
|||
import { getAccessorType } from 'typed-vuex';
|
||||
|
||||
export const state = () => ({
|
||||
tasks: [] as Task[]
|
||||
tasks: [] as Task[],
|
||||
snackbar: false,
|
||||
notification: {
|
||||
color: '',
|
||||
text: ''
|
||||
}
|
||||
});
|
||||
|
||||
export type RootState = ReturnType<typeof state>;
|
||||
|
@ -18,6 +23,16 @@ export const getters: GetterTree<RootState, RootState> = {
|
|||
export const mutations: MutationTree<RootState> = {
|
||||
setTasks(state, tasks: Task[]) {
|
||||
state.tasks = tasks;
|
||||
},
|
||||
|
||||
setNotification(state, notification) {
|
||||
state.notification = notification;
|
||||
// Show notification
|
||||
state.snackbar = true;
|
||||
},
|
||||
|
||||
setSnackbar(state, value) {
|
||||
state.snackbar = value;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -33,6 +48,12 @@ export const actions: ActionTree<RootState, RootState> = {
|
|||
});
|
||||
// Refresh
|
||||
await context.dispatch('fetchTasks');
|
||||
},
|
||||
|
||||
async updateTasks(context, tasks: Task[]) {
|
||||
await this.$axios.$put('/api/tasks', { tasks });
|
||||
// Refresh
|
||||
await context.dispatch('fetchTasks');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue