fix: reload event after editing event

This commit is contained in:
Shariq Ansari 2025-08-30 13:05:07 +05:30
parent c69a468e35
commit 92b79c2195
2 changed files with 12 additions and 8 deletions

View File

@ -426,6 +426,8 @@ const eventTitle = ref(null)
const error = ref(null)
const showAllParticipants = ref(false)
const eventResource = ref({})
const oldEvent = ref(null)
const dirty = computed(() => {
return JSON.stringify(oldEvent.value) !== JSON.stringify(_event.value)
@ -452,7 +454,7 @@ function fetchEvent() {
event.value.id !== 'new-event' &&
event.value.id !== 'duplicate-event'
) {
let e = createDocumentResource({
eventResource.value = createDocumentResource({
doctype: 'Event',
name: event.value.id,
fields: ['*'],
@ -461,9 +463,11 @@ function fetchEvent() {
oldEvent.value = { ..._event.value }
},
})
if (e.doc) {
_event.value = parseEvent(e.doc)
if (eventResource.value.doc && !event.value.reloadEvent) {
_event.value = parseEvent(eventResource.value.doc)
oldEvent.value = { ..._event.value }
} else {
eventResource.value.reload()
}
} else {
_event.value = event.value

View File

@ -190,12 +190,12 @@ function removeTempEvents() {
events.data = events.data.filter((ev) => !isTempEvent(ev.id))
}
function openEvent(e, nextMode) {
function openEvent(e, nextMode, reloadEvent = false) {
const _e = e?.calendarEvent || e
if (!_e?.id || isTempEvent(_e.id)) return
removeTempEvents()
showEventPanel.value = true
event.value = { id: _e.id }
event.value = { id: _e.id, reloadEvent }
activeEvent.value = _e.id
mode.value = nextMode
}
@ -269,7 +269,7 @@ async function updateEvent(_event, afterDrag = false) {
{
onSuccess: async (e) => {
await events.reload()
showEventPanel.value && showDetails({ id: e.name })
showEventPanel.value && showDetails({ id: e.name }, true)
},
},
)
@ -315,8 +315,8 @@ onMounted(() => {
showEventPanel.value = false
})
function showDetails(e) {
openEvent(e, 'details')
function showDetails(e, reloadEvent = false) {
openEvent(e, 'details', reloadEvent)
}
function editDetails(e) {