diff --git a/.gitignore b/.gitignore index 35833eb..de1837c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +node_modules node_modules/ yarn-error.log # No need, this is done by user diff --git a/src/components/management/EditEvent.vue b/src/components/management/EditEvent.vue index 66ae646..d161d85 100644 --- a/src/components/management/EditEvent.vue +++ b/src/components/management/EditEvent.vue @@ -180,9 +180,15 @@ export default defineComponent({ } async function save(template = false) { + if (!event.value.is_template && template) event.value.id = NaN; + event.value.is_template = template; try { + if (!isNaN(event.value.id)) { + //fix + } await store.addEvent(event.value); + if (props.modelValue === undefined && recurrent.value && !event.value.is_template) { let count = 0; const options: ModifyDateOptions = {}; diff --git a/src/components/overview/AgendaView.vue b/src/components/overview/AgendaView.vue index 8b9b0f2..ed2d78a 100644 --- a/src/components/overview/AgendaView.vue +++ b/src/components/overview/AgendaView.vue @@ -8,7 +8,7 @@
- +
@@ -158,7 +158,7 @@ export default defineComponent({ } async function loadAgendas() { - const selected = date.adjustDate(new Date(selectedDate.value), {milliseconds: 0, seconds: 0, minutes: 0, hours: 0}); + const selected = date.adjustDate(selectedDate.value, {milliseconds: 0, seconds: 0, minutes: 0, hours: 0}); const start = calendarRealView.value === 'day' ? selected : startOfWeek(selected); const end = date.addToDate(start, { days: calendarDays.value }); diff --git a/src/components/overview/slots/EventSlot.vue b/src/components/overview/slots/EventSlot.vue index 695e147..4c3fe82 100644 --- a/src/components/overview/slots/EventSlot.vue +++ b/src/components/overview/slots/EventSlot.vue @@ -51,6 +51,7 @@ import { defineComponent, computed, PropType } from 'vue'; import { hasPermission } from '@flaschengeist/api'; import { PERMISSIONS } from '../../../permissions'; +import { date } from 'quasar'; import JobSlot from './JobSlot.vue'; export default defineComponent({ @@ -72,8 +73,10 @@ export default defineComponent({ const canEdit = computed( () => hasPermission(PERMISSIONS.EDIT) && - (props.modelValue?.end || props.modelValue.start) > new Date() + (props.modelValue?.end || props.modelValue.start) >= + date.buildDate({ hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }) ); + const event = computed({ get: () => props.modelValue, set: (v) => emit('update:modelValue', v), diff --git a/src/store.ts b/src/store.ts index c40f748..f636865 100644 --- a/src/store.ts +++ b/src/store.ts @@ -151,9 +151,17 @@ export const useScheduleStore = defineStore({ }, async addEvent(event: FG.Event) { - const { data } = await api.post('/events', event); - if (data.is_template) this.templates.push(data); - return data; + if (isNaN(event.id)) { + const { data } = await api.post('/events', event); + if (data.is_template) this.templates.push(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})); + if (data.is_template) this.templates.push(data); + return data; + } }, }, });