refactor: streamline event handling and improve onSuccess callbacks in Calendar

This commit is contained in:
Shariq Ansari 2025-08-06 14:32:23 +05:30
parent 1c432d8610
commit f9f1c2a437

View File

@ -112,7 +112,7 @@ import {
dayjs, dayjs,
CalendarActiveEvent as activeEvent, CalendarActiveEvent as activeEvent,
} from 'frappe-ui' } from 'frappe-ui'
import { ref } from 'vue' import { onMounted, ref } from 'vue'
const { user } = sessionStore() const { user } = sessionStore()
const { $dialog } = globalStore() const { $dialog } = globalStore()
@ -149,22 +149,13 @@ const events = createListResource({
})) }))
}, },
insert: { insert: {
onSuccess: async () => { onSuccess: () => events.reload(),
await events.reload()
calendar.value.reloadEvents()
},
}, },
delete: { delete: {
onSuccess: async () => { onSuccess: () => events.reload(),
await events.reload()
calendar.value.reloadEvents()
},
}, },
setValue: { setValue: {
onSuccess: async () => { onSuccess: () => events.reload(),
await events.reload()
calendar.value.reloadEvents()
},
}, },
}) })
@ -212,9 +203,13 @@ function updateEvent(_event) {
}) })
showEventPanel.value = false showEventPanel.value = false
showEventDetails.value = true
if (showEventPanel.value) {
showEventPanel.value = true
activeEvent.value = _event.id
}
event.value = _event event.value = _event
activeEvent.value = _event.id
} }
function deleteEvent(eventID) { function deleteEvent(eventID) {
@ -243,6 +238,12 @@ function deleteEvent(eventID) {
}) })
} }
onMounted(() => {
activeEvent.value = ''
showEventPanel.value = false
showEventDetails.value = false
})
const showEventPanel = ref(false) const showEventPanel = ref(false)
const showEventDetails = ref(false) const showEventDetails = ref(false)
const event = ref({}) const event = ref({})