diff --git a/src/components/management/EditEvent.vue b/src/components/management/EditEvent.vue index 88b80a9..70c954d 100644 --- a/src/components/management/EditEvent.vue +++ b/src/components/management/EditEvent.vue @@ -114,14 +114,15 @@ import { useEventStore } from '../../store'; import { emptyEvent, emptyJob, EditableEvent } from '../../store/models'; import { date, ModifyDateOptions } from 'quasar'; -import { computed, defineComponent, PropType, ref, onBeforeMount } from 'vue'; +import { computed, defineComponent, PropType, ref, onBeforeMount, watch } from 'vue'; import EditJobSlot from './EditJobSlot.vue'; -import RecurrenceRule from './RecurrenceRule.vue'; +import RecurrenceRuleVue from './RecurrenceRule.vue'; +import { RecurrenceRule } from 'app/events'; export default defineComponent({ name: 'EditEvent', - components: { IsoDateInput, EditJobSlot, RecurrenceRule }, + components: { IsoDateInput, EditJobSlot, RecurrenceRule: RecurrenceRuleVue }, props: { modelValue: { required: false, @@ -154,10 +155,10 @@ export default defineComponent({ const activeJob = ref<{ validate: () => Promise }>(); const templates = computed(() => store.templates); const template = ref(); - const event = ref(props.modelValue || emptyEvent(startDate.value)); + const event = ref(props.modelValue || emptyEvent()); const eventtypes = computed(() => store.eventTypes); const recurrent = ref(false); - const recurrenceRule = ref({ frequency: 'daily', interval: 1 }); + const recurrenceRule = ref({ frequency: 'daily', interval: 1 }); onBeforeMount(() => { void store.getEventTypes(); @@ -165,6 +166,10 @@ export default defineComponent({ void store.getTemplates(); }); + watch(props, (n, o) => { + if (event.value?.id !== n.modelValue?.id) reset(); + }); + function addJob() { if (!activeJob.value) event.value.jobs.push(emptyJob()); else diff --git a/src/components/management/RecurrenceRule.vue b/src/components/management/RecurrenceRule.vue index a2531ca..cc52dee 100644 --- a/src/components/management/RecurrenceRule.vue +++ b/src/components/management/RecurrenceRule.vue @@ -38,6 +38,7 @@ import { defineComponent, PropType } from 'vue'; import { IsoDateInput } from '@flaschengeist/api/components'; import { notEmpty } from '@flaschengeist/api'; +import { RecurrenceRule } from '../../events'; export default defineComponent({ name: 'RecurrenceRule', @@ -45,11 +46,11 @@ export default defineComponent({ props: { modelValue: { required: true, - type: Object as PropType, + type: Object as PropType, }, }, emits: { - 'update:modelValue': (rule: FG.RecurrenceRule) => !!rule, + 'update:modelValue': (rule: RecurrenceRule) => !!rule, }, setup(props, { emit }) { const freqTypes = [ diff --git a/src/components/overview/slots/EventSlot.vue b/src/components/overview/slots/EventSlot.vue index 4c3fe82..644d400 100644 --- a/src/components/overview/slots/EventSlot.vue +++ b/src/components/overview/slots/EventSlot.vue @@ -6,7 +6,7 @@ >
- {{ event.type.name }} + {{ typeName }} @@ -51,6 +51,7 @@ import { defineComponent, computed, PropType } from 'vue'; import { hasPermission } from '@flaschengeist/api'; import { PERMISSIONS } from '../../../permissions'; +import { useEventStore } from '../../../store'; import { date } from 'quasar'; import JobSlot from './JobSlot.vue'; @@ -69,6 +70,7 @@ export default defineComponent({ editEvent: (val: number) => !!val, }, setup(props, { emit }) { + const store = useEventStore(); const canDelete = computed(() => hasPermission(PERMISSIONS.DELETE)); const canEdit = computed( () => @@ -76,6 +78,11 @@ export default defineComponent({ (props.modelValue?.end || props.modelValue.start) >= date.buildDate({ hours: 0, minutes: 0, seconds: 0, milliseconds: 0 }) ); + const typeName = computed(() => + typeof props.modelValue.type === 'object' + ? props.modelValue.type.name + : store.eventTypes.find((e) => e.id === props.modelValue.type)?.name || 'Unbekannt' + ); const event = computed({ get: () => props.modelValue, @@ -95,6 +102,7 @@ export default defineComponent({ edit, event, remove, + typeName, }; }, }); diff --git a/src/components/overview/slots/JobSlot.vue b/src/components/overview/slots/JobSlot.vue index 190f6a8..b8cea89 100644 --- a/src/components/overview/slots/JobSlot.vue +++ b/src/components/overview/slots/JobSlot.vue @@ -5,7 +5,7 @@
- {{ modelValue.type.name }} + {{ typeName }}
{{ modelValue.comment }} @@ -87,6 +87,12 @@ export default defineComponent({ return userStore.findUser(service.userid)?.display_name || service.userid; } + const typeName = computed(() => + typeof props.modelValue.type === 'object' + ? props.modelValue.type.name + : store.jobTypes.find((j) => j.id === props.modelValue.type)?.name || 'Unbekannter Diensttyp' + ); + const isEnrolled = computed( () => props.modelValue.services.findIndex( @@ -174,6 +180,7 @@ export default defineComponent({ invite: () => invite(true), signOutFromJob, transfer: () => invite(false), + typeName, userDisplay, asHour, };