diff --git a/src/components/management/EditEvent.vue b/src/components/management/EditEvent.vue
index 5275304..5ee363e 100644
--- a/src/components/management/EditEvent.vue
+++ b/src/components/management/EditEvent.vue
@@ -138,6 +138,7 @@ export default defineComponent({
},
emits: {
done: (val: boolean) => typeof val === 'boolean',
+ 'update:modelValue': (val?: FG.Event) => typeof val === 'object',
},
setup(props, { emit }) {
const store = useEventStore();
@@ -208,7 +209,8 @@ export default defineComponent({
async function save(is_template = false) {
event.value.is_template = is_template;
try {
- await store.addEvent(event.value);
+ const _event = await store.addEvent(event.value);
+ emit('update:modelValue', _event);
if (props.modelValue === undefined && recurrent.value && !event.value.is_template) {
let count = 0;
diff --git a/src/components/overview/ListView.vue b/src/components/overview/ListView.vue
index 4ad719d..a7ba069 100644
--- a/src/components/overview/ListView.vue
+++ b/src/components/overview/ListView.vue
@@ -28,7 +28,7 @@
{{ asDate(index) }}
-
+
@@ -88,6 +88,10 @@ export default defineComponent({
function editDone(changed: boolean) {
//if (changed) void loadAgendas();
+ const idx = events.value.findIndex((event) => event.id === editor.value?.id);
+ if (idx >= 0) {
+ events.value[idx] = editor.value as FG.Event;
+ }
editor.value = undefined;
}
@@ -117,16 +121,10 @@ export default defineComponent({
async function remove(id: number) {
if (await store.removeEvent(id)) {
- // Successfull removed
- for (const idx in agendas.value) {
- const i = agendas.value[idx].findIndex((event) => event.id === id);
- if (i !== -1) {
- agendas.value[idx].splice(i, 1);
- break;
- }
+ const idx = events.value.findIndex((event) => event.id === id);
+ if (idx !== -1) {
+ events.value.splice(idx, 1);
}
- } else {
- // Not found, this means our eventa are outdated
}
}
diff --git a/src/store/index.ts b/src/store/index.ts
index eca10eb..089f266 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -150,15 +150,13 @@ export const useEventStore = defineStore({
if (event?.id === undefined) {
const { data } = await api.post('/events', event);
if (data.is_template) this.templates.push(data);
+ fixEvent(data);
return data;
} else {
if (typeof event.type === 'object') event.type = event.type.id;
- const { data } = await api.put(
- `/events/${event.id}`,
- // Object.assign(event, { jobs: undefined })
- event
- );
+ const { data } = await api.put(`/events/${event.id}`, event);
if (data.is_template) this.templates.push(data);
+ fixEvent(data);
return data;
}
},