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. 23
      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: {
currency() {
try {
return new Intl.NumberFormat(this.currencyMeta.currency_locale || 'en-US',
{ style: 'currency', currency: this.currencyMeta.currency_code || 'USD' }).format(this.value)
return isNaN(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) {
return this.value
}

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

@ -1,5 +1,7 @@
<template>
<v-row class="currency-wrapper">
<v-tooltip top :disabled="!(isMoney && isPG)">
<template #activator="{ on, attrs }">
<v-row class="currency-wrapper" v-bind="attrs" v-on="on">
<v-col cols="6">
<!--label="Format Locale"-->
<v-autocomplete
@ -11,6 +13,7 @@
:items="currencyLocaleList"
outlined
hide-details
:disabled="isMoney && isPG"
/>
</v-col>
<v-col cols="6">
@ -24,9 +27,13 @@
:items="currencyList"
outlined
hide-details
:disabled="isMoney && isPG"
/>
</v-col>
</v-row>
</template>
<span>{{ message }}</span>
</v-tooltip>
</template>
<script>
@ -49,6 +56,20 @@ export default {
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: {
value() {
this.colMeta = this.value || {}

Loading…
Cancel
Save