fix: show new/edit event modal

This commit is contained in:
Shariq Ansari 2025-04-23 15:46:56 +05:30
parent 7ea8c60e5d
commit 743ffc0cf2
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,35 @@
<template>
<Dialog v-model="show" :options="{ size: '2xl' }">
<template #body> Hello </template>
</Dialog>
</template>
<script setup>
import { ref, nextTick, watch, computed } from 'vue'
const show = defineModel()
const event = defineModel('event')
const loading = ref(false)
const error = ref(null)
const title = ref(null)
const editMode = ref(false)
let _event = ref({})
watch(
() => show.value,
(value) => {
if (!value) return
editMode.value = false
nextTick(() => {
title.value.el.focus()
_event.value = { ...event.value }
if (_event.value.name) {
editMode.value = true
}
})
},
)
</script>

View File

@ -25,6 +25,9 @@
@create="(event) => createEvent(event)" @create="(event) => createEvent(event)"
@update="(event) => updateEvent(event)" @update="(event) => updateEvent(event)"
@delete="(eventID) => deleteEvent(eventID)" @delete="(eventID) => deleteEvent(eventID)"
:onClick="showDetails"
:onDblClick="editDetails"
:onCellDblClick="showNewModal"
> >
<template <template
#header="{ #header="{
@ -76,9 +79,11 @@
</p> </p>
</template> </template>
</Calendar> </Calendar>
<CalendarModal v-model="showModal" v-model:event="event" />
</div> </div>
</template> </template>
<script setup> <script setup>
import CalendarModal from '@/components/Modals/CalendarModal.vue'
import ViewBreadcrumbs from '@/components/ViewBreadcrumbs.vue' import ViewBreadcrumbs from '@/components/ViewBreadcrumbs.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import { sessionStore } from '@/stores/session' import { sessionStore } from '@/stores/session'
@ -138,6 +143,9 @@ function createEvent(event) {
event_type: event.eventType, event_type: event.eventType,
color: event.color, color: event.color,
}) })
showModal.value = false
event.value = {}
} }
function updateEvent(event) { function updateEvent(event) {
@ -153,6 +161,9 @@ function updateEvent(event) {
event_type: event.eventType, event_type: event.eventType,
color: event.color, color: event.color,
}) })
showModal.value = false
event.value = {}
} }
function deleteEvent(eventID) { function deleteEvent(eventID) {
@ -176,4 +187,27 @@ function deleteEvent(eventID) {
], ],
}) })
} }
const showModal = ref(false)
const event = ref({})
function showDetails(e) {}
function editDetails(e) {
showModal.value = true
event.value = { ...e.calendarEvent }
}
function showNewModal(e) {
showModal.value = true
event.value = {
title: '',
description: '',
date: dayjs(e.date).format('YYYY-MM-DD'),
from_time: fromTime,
to_time: toTime,
isFullDay: false,
eventType: 'Public',
}
}
</script> </script>