diff --git a/packages/nc-gui/components/project/spreadsheet/components/Cell.vue b/packages/nc-gui/components/project/spreadsheet/components/Cell.vue
index 260e721fc4..5dd090cedc 100644
--- a/packages/nc-gui/components/project/spreadsheet/components/Cell.vue
+++ b/packages/nc-gui/components/project/spreadsheet/components/Cell.vue
@@ -18,6 +18,7 @@
+
{{ value }}
@@ -35,10 +36,11 @@ import EditableAttachmentCell from '~/components/project/spreadsheet/components/
import BooleanCell from '~/components/project/spreadsheet/components/cell/BooleanCell'
import EmailCell from '~/components/project/spreadsheet/components/cell/EmailCell'
import RatingCell from '~/components/project/spreadsheet/components/editableCell/RatingCell'
+import CurrencyCell from '@/components/project/spreadsheet/components/cell/CurrencyCell'
export default {
name: 'TableCell',
- components: { RatingCell, EmailCell, TimeCell, DateTimeCell, DateCell, JsonCell, UrlCell, EditableAttachmentCell, EnumCell, SetListCell, BooleanCell },
+ components: { RatingCell, EmailCell, TimeCell, DateTimeCell, DateCell, JsonCell, UrlCell, EditableAttachmentCell, EnumCell, SetListCell, BooleanCell, CurrencyCell },
mixins: [cell],
props: ['value', 'dbAlias', 'isLocked', 'selected', 'column'],
computed: {
diff --git a/packages/nc-gui/components/project/spreadsheet/components/EditColumn.vue b/packages/nc-gui/components/project/spreadsheet/components/EditColumn.vue
index 441b800962..15d7c07ac7 100644
--- a/packages/nc-gui/components/project/spreadsheet/components/EditColumn.vue
+++ b/packages/nc-gui/components/project/spreadsheet/components/EditColumn.vue
@@ -166,6 +166,12 @@
:meta="meta"
/>
+
-
-
+
+ {{ currency }}
+
+
+
+
+
+
diff --git a/packages/nc-gui/components/project/spreadsheet/components/editColumn/CurrencyOptions.vue b/packages/nc-gui/components/project/spreadsheet/components/editColumn/CurrencyOptions.vue
new file mode 100644
index 0000000000..fec666ada1
--- /dev/null
+++ b/packages/nc-gui/components/project/spreadsheet/components/editColumn/CurrencyOptions.vue
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/nc-gui/components/project/spreadsheet/mixins/cell.js b/packages/nc-gui/components/project/spreadsheet/mixins/cell.js
index 57880fd019..85fb8c5238 100644
--- a/packages/nc-gui/components/project/spreadsheet/mixins/cell.js
+++ b/packages/nc-gui/components/project/spreadsheet/mixins/cell.js
@@ -66,7 +66,7 @@ export default {
return this.uiDatatype === UITypes.Rating
},
isCurrency() {
- return this.column.uidt == 'Currency'
+ return this.uiDatatype === 'Currency'
}
}
diff --git a/packages/nc-gui/components/project/spreadsheet/views/GridView.vue b/packages/nc-gui/components/project/spreadsheet/views/GridView.vue
index 54987b88a5..b6643f65ee 100644
--- a/packages/nc-gui/components/project/spreadsheet/views/GridView.vue
+++ b/packages/nc-gui/components/project/spreadsheet/views/GridView.vue
@@ -571,7 +571,8 @@ export default {
'URL',
'DateTime',
'CreateTime',
- 'LastModifiedTime'
+ 'LastModifiedTime',
+ 'Currency'
].includes(col.uidt)
},
async xcAuditModelCommentsCount() {
diff --git a/packages/nc-gui/helpers/currencyHelper.js b/packages/nc-gui/helpers/currencyHelper.js
new file mode 100644
index 0000000000..b3f24dd028
--- /dev/null
+++ b/packages/nc-gui/helpers/currencyHelper.js
@@ -0,0 +1,82 @@
+import locale from 'locale-codes'
+
+export const currencyCodes = [
+ 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AUD',
+ 'AWG', 'AZN', 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF',
+ 'BMD', 'BND', 'BOB', 'BOV', 'BRL', 'BSD', 'BTN', 'BWP',
+ 'BYR', 'BZD', 'CAD', 'CDF', 'CHE', 'CHF', 'CHW', 'CLF',
+ 'CLP', 'CNY', 'COP', 'COU', 'CRC', 'CUP', 'CVE', 'CYP',
+ 'CZK', 'DJF', 'DKK', 'DOP', 'DZD', 'EEK', 'EGP', 'ERN',
+ 'ETB', 'EUR', 'FJD', 'FKP', 'GBP', 'GEL', 'GHC', 'GIP',
+ 'GMD', 'GNF', 'GTQ', 'GYD', 'HKD', 'HNL', 'HRK', 'HTG',
+ 'HUF', 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK', 'JMD',
+ 'JOD', 'JPY', 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW',
+ 'KWD', 'KYD', 'KZT', 'LAK', 'LBP', 'LKR', 'LRD', 'LSL',
+ 'LTL', 'LVL', 'LYD', 'MAD', 'MDL', 'MGA', 'MKD', 'MMK',
+ 'MNT', 'MOP', 'MRO', 'MTL', 'MUR', 'MVR', 'MWK', 'MXN',
+ 'MXV', 'MYR', 'MZN', 'NAD', 'NGN', 'NIO', 'NOK', 'NPR',
+ 'NZD', 'OMR', 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN',
+ 'PYG', 'QAR', 'ROL', 'RON', 'RSD', 'RUB', 'RWF', 'SAR',
+ 'SBD', 'SCR', 'SDD', 'SEK', 'SGD', 'SHP', 'SIT', 'SKK',
+ 'SLL', 'SOS', 'SRD', 'STD', 'SYP', 'SZL', 'THB', 'TJS',
+ 'TMM', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS', 'UAH',
+ 'UGX', 'USD', 'USN', 'USS', 'UYU', 'UZS', 'VEB', 'VND',
+ 'VUV', 'WST', 'XAF', 'XAG', 'XAU', 'XBA', 'XBB', 'XBC',
+ 'XBD', 'XCD', 'XDR', 'XFO', 'XFU', 'XOF', 'XPD', 'XPF',
+ 'XPT', 'XTS', 'XXX', 'YER', 'ZAR', 'ZMK', 'ZWD'
+]
+
+export function validateCurrencyCode(v) {
+ return currencyCodes.includes(v)
+}
+
+export function currencyLocales() {
+ const localeList = locale.all
+ .filter((l) => {
+ try {
+ if (Intl.NumberFormat.supportedLocalesOf(l.tag).length > 0) {
+ return true
+ }
+ return false
+ } catch (e) {
+ return false
+ }
+ })
+ .map((l) => {
+ return {
+ text: l.name + ' (' + l.tag + ')',
+ value: l.tag
+ }
+ })
+ return localeList
+}
+
+export function validateCurrencyLocale(v) {
+ try {
+ return Intl.NumberFormat.supportedLocalesOf(v).length > 0
+ } catch (e) {
+ return false
+ }
+}
+
+/**
+ * @copyright Copyright (c) 2021, Xgene Cloud Ltd
+ *
+ * @author Mert Ersoy
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
diff --git a/packages/nc-gui/package.json b/packages/nc-gui/package.json
index 057b4ded37..7bd038a7cc 100644
--- a/packages/nc-gui/package.json
+++ b/packages/nc-gui/package.json
@@ -26,6 +26,7 @@
"httpsnippet": "^2.0.0",
"inflection": "^1.12.0",
"jsep": "^1.3.6",
+ "locale-codes": "^1.3.1",
"material-design-icons-iconfont": "^5.0.1",
"monaco-editor": "^0.19.3",
"monaco-themes": "^0.2.5",
diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts
index ad564527d8..425f62535f 100644
--- a/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts
+++ b/packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts
@@ -38,6 +38,7 @@ import {
parseBody
} from '../../../noco/meta/helpers/webhookHelpers';
import Validator from 'validator';
+import { customValidators } from './customValidators';
import { NcError } from '../../../noco/meta/helpers/catchError';
import { customAlphabet } from 'nanoid';
@@ -1833,7 +1834,7 @@ class BaseModelSqlv2 {
if (!validate) continue;
const { func, msg } = validate;
for (let j = 0; j < func.length; ++j) {
- const fn = typeof func[j] === 'string' ? Validator[func[j]] : func[j];
+ const fn = typeof func[j] === 'string' ? (customValidators[func[j]] ? customValidators[func[j]] : Validator[func[j]]) : func[j];
const arg =
typeof func[j] === 'string' ? columns[cn] + '' : columns[cn];
if (
diff --git a/packages/nocodb/src/lib/dataMapper/lib/sql/customValidators.ts b/packages/nocodb/src/lib/dataMapper/lib/sql/customValidators.ts
new file mode 100644
index 0000000000..e77c77b365
--- /dev/null
+++ b/packages/nocodb/src/lib/dataMapper/lib/sql/customValidators.ts
@@ -0,0 +1,5 @@
+import Validator from 'validator';
+
+export const customValidators = {
+ isCurrency: Validator['isFloat']
+}
\ No newline at end of file