@qrvey/utils 1.2.9-21 → 1.2.9-24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +295 -295
- package/dist/cjs/columns/interfaces/IColumn.d.ts +0 -2
- package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
- package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.js +11 -0
- package/dist/cjs/dates/constants/index.d.ts +1 -0
- package/dist/cjs/dates/constants/index.js +1 -0
- package/dist/cjs/filters/adapters/FDToFlatUI.js +1 -1
- package/dist/cjs/filters/adapters/FDToUI.js +1 -2
- package/dist/cjs/filters/adapters/logicToFlatUI.js +3 -3
- package/dist/cjs/filters/helpers/ui/getUpdatedUIFilters.js +1 -1
- package/dist/cjs/filters/interfaces/OLD_IFilterDetail.d.ts +4 -1
- package/dist/cjs/format/definition.d.ts +16 -2
- package/dist/cjs/format/definition.js +3 -1
- package/dist/cjs/format/format.js +1 -1
- package/dist/cjs/format/localization.js +24 -9
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
- package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
- package/dist/cjs/qrvey/helpers/transformValue.js +1 -1
- package/dist/columns/interfaces/IColumn.d.ts +0 -2
- package/dist/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
- package/dist/dates/constants/DATETIME_COLUMN_FORMAT.js +8 -0
- package/dist/dates/constants/index.d.ts +1 -0
- package/dist/dates/constants/index.js +1 -0
- package/dist/filters/adapters/FDToFlatUI.js +1 -1
- package/dist/filters/adapters/FDToUI.js +1 -2
- package/dist/filters/adapters/logicToFlatUI.js +3 -3
- package/dist/filters/helpers/ui/getUpdatedUIFilters.js +1 -1
- package/dist/filters/interfaces/OLD_IFilterDetail.d.ts +4 -1
- package/dist/format/definition.d.ts +16 -2
- package/dist/format/definition.js +2 -0
- package/dist/format/format.js +1 -1
- package/dist/format/localization.js +25 -10
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
- package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
- package/dist/qrvey/helpers/transformValue.js +1 -1
- package/package.json +1 -1
- package/src/columns/interfaces/IColumn.ts +0 -2
- package/src/dates/constants/DATETIME_COLUMN_FORMAT.ts +8 -0
- package/src/dates/constants/index.ts +1 -0
- package/src/filters/adapters/FDToFlatUI.ts +1 -1
- package/src/filters/adapters/FDToUI.ts +1 -1
- package/src/filters/adapters/logicToFlatUI.ts +1 -1
- package/src/filters/helpers/ui/getUpdatedUIFilters.ts +1 -1
- package/src/filters/interfaces/OLD_IFilterDetail.ts +2 -1
- package/src/format/definition.ts +6 -1
- package/src/format/format.ts +1 -1
- package/src/format/localization.ts +24 -10
- package/src/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.ts +1 -0
- package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.ts +1 -0
- package/src/interfaces/format/IFormatOutputFormat.Interface.ts +2 -1
- package/src/qrvey/helpers/transformValue.ts +1 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
|
|
2
|
-
import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
3
2
|
import { IColumnPropertyType } from "./IColumnPropertyType";
|
|
4
3
|
import { IColumnSortingSettings } from "./IColumnSortingSettings";
|
|
5
4
|
import { IBColumn } from "./IBColumn";
|
|
@@ -11,7 +10,6 @@ export interface IColumn extends Omit<IBColumn, "text" | "bucketId" | "formulaId
|
|
|
11
10
|
bucketid?: string;
|
|
12
11
|
aggregate?: IAggregateType;
|
|
13
12
|
calculation?: IColumnCalculationType;
|
|
14
|
-
dataset?: IDataset;
|
|
15
13
|
formulaid?: string;
|
|
16
14
|
label?: string;
|
|
17
15
|
linkid?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DATETIME_COLUMN_FORMAT: string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DATETIME_COLUMN_FORMAT = void 0;
|
|
4
|
+
exports.DATETIME_COLUMN_FORMAT = [
|
|
5
|
+
'MM/DD/YYYY HH24:MM:SS',
|
|
6
|
+
'DD/MM/YYYY HH24:MM:SS',
|
|
7
|
+
'YYYY-MM-DD HH24:MM:SS',
|
|
8
|
+
'MM/DD/YYYY HH24:MI:SS',
|
|
9
|
+
'DD/MM/YYYY HH24:MI:SS',
|
|
10
|
+
'YYYY-MM-DD HH24:MI:SS'
|
|
11
|
+
];
|
|
@@ -44,3 +44,4 @@ __exportStar(require("./DATE_YEAR_MONTHS"), exports);
|
|
|
44
44
|
__exportStar(require("./DATE_YEAR_MONTHS_MMMM"), exports);
|
|
45
45
|
__exportStar(require("./DATE_YEAR_QUARTERS"), exports);
|
|
46
46
|
__exportStar(require("./DATE_YEAR_QUARTERS_RANGE"), exports);
|
|
47
|
+
__exportStar(require("./DATETIME_COLUMN_FORMAT"), exports);
|
|
@@ -44,7 +44,7 @@ function FD21ToFlatUI(scopes = [], datasetsInfo = []) {
|
|
|
44
44
|
const datasetInfo = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
|
|
45
45
|
let columnInfo;
|
|
46
46
|
if (!(0, isEmpty_1.isEmpty)(datasetInfo))
|
|
47
|
-
columnInfo = datasetInfo.options.find(cInfo =>
|
|
47
|
+
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
48
48
|
const info = !(0, isEmpty_1.isEmpty)(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
|
|
49
49
|
const property = (0, adaptDateGroupingProperty_1.adaptDateGroupingProperty)(filter.property);
|
|
50
50
|
const uFilter = {
|
|
@@ -48,7 +48,6 @@ function FD21ToUI(scopes = [], section = FILTER_SECTION_1.FILTER_SECTION.ANYWHER
|
|
|
48
48
|
ufData.scopes = scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(dataset => {
|
|
49
49
|
const datasetInfo = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
|
|
50
50
|
return Object.assign(Object.assign({}, dataset), { label: datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.label, filters: dataset.filters.map(filter => {
|
|
51
|
-
var _a;
|
|
52
51
|
let columnInfo;
|
|
53
52
|
if (!(0, isEmpty_1.isEmpty)(datasetInfo))
|
|
54
53
|
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
@@ -60,7 +59,7 @@ function FD21ToUI(scopes = [], section = FILTER_SECTION_1.FILTER_SECTION.ANYWHER
|
|
|
60
59
|
id: filter.column.id,
|
|
61
60
|
label: columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.label,
|
|
62
61
|
linked: columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.linked,
|
|
63
|
-
linkid: (
|
|
62
|
+
linkid: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.linkid) || (datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.linkid),
|
|
64
63
|
outputFormat: (0, get_1._get)(datasetInfo, 'outputFormat'),
|
|
65
64
|
qrveyid: filter.column.qrveyid,
|
|
66
65
|
type: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.type) || filter.column.type,
|
|
@@ -56,7 +56,7 @@ function buildFilterByExpression(expression, scopeItem, uFilters) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
function getFilterByExpression(expression, scopeItem) {
|
|
59
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t
|
|
59
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
60
60
|
const uiExtras = expression.uiExtras;
|
|
61
61
|
const scopeid = scopeItem.scope !== FILTER_SCOPE_1.FILTER_SCOPE.GLOBAL ? (0, get_1._get)(scopeItem, 'uiExtras.scopeid') : undefined;
|
|
62
62
|
const info = !(0, isEmpty_1.isEmpty)(uiExtras.info) ? { icon: uiExtras.info.icon, label: uiExtras.info.label } : undefined;
|
|
@@ -92,8 +92,8 @@ function getFilterByExpression(expression, scopeItem) {
|
|
|
92
92
|
enabled: true,
|
|
93
93
|
displayed: true,
|
|
94
94
|
qrveyid: (_r = uiExtras.column) === null || _r === void 0 ? void 0 : _r.qrveyid,
|
|
95
|
-
label: (0, get_1._get)(
|
|
96
|
-
linkid: (
|
|
95
|
+
label: (0, get_1._get)(uiExtras.column, 'dataset.name') || ((_s = uiExtras.column) === null || _s === void 0 ? void 0 : _s.label),
|
|
96
|
+
linkid: (_t = uiExtras.column) === null || _t === void 0 ? void 0 : _t.linkid,
|
|
97
97
|
} }),
|
|
98
98
|
filterid: undefined,
|
|
99
99
|
lookupDisplayIndex: uiExtras.lookupDisplayIndex,
|
|
@@ -19,7 +19,7 @@ function getUpdatedUIFilters(data, datasets = []) {
|
|
|
19
19
|
dataset.filters = dataset.filters.map(filter => {
|
|
20
20
|
let columnInfo;
|
|
21
21
|
if (!(0, isEmpty_1.isEmpty)(datasetInfo))
|
|
22
|
-
columnInfo = datasetInfo.options.find(cInfo =>
|
|
22
|
+
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
23
23
|
if (!(0, isEmpty_1.isEmpty)(columnInfo)) {
|
|
24
24
|
filter.column.formulaType = columnInfo.formulaType;
|
|
25
25
|
filter.column.label = columnInfo.label;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
|
+
import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
2
3
|
import { IFSFilterExtrasInfo } from "./common/IFSFilterExtrasInfo";
|
|
3
4
|
import { IFDateSection } from "./IFDateSection";
|
|
4
5
|
import { IFOperator } from "./IFOperator";
|
|
@@ -10,7 +11,9 @@ import { IFValue } from "./IFValue";
|
|
|
10
11
|
import { IFUChartSettings } from "./ui/IFUChartSettings";
|
|
11
12
|
import { IFUValue } from "./ui/IFUValue";
|
|
12
13
|
export interface OLD_IFilterDetail {
|
|
13
|
-
column?: IColumn
|
|
14
|
+
column?: IColumn & {
|
|
15
|
+
dataset: IDataset;
|
|
16
|
+
};
|
|
14
17
|
dateSection?: IFDateSection;
|
|
15
18
|
enabled?: boolean;
|
|
16
19
|
lookupDisplayIndex?: number;
|
|
@@ -19,12 +19,26 @@ export declare const enum LOCALE_FORMATS {
|
|
|
19
19
|
DECIMAL = "Decimal",
|
|
20
20
|
CURRENCY = "Currency",
|
|
21
21
|
PERCENTAGE = "Percentage",
|
|
22
|
-
SCIENTIFIC = "Scientific"
|
|
22
|
+
SCIENTIFIC = "Scientific",
|
|
23
|
+
ABBREVIATED = "Abbreviated"
|
|
23
24
|
}
|
|
24
25
|
export declare const enum LOCALE_STYLES {
|
|
25
26
|
DECIMAL = "decimal",
|
|
26
27
|
PERCENT = "percent",
|
|
27
28
|
CURRENCY = "currency",
|
|
28
|
-
SCIENTIFIC = "scientific"
|
|
29
|
+
SCIENTIFIC = "scientific",
|
|
30
|
+
COMPACT = "compact"
|
|
29
31
|
}
|
|
30
32
|
export declare const LANG_DEFAULT = "en-US";
|
|
33
|
+
export declare const CURRENCY_DEFAULT: {
|
|
34
|
+
text: string;
|
|
35
|
+
label: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const DATETIME_OPTIONS: {
|
|
38
|
+
year: string;
|
|
39
|
+
month: string;
|
|
40
|
+
day: string;
|
|
41
|
+
hour: string;
|
|
42
|
+
minute: string;
|
|
43
|
+
second: string;
|
|
44
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LANG_DEFAULT = exports.currencyISO = exports.isTextColumn = exports.supportNumericFormatting = exports.isNumericalColumn = exports.isComplexColumn = exports.hasfileSizeProperty = exports.appliesFormatting = exports.DATEGROUP_FORMATTING_UNSUPPORT = exports.QUESTION_FORMAT_SUPPORT = exports.numericalFields = exports.complexFields = exports.textFields = void 0;
|
|
3
|
+
exports.DATETIME_OPTIONS = exports.CURRENCY_DEFAULT = exports.LANG_DEFAULT = exports.currencyISO = exports.isTextColumn = exports.supportNumericFormatting = exports.isNumericalColumn = exports.isComplexColumn = exports.hasfileSizeProperty = exports.appliesFormatting = exports.DATEGROUP_FORMATTING_UNSUPPORT = exports.QUESTION_FORMAT_SUPPORT = exports.numericalFields = exports.complexFields = exports.textFields = void 0;
|
|
4
4
|
const COLUMN_1 = require("../columns/constants/COLUMN");
|
|
5
5
|
const Charts_Const_1 = require("../constants/Charts.Const");
|
|
6
6
|
exports.textFields = [COLUMN_1.COLUMN.TEXTFIELD, COLUMN_1.COLUMN.TEXT_CATEGORY, COLUMN_1.COLUMN.TEXT_LABEL, COLUMN_1.COLUMN.TEXT_CATEGORY];
|
|
@@ -82,3 +82,5 @@ exports.currencyISO = [
|
|
|
82
82
|
{ text: 'RM (MYR)', label: 'MYR' }
|
|
83
83
|
];
|
|
84
84
|
exports.LANG_DEFAULT = 'en-US';
|
|
85
|
+
exports.CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
|
|
86
|
+
exports.DATETIME_OPTIONS = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
|
@@ -93,7 +93,7 @@ const addFormat = (value, outputFormat = 'None', config) => {
|
|
|
93
93
|
return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? (0, localization_1.formatWithLocale)(value, outputFormat, config) : formatDate(value, outputFormat.format);
|
|
94
94
|
case 'NUMERIC': {
|
|
95
95
|
const parse = parseFloat(value);
|
|
96
|
-
const withLocale = outputFormat
|
|
96
|
+
const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
|
|
97
97
|
return isNaN(parse) ? value : withLocale ? (0, localization_1.formatWithLocale)(value, outputFormat, config)
|
|
98
98
|
: formatNumber(parse, outputFormat, config);
|
|
99
99
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.formatWithLocale = exports.chooseLang = exports.getLang = void 0;
|
|
4
|
+
const __1 = require("..");
|
|
5
|
+
const isEmpty_1 = require("../general/mix/isEmpty");
|
|
4
6
|
const definition_1 = require("./definition");
|
|
5
7
|
const getLang = (locale) => {
|
|
6
8
|
if (!locale)
|
|
@@ -22,20 +24,26 @@ const formatWithLocale = (value, outputFormat, config = {}) => {
|
|
|
22
24
|
switch (outputFormat.type) {
|
|
23
25
|
case 'DATE':
|
|
24
26
|
case 'DATETIME':
|
|
25
|
-
return formatLocaleDate(value, config);
|
|
27
|
+
return formatLocaleDate(value, outputFormat, config);
|
|
26
28
|
case 'NUMERIC':
|
|
27
29
|
return formatLocaleNumber(value, outputFormat, config);
|
|
28
30
|
}
|
|
29
31
|
};
|
|
30
32
|
exports.formatWithLocale = formatWithLocale;
|
|
31
|
-
function formatLocaleDate(value, config) {
|
|
33
|
+
function formatLocaleDate(value, outputFormat, config) {
|
|
32
34
|
const { lang = definition_1.LANG_DEFAULT, options } = config;
|
|
33
35
|
const dateParam = new Date(value);
|
|
36
|
+
let langOpts = options;
|
|
37
|
+
if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
|
|
38
|
+
const { format } = outputFormat.originalFormat;
|
|
39
|
+
if (__1.DATETIME_COLUMN_FORMAT.includes(format))
|
|
40
|
+
langOpts = definition_1.DATETIME_OPTIONS;
|
|
41
|
+
}
|
|
34
42
|
try {
|
|
35
|
-
return new Intl.DateTimeFormat([lang, definition_1.LANG_DEFAULT],
|
|
43
|
+
return new Intl.DateTimeFormat([lang, definition_1.LANG_DEFAULT], langOpts).format(dateParam);
|
|
36
44
|
}
|
|
37
45
|
catch (error) {
|
|
38
|
-
return new Intl.DateTimeFormat(definition_1.LANG_DEFAULT,
|
|
46
|
+
return new Intl.DateTimeFormat(definition_1.LANG_DEFAULT, langOpts).format(dateParam);
|
|
39
47
|
}
|
|
40
48
|
}
|
|
41
49
|
function formatLocaleNumber(value, outputFormat, config) {
|
|
@@ -52,12 +60,19 @@ function getLocaleOptions(outputFormat) {
|
|
|
52
60
|
const { format, decimals, currency } = outputFormat;
|
|
53
61
|
switch (format) {
|
|
54
62
|
case "Currency" /* CURRENCY */: {
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
let iso = (0, isEmpty_1.isEmpty)(currency) ? definition_1.CURRENCY_DEFAULT : definition_1.currencyISO.find(item => item.text === currency.text);
|
|
64
|
+
if ((0, isEmpty_1.isEmpty)(iso)) {
|
|
65
|
+
iso = definition_1.currencyISO.find(item => {
|
|
66
|
+
const symbol = item.text.split(' ')[0];
|
|
67
|
+
return symbol === currency.label;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: decimals, currencyDisplay: 'narrowSymbol' };
|
|
57
71
|
}
|
|
58
72
|
case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
|
|
59
|
-
notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
|
|
60
|
-
case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
|
|
61
|
-
|
|
73
|
+
notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
|
|
74
|
+
case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
|
|
75
|
+
case "Abbreviated" /* ABBREVIATED */: return { notation: "compact" /* COMPACT */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
|
|
76
|
+
default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
|
|
62
77
|
}
|
|
63
78
|
}
|
|
@@ -43,5 +43,5 @@ function getOutputFormat(settings) {
|
|
|
43
43
|
*/
|
|
44
44
|
function getFormatConfig(settings) {
|
|
45
45
|
var _a;
|
|
46
|
-
return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.
|
|
46
|
+
return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.locale };
|
|
47
47
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
|
|
2
|
-
import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
3
2
|
import { IColumnPropertyType } from "./IColumnPropertyType";
|
|
4
3
|
import { IColumnSortingSettings } from "./IColumnSortingSettings";
|
|
5
4
|
import { IBColumn } from "./IBColumn";
|
|
@@ -11,7 +10,6 @@ export interface IColumn extends Omit<IBColumn, "text" | "bucketId" | "formulaId
|
|
|
11
10
|
bucketid?: string;
|
|
12
11
|
aggregate?: IAggregateType;
|
|
13
12
|
calculation?: IColumnCalculationType;
|
|
14
|
-
dataset?: IDataset;
|
|
15
13
|
formulaid?: string;
|
|
16
14
|
label?: string;
|
|
17
15
|
linkid?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DATETIME_COLUMN_FORMAT: string[];
|
|
@@ -40,7 +40,7 @@ function FD21ToFlatUI(scopes = [], datasetsInfo = []) {
|
|
|
40
40
|
const datasetInfo = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
|
|
41
41
|
let columnInfo;
|
|
42
42
|
if (!isEmpty(datasetInfo))
|
|
43
|
-
columnInfo = datasetInfo.options.find(cInfo =>
|
|
43
|
+
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
44
44
|
const info = !isEmpty(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
|
|
45
45
|
const property = adaptDateGroupingProperty(filter.property);
|
|
46
46
|
const uFilter = {
|
|
@@ -44,7 +44,6 @@ function FD21ToUI(scopes = [], section = FILTER_SECTION.ANYWHERE, enabled = true
|
|
|
44
44
|
ufData.scopes = scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(dataset => {
|
|
45
45
|
const datasetInfo = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
|
|
46
46
|
return Object.assign(Object.assign({}, dataset), { label: datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.label, filters: dataset.filters.map(filter => {
|
|
47
|
-
var _a;
|
|
48
47
|
let columnInfo;
|
|
49
48
|
if (!isEmpty(datasetInfo))
|
|
50
49
|
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
@@ -56,7 +55,7 @@ function FD21ToUI(scopes = [], section = FILTER_SECTION.ANYWHERE, enabled = true
|
|
|
56
55
|
id: filter.column.id,
|
|
57
56
|
label: columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.label,
|
|
58
57
|
linked: columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.linked,
|
|
59
|
-
linkid: (
|
|
58
|
+
linkid: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.linkid) || (datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.linkid),
|
|
60
59
|
outputFormat: _get(datasetInfo, 'outputFormat'),
|
|
61
60
|
qrveyid: filter.column.qrveyid,
|
|
62
61
|
type: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.type) || filter.column.type,
|
|
@@ -52,7 +52,7 @@ function buildFilterByExpression(expression, scopeItem, uFilters) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
function getFilterByExpression(expression, scopeItem) {
|
|
55
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t
|
|
55
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
56
56
|
const uiExtras = expression.uiExtras;
|
|
57
57
|
const scopeid = scopeItem.scope !== FILTER_SCOPE.GLOBAL ? _get(scopeItem, 'uiExtras.scopeid') : undefined;
|
|
58
58
|
const info = !isEmpty(uiExtras.info) ? { icon: uiExtras.info.icon, label: uiExtras.info.label } : undefined;
|
|
@@ -88,8 +88,8 @@ function getFilterByExpression(expression, scopeItem) {
|
|
|
88
88
|
enabled: true,
|
|
89
89
|
displayed: true,
|
|
90
90
|
qrveyid: (_r = uiExtras.column) === null || _r === void 0 ? void 0 : _r.qrveyid,
|
|
91
|
-
label: _get(
|
|
92
|
-
linkid: (
|
|
91
|
+
label: _get(uiExtras.column, 'dataset.name') || ((_s = uiExtras.column) === null || _s === void 0 ? void 0 : _s.label),
|
|
92
|
+
linkid: (_t = uiExtras.column) === null || _t === void 0 ? void 0 : _t.linkid,
|
|
93
93
|
} }),
|
|
94
94
|
filterid: undefined,
|
|
95
95
|
lookupDisplayIndex: uiExtras.lookupDisplayIndex,
|
|
@@ -16,7 +16,7 @@ export function getUpdatedUIFilters(data, datasets = []) {
|
|
|
16
16
|
dataset.filters = dataset.filters.map(filter => {
|
|
17
17
|
let columnInfo;
|
|
18
18
|
if (!isEmpty(datasetInfo))
|
|
19
|
-
columnInfo = datasetInfo.options.find(cInfo =>
|
|
19
|
+
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
20
20
|
if (!isEmpty(columnInfo)) {
|
|
21
21
|
filter.column.formulaType = columnInfo.formulaType;
|
|
22
22
|
filter.column.label = columnInfo.label;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
|
+
import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
2
3
|
import { IFSFilterExtrasInfo } from "./common/IFSFilterExtrasInfo";
|
|
3
4
|
import { IFDateSection } from "./IFDateSection";
|
|
4
5
|
import { IFOperator } from "./IFOperator";
|
|
@@ -10,7 +11,9 @@ import { IFValue } from "./IFValue";
|
|
|
10
11
|
import { IFUChartSettings } from "./ui/IFUChartSettings";
|
|
11
12
|
import { IFUValue } from "./ui/IFUValue";
|
|
12
13
|
export interface OLD_IFilterDetail {
|
|
13
|
-
column?: IColumn
|
|
14
|
+
column?: IColumn & {
|
|
15
|
+
dataset: IDataset;
|
|
16
|
+
};
|
|
14
17
|
dateSection?: IFDateSection;
|
|
15
18
|
enabled?: boolean;
|
|
16
19
|
lookupDisplayIndex?: number;
|
|
@@ -19,12 +19,26 @@ export declare const enum LOCALE_FORMATS {
|
|
|
19
19
|
DECIMAL = "Decimal",
|
|
20
20
|
CURRENCY = "Currency",
|
|
21
21
|
PERCENTAGE = "Percentage",
|
|
22
|
-
SCIENTIFIC = "Scientific"
|
|
22
|
+
SCIENTIFIC = "Scientific",
|
|
23
|
+
ABBREVIATED = "Abbreviated"
|
|
23
24
|
}
|
|
24
25
|
export declare const enum LOCALE_STYLES {
|
|
25
26
|
DECIMAL = "decimal",
|
|
26
27
|
PERCENT = "percent",
|
|
27
28
|
CURRENCY = "currency",
|
|
28
|
-
SCIENTIFIC = "scientific"
|
|
29
|
+
SCIENTIFIC = "scientific",
|
|
30
|
+
COMPACT = "compact"
|
|
29
31
|
}
|
|
30
32
|
export declare const LANG_DEFAULT = "en-US";
|
|
33
|
+
export declare const CURRENCY_DEFAULT: {
|
|
34
|
+
text: string;
|
|
35
|
+
label: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const DATETIME_OPTIONS: {
|
|
38
|
+
year: string;
|
|
39
|
+
month: string;
|
|
40
|
+
day: string;
|
|
41
|
+
hour: string;
|
|
42
|
+
minute: string;
|
|
43
|
+
second: string;
|
|
44
|
+
};
|
|
@@ -73,3 +73,5 @@ export const currencyISO = [
|
|
|
73
73
|
{ text: 'RM (MYR)', label: 'MYR' }
|
|
74
74
|
];
|
|
75
75
|
export const LANG_DEFAULT = 'en-US';
|
|
76
|
+
export const CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
|
|
77
|
+
export const DATETIME_OPTIONS = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
|
package/dist/format/format.js
CHANGED
|
@@ -84,7 +84,7 @@ export const addFormat = (value, outputFormat = 'None', config) => {
|
|
|
84
84
|
return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat.format);
|
|
85
85
|
case 'NUMERIC': {
|
|
86
86
|
const parse = parseFloat(value);
|
|
87
|
-
const withLocale = outputFormat
|
|
87
|
+
const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
|
|
88
88
|
return isNaN(parse) ? value : withLocale ? formatWithLocale(value, outputFormat, config)
|
|
89
89
|
: formatNumber(parse, outputFormat, config);
|
|
90
90
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DATETIME_COLUMN_FORMAT } from '..';
|
|
2
|
+
import { isEmpty } from '../general/mix/isEmpty';
|
|
3
|
+
import { currencyISO, LANG_DEFAULT, CURRENCY_DEFAULT, DATETIME_OPTIONS } from './definition';
|
|
2
4
|
export const getLang = (locale) => {
|
|
3
5
|
if (!locale)
|
|
4
6
|
return;
|
|
@@ -17,19 +19,25 @@ export const formatWithLocale = (value, outputFormat, config = {}) => {
|
|
|
17
19
|
switch (outputFormat.type) {
|
|
18
20
|
case 'DATE':
|
|
19
21
|
case 'DATETIME':
|
|
20
|
-
return formatLocaleDate(value, config);
|
|
22
|
+
return formatLocaleDate(value, outputFormat, config);
|
|
21
23
|
case 'NUMERIC':
|
|
22
24
|
return formatLocaleNumber(value, outputFormat, config);
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
|
-
function formatLocaleDate(value, config) {
|
|
27
|
+
function formatLocaleDate(value, outputFormat, config) {
|
|
26
28
|
const { lang = LANG_DEFAULT, options } = config;
|
|
27
29
|
const dateParam = new Date(value);
|
|
30
|
+
let langOpts = options;
|
|
31
|
+
if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
|
|
32
|
+
const { format } = outputFormat.originalFormat;
|
|
33
|
+
if (DATETIME_COLUMN_FORMAT.includes(format))
|
|
34
|
+
langOpts = DATETIME_OPTIONS;
|
|
35
|
+
}
|
|
28
36
|
try {
|
|
29
|
-
return new Intl.DateTimeFormat([lang, LANG_DEFAULT],
|
|
37
|
+
return new Intl.DateTimeFormat([lang, LANG_DEFAULT], langOpts).format(dateParam);
|
|
30
38
|
}
|
|
31
39
|
catch (error) {
|
|
32
|
-
return new Intl.DateTimeFormat(LANG_DEFAULT,
|
|
40
|
+
return new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
43
|
function formatLocaleNumber(value, outputFormat, config) {
|
|
@@ -46,12 +54,19 @@ function getLocaleOptions(outputFormat) {
|
|
|
46
54
|
const { format, decimals, currency } = outputFormat;
|
|
47
55
|
switch (format) {
|
|
48
56
|
case "Currency" /* CURRENCY */: {
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
let iso = isEmpty(currency) ? CURRENCY_DEFAULT : currencyISO.find(item => item.text === currency.text);
|
|
58
|
+
if (isEmpty(iso)) {
|
|
59
|
+
iso = currencyISO.find(item => {
|
|
60
|
+
const symbol = item.text.split(' ')[0];
|
|
61
|
+
return symbol === currency.label;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: decimals, currencyDisplay: 'narrowSymbol' };
|
|
51
65
|
}
|
|
52
66
|
case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
|
|
53
|
-
notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
|
|
54
|
-
case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
|
|
55
|
-
|
|
67
|
+
notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
|
|
68
|
+
case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
|
|
69
|
+
case "Abbreviated" /* ABBREVIATED */: return { notation: "compact" /* COMPACT */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
|
|
70
|
+
default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
|
|
56
71
|
}
|
|
57
72
|
}
|
|
@@ -39,5 +39,5 @@ function getOutputFormat(settings) {
|
|
|
39
39
|
*/
|
|
40
40
|
function getFormatConfig(settings) {
|
|
41
41
|
var _a;
|
|
42
|
-
return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.
|
|
42
|
+
return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.locale };
|
|
43
43
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
|
|
2
|
-
import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
3
2
|
import { IColumnPropertyType } from "./IColumnPropertyType";
|
|
4
3
|
import { IColumnSortingSettings } from "./IColumnSortingSettings";
|
|
5
4
|
import { IBColumn } from "./IBColumn";
|
|
@@ -12,7 +11,6 @@ export interface IColumn extends Omit<IBColumn, "text" | "bucketId" | "formulaId
|
|
|
12
11
|
bucketid?: string;
|
|
13
12
|
aggregate?: IAggregateType;
|
|
14
13
|
calculation?: IColumnCalculationType;
|
|
15
|
-
dataset?: IDataset;
|
|
16
14
|
formulaid?: string;
|
|
17
15
|
label?: string;
|
|
18
16
|
linkid?: string;
|
|
@@ -47,7 +47,7 @@ function FD21ToFlatUI(scopes: IFSScope[] = [], datasetsInfo: IDataset[] = []): I
|
|
|
47
47
|
dataset.filters.forEach(filter => {
|
|
48
48
|
const datasetInfo: IDataset = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
|
|
49
49
|
let columnInfo: IColumn;
|
|
50
|
-
if (!isEmpty(datasetInfo)) columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.
|
|
50
|
+
if (!isEmpty(datasetInfo)) columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
51
51
|
const info = !isEmpty(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
|
|
52
52
|
const property = adaptDateGroupingProperty(filter.property);
|
|
53
53
|
|
|
@@ -71,7 +71,7 @@ export function FDToUI(filterData: IFSData, datasetsInfo: IDataset[] = []): IFUD
|
|
|
71
71
|
id: filter.column.id,
|
|
72
72
|
label: columnInfo?.label,
|
|
73
73
|
linked: columnInfo?.linked,
|
|
74
|
-
linkid: columnInfo?.
|
|
74
|
+
linkid: columnInfo?.linkid || datasetInfo?.linkid,
|
|
75
75
|
outputFormat: _get(datasetInfo, 'outputFormat'),
|
|
76
76
|
qrveyid: filter.column.qrveyid,
|
|
77
77
|
type: columnInfo?.type || filter.column.type,
|
|
@@ -103,7 +103,7 @@ function getFilterByExpression(expression: OLD_IFilterExpression, scopeItem: OLD
|
|
|
103
103
|
enabled: true,
|
|
104
104
|
displayed: true,
|
|
105
105
|
qrveyid: uiExtras.column?.qrveyid,
|
|
106
|
-
label: _get(
|
|
106
|
+
label: _get(uiExtras.column, 'dataset.name') || uiExtras.column?.label,
|
|
107
107
|
linkid: uiExtras.column?.linkid,
|
|
108
108
|
},
|
|
109
109
|
},
|