diff --git a/packages/nc-gui/components/smartsheet/Cell.vue b/packages/nc-gui/components/smartsheet/Cell.vue index 3b53294172..2ed187af22 100644 --- a/packages/nc-gui/components/smartsheet/Cell.vue +++ b/packages/nc-gui/components/smartsheet/Cell.vue @@ -66,43 +66,6 @@ const syncValue = useDebounceFn( 500, { maxWait: 2000 }, ) - -const isAutoSaved = $computed(() => { - return [ - UITypes.SingleLineText, - UITypes.LongText, - UITypes.PhoneNumber, - UITypes.Email, - UITypes.URL, - UITypes.Number, - UITypes.Decimal, - UITypes.Percent, - UITypes.Count, - UITypes.AutoNumber, - UITypes.SpecificDBType, - UITypes.Geometry, - UITypes.Duration, - ].includes(column?.value?.uidt as UITypes) -}) - -const isManualSaved = $computed(() => [UITypes.Currency].includes(column?.value?.uidt as UITypes)) - -const vModel = computed({ - get: () => props.modelValue, - set: (val) => { - if (val !== props.modelValue) { - currentRow.value.rowMeta.changed = true - emit('update:modelValue', val) - if (isAutoSaved) { - syncValue() - } else if (!isManualSaved) { - emit('save') - currentRow.value.rowMeta.changed = true - } - } - }, -}) - const { isPrimary, isURL, @@ -126,8 +89,26 @@ const { isMultiSelect, isPercent, isPhoneNumber, + isAutoSaved, + isManualSaved, } = useColumn(column) +const vModel = computed({ + get: () => props.modelValue, + set: (val) => { + if (val !== props.modelValue) { + currentRow.value.rowMeta.changed = true + emit('update:modelValue', val) + if (isAutoSaved.value) { + syncValue() + } else if (!isManualSaved.value) { + emit('save') + currentRow.value.rowMeta.changed = true + } + } + }, +}) + const syncAndNavigate = (dir: NavigateDir, e: KeyboardEvent) => { if (isJSON.value) return diff --git a/packages/nc-gui/composables/useColumn.ts b/packages/nc-gui/composables/useColumn.ts index 93710c3f77..a481e227a0 100644 --- a/packages/nc-gui/composables/useColumn.ts +++ b/packages/nc-gui/composables/useColumn.ts @@ -56,11 +56,10 @@ export function useColumn(column: Ref) { UITypes.AutoNumber, UITypes.SpecificDBType, UITypes.Geometry, + UITypes.Duration, ].includes(uiDatatype.value), ) - const isManualSaved = computed(() => - [UITypes.Currency, UITypes.Year, UITypes.Time, UITypes.Duration].includes(uiDatatype.value), - ) + const isManualSaved = computed(() => [UITypes.Currency].includes(uiDatatype.value)) const isPrimary = computed(() => column.value?.pv) return {