Browse Source

fix(nc-gui): currency handle manual save

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/4114/head
mertmit 2 years ago
parent
commit
1d495268f5
  1. 20
      packages/nc-gui/components/cell/Currency.vue
  2. 2
      packages/nc-gui/components/smartsheet/Cell.vue

20
packages/nc-gui/components/cell/Currency.vue

@ -8,14 +8,16 @@ interface Props {
const props = defineProps<Props>() const props = defineProps<Props>()
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue', 'save'])
const column = inject(ColumnInj)! const column = inject(ColumnInj)!
const editEnabled = inject(EditModeInj) const editEnabled = inject(EditModeInj)!
const vModel = useVModel(props, 'modelValue', emit) const vModel = useVModel(props, 'modelValue', emit)
const lastSaved = ref()
const currencyMeta = computed(() => { const currencyMeta = computed(() => {
return { return {
currency_locale: 'en-US', currency_locale: 'en-US',
@ -38,6 +40,18 @@ const currency = computed(() => {
}) })
const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus() const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
const submitCurrency = () => {
if (lastSaved.value !== vModel.value) {
lastSaved.value = vModel.value
emit('save')
}
editEnabled.value = false
}
onMounted(() => {
lastSaved.value = vModel.value
})
</script> </script>
<template> <template>
@ -46,7 +60,7 @@ const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
:ref="focus" :ref="focus"
v-model="vModel" v-model="vModel"
class="w-full h-full border-none outline-none px-2" class="w-full h-full border-none outline-none px-2"
@blur="editEnabled = false" @blur="submitCurrency"
/> />
<span v-else-if="vModel">{{ currency }}</span> <span v-else-if="vModel">{{ currency }}</span>

2
packages/nc-gui/components/smartsheet/Cell.vue

@ -163,7 +163,7 @@ const syncAndNavigate = (dir: NavigateDir, e: KeyboardEvent) => {
<LazyCellUrl v-else-if="isURL" v-model="vModel" /> <LazyCellUrl v-else-if="isURL" v-model="vModel" />
<LazyCellPhoneNumber v-else-if="isPhoneNumber" v-model="vModel" /> <LazyCellPhoneNumber v-else-if="isPhoneNumber" v-model="vModel" />
<LazyCellPercent v-else-if="isPercent" v-model="vModel" /> <LazyCellPercent v-else-if="isPercent" v-model="vModel" />
<LazyCellCurrency v-else-if="isCurrency" v-model="vModel" /> <LazyCellCurrency v-else-if="isCurrency" v-model="vModel" @save="emit('save')" />
<LazyCellDecimal v-else-if="isDecimal" v-model="vModel" /> <LazyCellDecimal v-else-if="isDecimal" v-model="vModel" />
<LazyCellInteger v-else-if="isInt" v-model="vModel" /> <LazyCellInteger v-else-if="isInt" v-model="vModel" />
<LazyCellFloat v-else-if="isFloat" v-model="vModel" /> <LazyCellFloat v-else-if="isFloat" v-model="vModel" />

Loading…
Cancel
Save