fix: disable create button when event data is not modified

This commit is contained in:
Shariq Ansari 2025-09-04 22:44:32 +05:30
parent 5eaf828758
commit 1d249b8fff

View File

@ -158,6 +158,7 @@
? __('Duplicate') ? __('Duplicate')
: __('Create') : __('Create')
" "
:disabled="!dirty"
:loading=" :loading="
mode === 'edit' mode === 'edit'
? eventsResource.setValue.loading ? eventsResource.setValue.loading
@ -224,6 +225,7 @@ const mode = computed(() => {
: 'create' : 'create'
}) })
const oldEvent = ref({})
const _event = ref({ const _event = ref({
title: '', title: '',
description: '', description: '',
@ -239,6 +241,10 @@ const _event = ref({
event_participants: [], event_participants: [],
}) })
const dirty = computed(() => {
return JSON.stringify(_event.value) !== JSON.stringify(oldEvent.value)
})
const peoples = computed({ const peoples = computed({
get() { get() {
return _event.value.event_participants || [] return _event.value.event_participants || []
@ -274,6 +280,8 @@ onMounted(() => {
event_participants: props.event.event_participants || [], event_participants: props.event.event_participants || [],
} }
oldEvent.value = JSON.parse(JSON.stringify(_event.value))
setTimeout(() => title.value?.el?.focus(), 100) setTimeout(() => title.value?.el?.focus(), 100)
} }
}) })