feat: enhance event creation and updating logic in Calendar component
This commit is contained in:
parent
10e3adfd18
commit
aa7d9affdb
@ -247,7 +247,16 @@ watch(
|
||||
title.value = 'Duplicate event'
|
||||
}
|
||||
|
||||
nextTick(() => (_event.value = { ...newEvent }))
|
||||
nextTick(() => {
|
||||
if (props.mode === 'create') {
|
||||
_event.value.fromDate = newEvent.fromDate
|
||||
_event.value.toDate = newEvent.toDate
|
||||
_event.value.fromTime = newEvent.fromTime
|
||||
_event.value.toTime = newEvent.toTime
|
||||
} else {
|
||||
_event.value = { ...newEvent }
|
||||
}
|
||||
})
|
||||
setTimeout(() => eventTitle.value?.el?.focus(), 100)
|
||||
},
|
||||
{ immediate: true },
|
||||
|
||||
@ -157,7 +157,11 @@ const events = createListResource({
|
||||
})
|
||||
|
||||
function saveEvent(_event) {
|
||||
_event.id ? updateEvent(_event) : createEvent(_event)
|
||||
if (!event.id || event.id === 'new-event' || event.id === 'duplicate-event') {
|
||||
createEvent(_event)
|
||||
} else {
|
||||
updateEvent(_event)
|
||||
}
|
||||
}
|
||||
|
||||
function createEvent(_event) {
|
||||
@ -188,7 +192,7 @@ function createEvent(_event) {
|
||||
function updateEvent(_event) {
|
||||
if (!_event.id) return
|
||||
|
||||
if (mode.value === 'edit' || mode.value === 'details') {
|
||||
if (!mode.value || mode.value === 'edit' || mode.value === 'details') {
|
||||
events.setValue.submit({
|
||||
name: _event.id,
|
||||
subject: _event.title,
|
||||
@ -271,6 +275,7 @@ function newEvent(e, duplicate = false) {
|
||||
showEventPanel.value = true
|
||||
|
||||
event.value = {
|
||||
id: duplicate ? 'duplicate-event' : 'new-event',
|
||||
title: duplicate ? `${e.title} (Copy)` : '',
|
||||
description: e.description || '',
|
||||
date: fromDate,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user