From 048815d6507158866ca365b383484d821af9cb39 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Wed, 3 Aug 2022 16:10:14 +0800 Subject: [PATCH] fix(gui-v2): revise based on PR comments --- .../smartsheet-column/CurrencyOptions.vue | 60 +++++++++---------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue b/packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue index ae4a95d2a1..29cf63b9e4 100644 --- a/packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue +++ b/packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue @@ -9,45 +9,43 @@ interface Option { const { formState, validateInfos, setAdditionalValidations, sqlUi, onDataTypeChange, onAlter } = useColumnCreateStoreOrThrow() -const validators = computed(() => { - return { - 'meta.currency_locale': [ - { - validator: (_: any, locale: any) => { - return new Promise((resolve, reject) => { - if (!validateCurrencyLocale(locale)) { - return reject(new Error('Invalid locale')) - } - resolve() - }) - }, +const validators = { + 'meta.currency_locale': [ + { + validator: (_: any, locale: any) => { + return new Promise((resolve, reject) => { + if (!validateCurrencyLocale(locale)) { + return reject(new Error('Invalid locale')) + } + resolve() + }) }, - ], - 'meta.currency_code': [ - { - validator: (_: any, currencyCode: any) => { - return new Promise((resolve, reject) => { - if (!validateCurrencyCode(currencyCode)) { - return reject(new Error('Invalid Currency Code')) - } - resolve() - }) - }, + }, + ], + 'meta.currency_code': [ + { + validator: (_: any, currencyCode: any) => { + return new Promise((resolve, reject) => { + if (!validateCurrencyCode(currencyCode)) { + return reject(new Error('Invalid Currency Code')) + } + resolve() + }) }, - ], - } -}) + }, + ], +} // set additional validations setAdditionalValidations({ - ...validators.value, + ...validators, }) const { isPg } = useProject() -const currencyList = ref(currencyCodes) +const currencyList = currencyCodes || [] -const currencyLocaleList = ref(currencyLocales()) +const currencyLocaleList = currencyLocales() || [] const isMoney = computed(() => formState.value.dt === 'money') @@ -73,7 +71,7 @@ function filterOption(input: string, option: Option) { :filter-option="filterOption" :disabled="isMoney && isPg" > - + {{ currencyLocale.text }} @@ -89,7 +87,7 @@ function filterOption(input: string, option: Option) { size="small" :disabled="isMoney && isPg" > - + {{ currencyCode }}