From d03fc7bd57d24c6298607cb104393de4390efb27 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Tue, 10 Dec 2024 10:15:34 +0000 Subject: [PATCH] fix(nc-gui): auto same duration cell value --- packages/nc-gui/components/cell/Duration.vue | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/cell/Duration.vue b/packages/nc-gui/components/cell/Duration.vue index 7c8f6bea83..1430ae9b0b 100644 --- a/packages/nc-gui/components/cell/Duration.vue +++ b/packages/nc-gui/components/cell/Duration.vue @@ -30,14 +30,32 @@ const durationType = computed(() => parseProp(column?.value?.meta)?.duration || const durationPlaceholder = computed(() => durationOptions[durationType.value].title) +const tempState = ref() + const localState = computed({ - get: () => convertMS2Duration(modelValue, durationType.value), + get: () => { + if (tempState.value === undefined) { + return convertMS2Duration(modelValue, durationType.value) + } + + return tempState.value + }, set: (val) => { + tempState.value = val + isEdited.value = true const res = convertDurationToSeconds(val, durationType.value) if (res._isValid) { durationInMS.value = res._sec } + + if (!val) { + emit('update:modelValue', null) + isEdited.value = false + tempState.value = undefined + } else { + emit('update:modelValue', durationInMS.value) + } }, }) @@ -63,7 +81,10 @@ const submitDuration = () => { if (isEdited.value) { emit('update:modelValue', durationInMS.value) } + isEdited.value = false + + tempState.value = undefined } const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!