Browse Source

fix: pg database type money

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/2257/head
mertmit 3 years ago
parent
commit
72551a440e
  1. 7
      packages/nc-gui/components/project/spreadsheet/components/cell/CurrencyCell.vue
  2. 77
      packages/nc-gui/components/project/spreadsheet/components/editColumn/CurrencyOptions.vue

7
packages/nc-gui/components/project/spreadsheet/components/cell/CurrencyCell.vue

@ -13,8 +13,11 @@ export default {
computed: { computed: {
currency() { currency() {
try { try {
return new Intl.NumberFormat(this.currencyMeta.currency_locale || 'en-US', return isNaN(this.value)
{ style: 'currency', currency: this.currencyMeta.currency_code || 'USD' }).format(this.value) ? this.value
: new Intl.NumberFormat(this.currencyMeta.currency_locale || 'en-US',
{ style: 'currency', currency: this.currencyMeta.currency_code || 'USD' })
.format(this.value)
} catch (e) { } catch (e) {
return this.value return this.value
} }

77
packages/nc-gui/components/project/spreadsheet/components/editColumn/CurrencyOptions.vue

@ -1,32 +1,39 @@
<template> <template>
<v-row class="currency-wrapper"> <v-tooltip top :disabled="!(isMoney && isPG)">
<v-col cols="6"> <template #activator="{ on, attrs }">
<!--label="Format Locale"--> <v-row class="currency-wrapper" v-bind="attrs" v-on="on">
<v-autocomplete <v-col cols="6">
v-model="colMeta.currency_locale" <!--label="Format Locale"-->
dense <v-autocomplete
class="caption" v-model="colMeta.currency_locale"
label="Currency Locale" dense
:rules="[isValidCurrencyLocale]" class="caption"
:items="currencyLocaleList" label="Currency Locale"
outlined :rules="[isValidCurrencyLocale]"
hide-details :items="currencyLocaleList"
/> outlined
</v-col> hide-details
<v-col cols="6"> :disabled="isMoney && isPG"
<!--label="Currency Code"--> />
<v-autocomplete </v-col>
v-model="colMeta.currency_code" <v-col cols="6">
dense <!--label="Currency Code"-->
class="caption" <v-autocomplete
label="Currency Code" v-model="colMeta.currency_code"
:rules="[isValidCurrencyCode]" dense
:items="currencyList" class="caption"
outlined label="Currency Code"
hide-details :rules="[isValidCurrencyCode]"
/> :items="currencyList"
</v-col> outlined
</v-row> hide-details
:disabled="isMoney && isPG"
/>
</v-col>
</v-row>
</template>
<span>{{ message }}</span>
</v-tooltip>
</template> </template>
<script> <script>
@ -49,6 +56,20 @@ export default {
return validateCurrencyCode(value) || 'Invalid Currency Code' return validateCurrencyCode(value) || 'Invalid Currency Code'
} }
}), }),
computed: {
isMoney() {
return this.column.dt === 'money'
},
isPG() {
return ['pg'].includes(this.$store.getters['project/GtrClientType'])
},
message() {
if (this.isMoney && this.isPG) {
return "PostgreSQL 'money' type has own currency settings"
}
return ''
}
},
watch: { watch: {
value() { value() {
this.colMeta = this.value || {} this.colMeta = this.value || {}

Loading…
Cancel
Save