This commit is contained in:
2024-04-07 17:18:58 +02:00
parent d7fafda78e
commit 491cbf15b6
7 changed files with 229 additions and 311 deletions

View File

@@ -61,23 +61,6 @@ const convertResourceIds = () => {
})
}
const createEvent = async () => {
const {data,error} = await supabase
.from("events")
.insert([newEventData.value])
.select()
if(error) {
console.log(error)
}
console.log("OK")
showNewEventModal.value = false
newEventData.value = {}
dataStore.fetchEvents()
}
//Calendar Config
const calendarOptionsGrid = reactive({
@@ -96,23 +79,19 @@ const calendarOptionsGrid = reactive({
weekNumbers: true,
select: function(info) {
console.log(info)
/*newEventData.value.resourceId = info.resource.id
if(info.resource.extendedProps){
newEventData.value.resourceType = info.resource.extendedProps.type
}*/
newEventData.value.start = info.startStr
newEventData.value.end = info.endStr
//showNewEventModal.value = true
router.push(`/events/edit/?start=${info.startStr}&end=${info.endStr}&source=grid`)
},
eventClick: function (info){
console.log(info)
router.push(`/events/show/${info.event.id}`)
//selectedEvent.value = info.event
//showEventModal.value = true
if(info.event.title.startsWith("Abw.:")){
router.push(`/absencerequests/show/${info.event.id}`)
} else {
router.push(`/events/show/${info.event.id}`)
}
},
})
@@ -130,28 +109,14 @@ const calendarOptionsTimeline = reactive({
initialEvents: dataStore.getEventsByResource,
selectable: true,
select: function (info) {
/*let resourceObj = {}
resourceObj.id = info.resource.id
if(info.resource.extendedProps){
resourceObj.type = info.resource.extendedProps.type
}
console.log(resourceObj)*/
selectedResources.value = [info.resource.id]
newEventData.value.start = info.startStr
newEventData.value.end = info.endStr
console.log(newEventData.value)
convertResourceIds()
//showNewEventModal.value = true
router.push(`/events/edit/?start=${info.startStr}&end=${info.endStr}&resources=${JSON.stringify([info.resource.id])}&source=timeline`)
},
eventClick: function (info){
router.push(`/events/show/${info.event.id}`)
//selectedEvent.value = info.event
//showEventModal.value = true
if(info.event.title.startsWith("Abw.:")){
router.push(`/absencerequests/show/${info.event.id}`)
} else {
router.push(`/events/show/${info.event.id}`)
}
},
resourceGroupField: "type",
resourceOrder: "-type",
@@ -184,125 +149,12 @@ const calendarOptionsTimeline = reactive({
</script>
<template>
<!-- NEW EVENT MODAL -->
<UModal
v-model="showNewEventModal"
>
<UCard>
<template #header>
Neuen Termin erstellen
</template>
<UFormGroup
label="Resource:"
>
<USelectMenu
v-model="selectedResources"
:options="resources"
option-attribute="title"
value-attribute="id"
multiple
@change="convertResourceIds"
>
<template #label>
<span v-if="selectedResources.length == 0">Keine Ressourcen ausgewählt</span>
<span v-else >{{ selectedResources.length }} ausgewählt</span>
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Titel:"
>
<UInput
v-model="newEventData.title"
/>
</UFormGroup>
<UFormGroup
label="Projekt:"
>
<USelectMenu
v-model="newEventData.project"
:options="dataStore.projects"
option-attribute="name"
value-attribute="id"
searchable
searchable-placeholder="Suche..."
:search-attributes="['name']"
>
<template #label>
{{dataStore.getProjectById(newEventData.project) ? dataStore.getProjectById(newEventData.project).name : "Kein Projekt ausgewählt"}}
</template>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Typ:"
>
<USelectMenu
v-model="newEventData.type"
:options="eventTypes"
option-attribute="label"
value-attribute="label"
>
</USelectMenu>
</UFormGroup>
<UFormGroup
label="Start:"
>
<UInput
v-model="newEventData.start"
/>
</UFormGroup>
<UFormGroup
label="Ende:"
>
<UInput
v-model="newEventData.end"
/>
</UFormGroup>
<template #footer>
<UButton
@click="createEvent"
>
Erstellen
</UButton>
</template>
</UCard>
</UModal>
<!--SHOW EVENT MODAL -->
<UModal
v-model="showEventModal"
>
<UCard>
<template #header>
{{selectedEvent.title}}
</template>
Start: {{dayjs(selectedEvent.startStr).format("DD.MM.YYYY HH:mm")}}<br>
Ende: {{dayjs(selectedEvent.endStr).format("DD.MM.YYYY HH:mm")}}
<DevOnly>
<UDivider class="my-3"/>
{{selectedEvent}}
</DevOnly>
</UCard>
</UModal>
<UDashboardNavbar :title="currentItem ? currentItem.name : ''">
<template #right>
</template>
</UDashboardNavbar>
<div v-if="mode === 'grid'" class="p-5">
<FullCalendar
:options="calendarOptionsGrid"