Browse Source

fix(gui-v2): revise based on PR comments

pull/2963/head
Wing-Kam Wong 2 years ago
parent
commit
048815d650
  1. 60
      packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue

60
packages/nc-gui-v2/components/smartsheet-column/CurrencyOptions.vue

@ -9,45 +9,43 @@ interface Option {
const { formState, validateInfos, setAdditionalValidations, sqlUi, onDataTypeChange, onAlter } = useColumnCreateStoreOrThrow() const { formState, validateInfos, setAdditionalValidations, sqlUi, onDataTypeChange, onAlter } = useColumnCreateStoreOrThrow()
const validators = computed(() => { const validators = {
return { 'meta.currency_locale': [
'meta.currency_locale': [ {
{ validator: (_: any, locale: any) => {
validator: (_: any, locale: any) => { return new Promise<void>((resolve, reject) => {
return new Promise<void>((resolve, reject) => { if (!validateCurrencyLocale(locale)) {
if (!validateCurrencyLocale(locale)) { return reject(new Error('Invalid locale'))
return reject(new Error('Invalid locale')) }
} resolve()
resolve() })
})
},
}, },
], },
'meta.currency_code': [ ],
{ 'meta.currency_code': [
validator: (_: any, currencyCode: any) => { {
return new Promise<void>((resolve, reject) => { validator: (_: any, currencyCode: any) => {
if (!validateCurrencyCode(currencyCode)) { return new Promise<void>((resolve, reject) => {
return reject(new Error('Invalid Currency Code')) if (!validateCurrencyCode(currencyCode)) {
} return reject(new Error('Invalid Currency Code'))
resolve() }
}) resolve()
}, })
}, },
], },
} ],
}) }
// set additional validations // set additional validations
setAdditionalValidations({ setAdditionalValidations({
...validators.value, ...validators,
}) })
const { isPg } = useProject() const { isPg } = useProject()
const currencyList = ref(currencyCodes) const currencyList = currencyCodes || []
const currencyLocaleList = ref(currencyLocales()) const currencyLocaleList = currencyLocales() || []
const isMoney = computed(() => formState.value.dt === 'money') const isMoney = computed(() => formState.value.dt === 'money')
@ -73,7 +71,7 @@ function filterOption(input: string, option: Option) {
:filter-option="filterOption" :filter-option="filterOption"
:disabled="isMoney && isPg" :disabled="isMoney && isPg"
> >
<a-select-option v-for="(currencyLocale, i) in currencyLocaleList ?? []" :key="i" :value="currencyLocale.value"> <a-select-option v-for="(currencyLocale, i) of currencyLocaleList" :key="i" :value="currencyLocale.value">
{{ currencyLocale.text }} {{ currencyLocale.text }}
</a-select-option> </a-select-option>
</a-select> </a-select>
@ -89,7 +87,7 @@ function filterOption(input: string, option: Option) {
size="small" size="small"
:disabled="isMoney && isPg" :disabled="isMoney && isPg"
> >
<a-select-option v-for="(currencyCode, i) in currencyList ?? []" :key="i" :value="currencyCode"> <a-select-option v-for="(currencyCode, i) of currencyList" :key="i" :value="currencyCode">
{{ currencyCode }} {{ currencyCode }}
</a-select-option> </a-select-option>
</a-select> </a-select>

Loading…
Cancel
Save