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