fix: handle syncing of event
This commit is contained in:
parent
0d1a4effdb
commit
223cbf4020
@ -154,7 +154,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Event create, duplicate & edit -->
|
<!-- Event new, duplicate & edit -->
|
||||||
<div v-else class="flex flex-col overflow-y-auto">
|
<div v-else class="flex flex-col overflow-y-auto">
|
||||||
<div class="flex gap-2 items-center px-4.5 py-3">
|
<div class="flex gap-2 items-center px-4.5 py-3">
|
||||||
<Dropdown class="ml-1" :options="colors">
|
<Dropdown class="ml-1" :options="colors">
|
||||||
@ -224,14 +224,14 @@
|
|||||||
v-if="!_event.isFullDay"
|
v-if="!_event.isFullDay"
|
||||||
class="max-w-[105px]"
|
class="max-w-[105px]"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
v-model="_event.fromTime"
|
:modelValue="_event.fromTime"
|
||||||
:placeholder="__('Start Time')"
|
:placeholder="__('Start Time')"
|
||||||
@update:modelValue="(time) => updateTime(time, true)"
|
@update:modelValue="(time) => updateTime(time, true)"
|
||||||
/>
|
/>
|
||||||
<TimePicker
|
<TimePicker
|
||||||
class="max-w-[105px]"
|
class="max-w-[105px]"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
v-model="_event.toTime"
|
:modelValue="_event.toTime"
|
||||||
:options="toOptions"
|
:options="toOptions"
|
||||||
:placeholder="__('End Time')"
|
:placeholder="__('End Time')"
|
||||||
placement="bottom-end"
|
placement="bottom-end"
|
||||||
@ -369,10 +369,6 @@ import { ref, computed, watch, h } from 'vue'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
event: {
|
|
||||||
type: Object,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
mode: {
|
mode: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'details',
|
default: 'details',
|
||||||
@ -394,6 +390,7 @@ const { $dialog } = globalStore()
|
|||||||
const { getUser } = usersStore()
|
const { getUser } = usersStore()
|
||||||
|
|
||||||
const show = defineModel()
|
const show = defineModel()
|
||||||
|
const event = defineModel('event')
|
||||||
|
|
||||||
const _event = ref({})
|
const _event = ref({})
|
||||||
|
|
||||||
@ -421,7 +418,7 @@ const peoples = computed({
|
|||||||
const title = computed(() => {
|
const title = computed(() => {
|
||||||
if (props.mode === 'details') return __('Event details')
|
if (props.mode === 'details') return __('Event details')
|
||||||
if (props.mode === 'edit') return __('Editing event')
|
if (props.mode === 'edit') return __('Editing event')
|
||||||
if (props.mode === 'create') return __('New event')
|
if (props.mode === 'new') return __('New event')
|
||||||
return __('Duplicate event')
|
return __('Duplicate event')
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -440,7 +437,7 @@ const displayedPeoples = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => props.mode, () => props.event],
|
[() => props.mode, () => event.value],
|
||||||
() => {
|
() => {
|
||||||
error.value = null
|
error.value = null
|
||||||
focusOnTitle()
|
focusOnTitle()
|
||||||
@ -451,13 +448,13 @@ watch(
|
|||||||
|
|
||||||
function fetchEvent() {
|
function fetchEvent() {
|
||||||
if (
|
if (
|
||||||
props.event.id &&
|
event.value.id &&
|
||||||
props.event.id !== 'new-event' &&
|
event.value.id !== 'new-event' &&
|
||||||
props.event.id !== 'duplicate-event'
|
event.value.id !== 'duplicate-event'
|
||||||
) {
|
) {
|
||||||
let e = createDocumentResource({
|
let e = createDocumentResource({
|
||||||
doctype: 'Event',
|
doctype: 'Event',
|
||||||
name: props.event.id,
|
name: event.value.id,
|
||||||
fields: ['*'],
|
fields: ['*'],
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
_event.value = parseEvent(data)
|
_event.value = parseEvent(data)
|
||||||
@ -469,8 +466,8 @@ function fetchEvent() {
|
|||||||
oldEvent.value = { ..._event.value }
|
oldEvent.value = { ..._event.value }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_event.value = props.event
|
_event.value = event.value
|
||||||
oldEvent.value = { ...props.event }
|
oldEvent.value = { ...event.value }
|
||||||
}
|
}
|
||||||
showAllParticipants.value = false
|
showAllParticipants.value = false
|
||||||
}
|
}
|
||||||
@ -501,7 +498,7 @@ function parseEvent(_e) {
|
|||||||
|
|
||||||
function focusOnTitle() {
|
function focusOnTitle() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (['edit', 'create', 'duplicate'].includes(props.mode)) {
|
if (['edit', 'new', 'duplicate'].includes(props.mode)) {
|
||||||
eventTitle.value?.el?.focus()
|
eventTitle.value?.el?.focus()
|
||||||
}
|
}
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|||||||
@ -102,7 +102,7 @@
|
|||||||
<CalendarEventPanel
|
<CalendarEventPanel
|
||||||
v-if="showEventPanel"
|
v-if="showEventPanel"
|
||||||
v-model="showEventPanel"
|
v-model="showEventPanel"
|
||||||
:event="event"
|
v-model:event="event"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
@save="saveEvent"
|
@save="saveEvent"
|
||||||
@edit="editDetails"
|
@edit="editDetails"
|
||||||
@ -221,6 +221,16 @@ function createEvent(_event) {
|
|||||||
|
|
||||||
async function updateEvent(_event) {
|
async function updateEvent(_event) {
|
||||||
if (!_event.id) return
|
if (!_event.id) return
|
||||||
|
|
||||||
|
if (
|
||||||
|
['duplicate', 'new'].includes(mode.value) &&
|
||||||
|
!['duplicate-event', 'new-event'].includes(_event.id)
|
||||||
|
) {
|
||||||
|
event.value = { id: _event.id }
|
||||||
|
activeEvent.value = _event.id
|
||||||
|
mode.value = 'details'
|
||||||
|
}
|
||||||
|
|
||||||
if (!mode.value || mode.value === 'edit' || mode.value === 'details') {
|
if (!mode.value || mode.value === 'edit' || mode.value === 'details') {
|
||||||
// Ensure Contacts exist for participants referencing a new/unknown Contact, if not create them
|
// Ensure Contacts exist for participants referencing a new/unknown Contact, if not create them
|
||||||
if (
|
if (
|
||||||
@ -253,6 +263,8 @@ async function updateEvent(_event) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
event.value = { ..._event }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -366,7 +378,7 @@ function newEvent(e, duplicate = false) {
|
|||||||
|
|
||||||
showEventPanel.value = true
|
showEventPanel.value = true
|
||||||
activeEvent.value = duplicate ? 'duplicate-event' : 'new-event'
|
activeEvent.value = duplicate ? 'duplicate-event' : 'new-event'
|
||||||
mode.value = duplicate ? 'duplicate' : 'create'
|
mode.value = duplicate ? 'duplicate' : 'new'
|
||||||
}
|
}
|
||||||
|
|
||||||
function duplicateEvent(e) {
|
function duplicateEvent(e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user