@qrvey/utils 1.2.10-5 → 1.2.10-8
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 +1 -1
- package/bitbucket-pipelines.yml +1 -1
- package/dist/cjs/filters/adapters/adaptFilterValues.js +1 -1
- package/dist/cjs/filters/adapters/flatUIToFD.js +4 -0
- package/dist/cjs/filters/adapters/flatUIToOldLogic.js +1 -1
- package/dist/cjs/filters/adapters/flatUIToUI.js +4 -0
- package/dist/cjs/filters/helpers/OLD_getAggFilters.d.ts +1 -1
- package/dist/cjs/filters/helpers/OLD_getAggFilters.js +1 -1
- package/dist/cjs/filters/helpers/backend/getBackendProperty.js +1 -1
- package/dist/cjs/filters/helpers/backend/getBackendValues.js +1 -1
- package/dist/cjs/filters/helpers/common/getMergeValuesSettings.d.ts +7 -0
- package/dist/cjs/filters/helpers/common/getMergeValuesSettings.js +15 -0
- package/dist/cjs/filters/helpers/common/index.d.ts +1 -0
- package/dist/cjs/filters/helpers/common/index.js +1 -0
- package/dist/cjs/filters/helpers/common/mergeFilters.js +4 -58
- package/dist/cjs/filters/helpers/common/mergeValues.d.ts +11 -0
- package/dist/cjs/filters/helpers/common/mergeValues.js +92 -0
- package/dist/cjs/filters/interfaces/common/IFSValue.d.ts +1 -1
- package/dist/cjs/filters/interfaces/functions/IFFiltersMergeFilters.d.ts +2 -2
- package/dist/cjs/filters/interfaces/functions/IFFiltersMergeValues.d.ts +3 -0
- package/dist/cjs/filters/interfaces/functions/IFFiltersMergeValues.js +2 -0
- package/dist/cjs/filters/interfaces/functions/index.d.ts +1 -0
- package/dist/cjs/filters/interfaces/functions/index.js +1 -0
- package/dist/cjs/filters/interfaces/ui/IFUValue.d.ts +1 -1
- package/dist/cjs/filters/services/UChartPaginationApi.d.ts +2 -2
- package/dist/cjs/filters/services/UChartPaginationApi.js +2 -2
- package/dist/cjs/format/format.js +4 -2
- package/dist/cjs/format/localization.js +17 -3
- package/dist/cjs/globalization/interfaces/dashboard/II18nDashboardToast.d.ts +1 -0
- package/dist/cjs/globalization/labels/dashboard/I18N_DASHBOARD.js +1 -0
- package/dist/cjs/qrvey/helpers/transformValue.js +3 -0
- package/dist/cjs/services/adapters/BBranchesMapToUIBranchesMap.adapter.d.ts +3 -3
- package/dist/cjs/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
- package/dist/filters/adapters/adaptFilterValues.js +1 -1
- package/dist/filters/adapters/flatUIToFD.js +4 -0
- package/dist/filters/adapters/flatUIToOldLogic.js +1 -1
- package/dist/filters/adapters/flatUIToUI.js +4 -0
- package/dist/filters/helpers/OLD_getAggFilters.d.ts +1 -1
- package/dist/filters/helpers/OLD_getAggFilters.js +1 -1
- package/dist/filters/helpers/backend/getBackendProperty.js +1 -1
- package/dist/filters/helpers/backend/getBackendValues.js +1 -1
- package/dist/filters/helpers/common/getMergeValuesSettings.d.ts +7 -0
- package/dist/filters/helpers/common/getMergeValuesSettings.js +11 -0
- package/dist/filters/helpers/common/index.d.ts +1 -0
- package/dist/filters/helpers/common/index.js +1 -0
- package/dist/filters/helpers/common/mergeFilters.js +3 -57
- package/dist/filters/helpers/common/mergeValues.d.ts +11 -0
- package/dist/filters/helpers/common/mergeValues.js +88 -0
- package/dist/filters/interfaces/common/IFSValue.d.ts +1 -1
- package/dist/filters/interfaces/functions/IFFiltersMergeFilters.d.ts +2 -2
- package/dist/filters/interfaces/functions/IFFiltersMergeValues.d.ts +3 -0
- package/dist/filters/interfaces/functions/IFFiltersMergeValues.js +1 -0
- package/dist/filters/interfaces/functions/index.d.ts +1 -0
- package/dist/filters/interfaces/functions/index.js +1 -0
- package/dist/filters/interfaces/ui/IFUValue.d.ts +1 -1
- package/dist/filters/services/UChartPaginationApi.d.ts +2 -2
- package/dist/filters/services/UChartPaginationApi.js +2 -2
- package/dist/format/format.js +4 -2
- package/dist/format/localization.js +17 -3
- package/dist/globalization/interfaces/dashboard/II18nDashboardToast.d.ts +1 -0
- package/dist/globalization/labels/dashboard/I18N_DASHBOARD.js +1 -0
- package/dist/qrvey/helpers/transformValue.js +3 -0
- package/dist/services/adapters/BBranchesMapToUIBranchesMap.adapter.d.ts +3 -3
- package/dist/services/adapters/BBranchesMapToUIBranchesMap.adapter.js +3 -3
- package/package.json +10 -8
- package/publishing.js +15 -2
- package/src/filters/adapters/adaptFilterValues.ts +1 -1
- package/src/filters/adapters/flatUIToFD.ts +5 -0
- package/src/filters/adapters/flatUIToOldLogic.ts +1 -1
- package/src/filters/adapters/flatUIToUI.ts +5 -0
- package/src/filters/helpers/OLD_getAggFilters.ts +1 -1
- package/src/filters/helpers/backend/getBackendProperty.ts +2 -1
- package/src/filters/helpers/backend/getBackendValues.ts +1 -1
- package/src/filters/helpers/common/getMergeValuesSettings.ts +12 -0
- package/src/filters/helpers/common/index.ts +1 -0
- package/src/filters/helpers/common/mergeFilters.ts +5 -59
- package/src/filters/helpers/common/mergeValues.ts +87 -0
- package/src/filters/interfaces/common/IFSValue.ts +1 -1
- package/src/filters/interfaces/functions/IFFiltersMergeFilters.ts +2 -2
- package/src/filters/interfaces/functions/IFFiltersMergeValues.ts +3 -0
- package/src/filters/interfaces/functions/index.ts +1 -0
- package/src/filters/interfaces/ui/IFUValue.ts +1 -1
- package/src/filters/services/UChartPaginationApi.ts +2 -4
- package/src/format/format.ts +3 -2
- package/src/format/localization.ts +17 -3
- package/src/globalization/interfaces/dashboard/II18nDashboardToast.ts +1 -0
- package/src/globalization/labels/dashboard/I18N_DASHBOARD.ts +1 -0
- package/src/qrvey/helpers/transformValue.ts +3 -0
- package/src/services/adapters/BBranchesMapToUIBranchesMap.adapter.ts +3 -3
|
@@ -3,6 +3,7 @@ import { COLUMN_PROPERTY } from "../../../columns/constants/COLUMN_PROPERTY";
|
|
|
3
3
|
import { isDateColumn } from "../../../columns/helpers/isDateColumn";
|
|
4
4
|
import { isEmpty } from "../../../general/mix/isEmpty";
|
|
5
5
|
import { IFSFilter } from "../../interfaces/common/IFSFilter";
|
|
6
|
+
import { IFSValue } from "../../interfaces/common/IFSValue";
|
|
6
7
|
import { IFProperty } from "../../interfaces/IFProperty";
|
|
7
8
|
import { isNullValidator } from "../common/isNullValidator";
|
|
8
9
|
|
|
@@ -20,7 +21,7 @@ export function getBackendProperty(filter: IFSFilter): IFProperty {
|
|
|
20
21
|
} else if (filter.column.type === COLUMN.LOOKUP && filter.property === COLUMN_PROPERTY.LOOKUP_DISPLAY && filter.lookupDisplayIndex != null) {
|
|
21
22
|
return filter.property.concat('_').concat(filter.lookupDisplayIndex.toString()) as any;
|
|
22
23
|
} else if (filter.column.type === COLUMN.IMAGE) {
|
|
23
|
-
return COLUMN_PROPERTY.IMAGE_ANSWER_ID;
|
|
24
|
+
return (filter.values as IFSValue[]).every(value => isEmpty(value.valueid)) ? undefined : COLUMN_PROPERTY.IMAGE_ANSWER_ID;
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
return filter.property;
|
|
@@ -84,7 +84,7 @@ function getResultValues(values: IFSValue[], filter: IFSFilter): IFBExpressionVa
|
|
|
84
84
|
return (values || []).map((value: IFSValue) => {
|
|
85
85
|
if (value.enabled) {
|
|
86
86
|
if (filter.column.type === COLUMN.IMAGE) {
|
|
87
|
-
return value.valueid;
|
|
87
|
+
return value.valueid || value.imageUrl || value.value;
|
|
88
88
|
} else {
|
|
89
89
|
return value.value;
|
|
90
90
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IFFiltersMergeValues } from "../../interfaces/functions/IFFiltersMergeValues";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Transforms the given MergeFilters settings object. Adds the missing properties if they do not exist.
|
|
5
|
+
* @param settings an object to the MergeFilters settings
|
|
6
|
+
* @returns a new MergeFilters settings object.
|
|
7
|
+
*/
|
|
8
|
+
export function getMergeValuesSettings(settings?: IFFiltersMergeValues): IFFiltersMergeValues {
|
|
9
|
+
return {
|
|
10
|
+
overwriteValues: settings?.overwriteValues ?? false,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -24,6 +24,7 @@ export * from './isNullValidator';
|
|
|
24
24
|
export * from './isRangeValidator';
|
|
25
25
|
export * from './isRegularValidator';
|
|
26
26
|
export * from './mergeFilters';
|
|
27
|
+
export * from './mergeValues';
|
|
27
28
|
export * from './resolveDatasetConditions';
|
|
28
29
|
export * from './resolveFilterConditions';
|
|
29
30
|
export * from './resolveScopeConditions';
|
|
@@ -5,18 +5,11 @@ import { IFSData } from "../../interfaces/common/IFSData";
|
|
|
5
5
|
import { IFSDataset } from "../../interfaces/common/IFSDataset";
|
|
6
6
|
import { IFSFilter } from "../../interfaces/common/IFSFilter";
|
|
7
7
|
import { IFSScope } from "../../interfaces/common/IFSScope";
|
|
8
|
-
import { IFSValue } from "../../interfaces/common/IFSValue";
|
|
9
|
-
import { IFSValueRange } from "../../interfaces/common/IFSValueRange";
|
|
10
|
-
import { IFSValueRelativeDate } from "../../interfaces/common/IFSValueRelativeDate";
|
|
11
8
|
import { IFFiltersMergeFilters } from "../../interfaces/functions/IFFiltersMergeFilters";
|
|
12
|
-
import { IFValue } from "../../interfaces/IFValue";
|
|
13
9
|
import { IFUData } from "../../interfaces/ui/IFUData";
|
|
14
10
|
import { getFilterid } from "./getFilterid";
|
|
15
11
|
import { getMergeFiltersSettings } from "./getMergeFiltersSettings";
|
|
16
|
-
import {
|
|
17
|
-
import { isNullValidator } from "./isNullValidator";
|
|
18
|
-
import { isRangeValidator } from "./isRangeValidator";
|
|
19
|
-
import { isRegularValidator } from "./isRegularValidator";
|
|
12
|
+
import { mergeValues } from "./mergeValues";
|
|
20
13
|
import { resolveDatasetConditions } from "./resolveDatasetConditions";
|
|
21
14
|
import { resolveFilterConditions } from "./resolveFilterConditions";
|
|
22
15
|
import { resolveScopeConditions } from "./resolveScopeConditions";
|
|
@@ -134,8 +127,11 @@ function mergeFilterProps(filter1: IFSFilter, filter2: IFSFilter, settings?: IFF
|
|
|
134
127
|
if (settings.overwriteFilterProps) {
|
|
135
128
|
filter1 = {
|
|
136
129
|
...filter1,
|
|
130
|
+
collapsed: filter2.collapsed ?? filter1.collapsed,
|
|
131
|
+
displayed: filter2.displayed ?? filter1.displayed,
|
|
132
|
+
dateSection: filter2.dateSection,
|
|
137
133
|
extras: filter2.extras,
|
|
138
|
-
enabled: filter2.enabled
|
|
134
|
+
enabled: filter2.enabled ?? filter1.enabled,
|
|
139
135
|
filterid: filter2.filterid,
|
|
140
136
|
lookupDisplayIndex: filter2.lookupDisplayIndex,
|
|
141
137
|
nullValues: filter2.nullValues,
|
|
@@ -144,53 +140,3 @@ function mergeFilterProps(filter1: IFSFilter, filter2: IFSFilter, settings?: IFF
|
|
|
144
140
|
}
|
|
145
141
|
return filter1;
|
|
146
142
|
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Gets a new value structure array by merging two value structures
|
|
150
|
-
* @param filter1 the target filter structure
|
|
151
|
-
* @param filter2 the filter to be used to merge the values
|
|
152
|
-
* @param settings configuration of the mergeFilter
|
|
153
|
-
* @returns a new value structure array
|
|
154
|
-
*/
|
|
155
|
-
function mergeValues(filter1: IFSFilter, filter2: IFSFilter, settings?: IFFiltersMergeFilters): IFValue[] {
|
|
156
|
-
if (isEmpty(filter1) && isEmpty(filter2)) return [];
|
|
157
|
-
|
|
158
|
-
let newValues = [];
|
|
159
|
-
let filter1Values = filter1.values || [];
|
|
160
|
-
const filter2Values = filter2.values || [];
|
|
161
|
-
if (!settings.overwriteValues) {
|
|
162
|
-
if (isInValidator(filter1.validator)) {
|
|
163
|
-
newValues = filter2Values.reduce((values: IFValue[], value2: IFSValueRelativeDate) => {
|
|
164
|
-
const value1Index = (filter1Values as IFSValueRelativeDate[]).findIndex(value1 => value2.anchor === value1.anchor && value2.cursor === value1.cursor && value2.includeCurrent === value1.includeCurrent && value2.isCalendarDate === value1.isCalendarDate && value2.number === value1.number && value2.unit === value1.unit);
|
|
165
|
-
if (value1Index === -1) {
|
|
166
|
-
values.push(value2);
|
|
167
|
-
}
|
|
168
|
-
return values;
|
|
169
|
-
}, filter1Values as IFValue[]);
|
|
170
|
-
} else if (isRangeValidator(filter1.validator)) {
|
|
171
|
-
newValues = filter2Values.reduce((values: IFValue[], value2: IFSValueRange) => {
|
|
172
|
-
const value1Index = (filter1Values as IFSValueRange[]).findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
|
|
173
|
-
if (value1Index === -1) {
|
|
174
|
-
values.push(value2);
|
|
175
|
-
}
|
|
176
|
-
return values;
|
|
177
|
-
}, filter1Values as IFValue[]);
|
|
178
|
-
} else if (isRegularValidator(filter1.validator) || isNullValidator(filter1.validator)) {
|
|
179
|
-
newValues = filter2Values.reduce((values: IFValue[], value2: IFSValue) => {
|
|
180
|
-
const value1Index = (filter1Values as IFSValue[]).findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
|
|
181
|
-
if (value1Index === -1) {
|
|
182
|
-
values.push(value2);
|
|
183
|
-
}
|
|
184
|
-
return values;
|
|
185
|
-
}, filter1Values as IFValue[]);
|
|
186
|
-
} else {
|
|
187
|
-
filter1Values = filter1Values.concat(filter2Values);
|
|
188
|
-
newValues = filter1Values;
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
filter1Values = filter2Values;
|
|
192
|
-
newValues = filter1Values;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return newValues;
|
|
196
|
-
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { isEmpty } from "../../../general/mix/isEmpty";
|
|
2
|
+
import { IFSFilter } from "../../interfaces/common/IFSFilter";
|
|
3
|
+
import { IFSValue } from "../../interfaces/common/IFSValue";
|
|
4
|
+
import { IFSValueRange } from "../../interfaces/common/IFSValueRange";
|
|
5
|
+
import { IFSValueRelativeDate } from "../../interfaces/common/IFSValueRelativeDate";
|
|
6
|
+
import { IFFiltersMergeValues } from "../../interfaces/functions/IFFiltersMergeValues";
|
|
7
|
+
import { IFValue } from "../../interfaces/IFValue";
|
|
8
|
+
import { getMergeValuesSettings } from "./getMergeValuesSettings";
|
|
9
|
+
import { isInValidator } from "./isInValidator";
|
|
10
|
+
import { isNullValidator } from "./isNullValidator";
|
|
11
|
+
import { isRangeValidator } from "./isRangeValidator";
|
|
12
|
+
import { isRegularValidator } from "./isRegularValidator";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets a new value structure array by merging two value structures
|
|
16
|
+
* @param filter1 the target filter structure
|
|
17
|
+
* @param filter2 the filter to be used to merge the values
|
|
18
|
+
* @param settings configuration of the mergeFilter
|
|
19
|
+
* @returns a new value structure array
|
|
20
|
+
*/
|
|
21
|
+
export function mergeValues(filter1: IFSFilter, filter2: IFSFilter, settings?: IFFiltersMergeValues): IFValue[] {
|
|
22
|
+
if (isEmpty(filter1) && isEmpty(filter2)) return [];
|
|
23
|
+
|
|
24
|
+
settings = getMergeValuesSettings(settings);
|
|
25
|
+
|
|
26
|
+
let newValues = [];
|
|
27
|
+
let filter1Values = filter1.values || [];
|
|
28
|
+
const filter2Values = filter2.values || [];
|
|
29
|
+
if (settings.overwriteValues) {
|
|
30
|
+
filter1Values = filter2Values;
|
|
31
|
+
newValues = filter1Values;
|
|
32
|
+
} else {
|
|
33
|
+
if (isInValidator(filter1.validator)) {
|
|
34
|
+
newValues = filter2Values.reduce((values: IFSValueRelativeDate[], value2: IFSValueRelativeDate) => {
|
|
35
|
+
const value1Index = (filter1Values as IFSValueRelativeDate[]).findIndex(value1 => value2.anchor === value1.anchor && value2.cursor === value1.cursor && value2.includeCurrent === value1.includeCurrent && value2.isCalendarDate === value1.isCalendarDate && value2.number === value1.number && value2.unit === value1.unit);
|
|
36
|
+
if (value1Index === -1) {
|
|
37
|
+
values.push(value2);
|
|
38
|
+
} else {
|
|
39
|
+
values[value1Index] = {
|
|
40
|
+
anchor: value2.anchor,
|
|
41
|
+
cursor: value2.cursor,
|
|
42
|
+
enabled: value2.enabled ?? values[value1Index].enabled,
|
|
43
|
+
includeCurrent: value2.includeCurrent,
|
|
44
|
+
isCalendarDate: value2.isCalendarDate,
|
|
45
|
+
number: value2.number,
|
|
46
|
+
unit: value2.unit,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return values;
|
|
50
|
+
}, filter1Values as IFValue[]);
|
|
51
|
+
} else if (isRangeValidator(filter1.validator)) {
|
|
52
|
+
newValues = filter2Values.reduce((values: IFSValueRange[], value2: IFSValueRange) => {
|
|
53
|
+
const value1Index = (filter1Values as IFSValueRange[]).findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
|
|
54
|
+
if (value1Index === -1) {
|
|
55
|
+
values.push(value2);
|
|
56
|
+
} else {
|
|
57
|
+
values[value1Index] = {
|
|
58
|
+
enabled: value2.enabled ?? values[value1Index].enabled,
|
|
59
|
+
max: value2.max,
|
|
60
|
+
min: value2.min,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return values;
|
|
64
|
+
}, filter1Values as IFValue[]);
|
|
65
|
+
} else if (isRegularValidator(filter1.validator) || isNullValidator(filter1.validator)) {
|
|
66
|
+
newValues = filter2Values.reduce((values: IFSValue[], value2: IFSValue) => {
|
|
67
|
+
const value1Index = (filter1Values as IFSValue[]).findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
|
|
68
|
+
if (value1Index === -1) {
|
|
69
|
+
values.push(value2);
|
|
70
|
+
} else {
|
|
71
|
+
values[value1Index] = {
|
|
72
|
+
enabled: value2.enabled ?? values[value1Index].enabled,
|
|
73
|
+
imageUrl: value2.imageUrl,
|
|
74
|
+
value: value2.value,
|
|
75
|
+
valueid: value2.valueid,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
return values;
|
|
79
|
+
}, filter1Values as IFValue[]);
|
|
80
|
+
} else {
|
|
81
|
+
filter1Values = filter1Values.concat(filter2Values);
|
|
82
|
+
newValues = filter1Values;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return newValues;
|
|
87
|
+
}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
export interface IFSValue {
|
|
5
5
|
enabled?: boolean; // True: the value is enabled; False: the value is disabled
|
|
6
6
|
imageUrl?: string; // URL for a image. This is common for images column type.
|
|
7
|
-
value
|
|
7
|
+
value?: string; // The value to filter
|
|
8
8
|
valueid?: string; // Mostly for webform columns that need an ID. Alias for answerid in the model object.
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { IFFiltersMergeValues } from "./IFFiltersMergeValues";
|
|
1
2
|
|
|
2
3
|
/**
|
|
3
4
|
* Structure for MergeFilters property settings
|
|
4
5
|
*/
|
|
5
|
-
export interface IFFiltersMergeFilters {
|
|
6
|
+
export interface IFFiltersMergeFilters extends IFFiltersMergeValues{
|
|
6
7
|
overwriteFilterProps?: boolean;
|
|
7
|
-
overwriteValues?: boolean;
|
|
8
8
|
setGroupedColumnOperator?: boolean;
|
|
9
9
|
}
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
export interface IFUValue {
|
|
5
5
|
enabled?: boolean; // Optional flag to enabled the value
|
|
6
6
|
imageUrl?: string; // URL from Image type
|
|
7
|
-
value
|
|
7
|
+
value?: string; // A string value
|
|
8
8
|
valueid?: string; // For values that need a value ID or answer ID
|
|
9
9
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
import { isNumericalColumn } from "../../columns/helpers/isNumericalColumn";
|
|
4
2
|
import { isDateColumn } from "../../columns/helpers/isDateColumn";
|
|
5
3
|
import { getAggFilters } from "../helpers/OLD_getAggFilters";
|
|
@@ -31,7 +29,7 @@ export default class UChartPaginationApi {
|
|
|
31
29
|
|
|
32
30
|
/**
|
|
33
31
|
* Gets afterKey object
|
|
34
|
-
* @returns
|
|
32
|
+
* @returns the afterKey object
|
|
35
33
|
*/
|
|
36
34
|
getAfterKey = (): any => {
|
|
37
35
|
return this.afterKey;
|
|
@@ -127,7 +125,7 @@ export default class UChartPaginationApi {
|
|
|
127
125
|
/**
|
|
128
126
|
* Get a dimension body structure foor pagination endpoint
|
|
129
127
|
* @param dimensions
|
|
130
|
-
* @returns
|
|
128
|
+
* @returns the dimension body structure
|
|
131
129
|
*/
|
|
132
130
|
private _getDimensionsBodyAdapter = (dimensions = []) => {
|
|
133
131
|
return dimensions.map(dimension => ({
|
package/src/format/format.ts
CHANGED
|
@@ -23,7 +23,8 @@ function isValidDateString(dateString = '') {
|
|
|
23
23
|
export function formatDate(dateString, format) {
|
|
24
24
|
if (isEmpty(dateString) || !isNaN(dateString) || format === 'Default') return dateString;
|
|
25
25
|
if (!isValidDateString(dateString)) return dateString;
|
|
26
|
-
|
|
26
|
+
const dateValue = dateString?.replace(/Z$/i, '');
|
|
27
|
+
return dayjs(dateValue.split('.')[0]).format(format.replace('HH24:', 'HH:').replace('MI:SS', 'mm:ss').replace('MM:SS', 'mm:ss'));
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export function formatAbbreviated(num, decimals) {
|
|
@@ -89,7 +90,7 @@ export const addFormat = (value: any, outputFormat: any = 'None', config?: IForm
|
|
|
89
90
|
switch (outputFormat.type) {
|
|
90
91
|
case 'DATE':
|
|
91
92
|
case 'DATETIME':
|
|
92
|
-
return config?.lang && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat
|
|
93
|
+
return config?.lang && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat?.format === 'Default' && outputFormat?.originalFormat?.format ? outputFormat?.originalFormat?.format : outputFormat?.format);
|
|
93
94
|
case 'NUMERIC': {
|
|
94
95
|
const parse = parseFloat(value);
|
|
95
96
|
const withLocale = outputFormat !== 'None' && config?.lang;
|
|
@@ -27,9 +27,10 @@ export const formatWithLocale = (value: any, outputFormat: IFormatOutputFormat,
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
const DATE_FORMAT_CACHE = [];
|
|
30
31
|
function formatLocaleDate(value: any, outputFormat: IFormatOutputFormat, config: IFormatConfig) {
|
|
31
32
|
const { lang = LANG_DEFAULT, options } = config;
|
|
32
|
-
const dateValue = value?.replace(
|
|
33
|
+
const dateValue = value?.replace(/Z$/i, '');
|
|
33
34
|
const dateParam = new Date(dateValue);
|
|
34
35
|
let langOpts = options;
|
|
35
36
|
if (outputFormat?.originalFormat) {
|
|
@@ -37,18 +38,31 @@ function formatLocaleDate(value: any, outputFormat: IFormatOutputFormat, config:
|
|
|
37
38
|
if (DATETIME_COLUMN_FORMAT.includes(format)) langOpts = DATETIME_OPTIONS;
|
|
38
39
|
}
|
|
39
40
|
try {
|
|
40
|
-
|
|
41
|
+
const key = lang + JSON.stringify(langOpts);
|
|
42
|
+
let formatter = DATE_FORMAT_CACHE[key];
|
|
43
|
+
if (!formatter) {
|
|
44
|
+
formatter = new Intl.DateTimeFormat([lang, LANG_DEFAULT], langOpts);
|
|
45
|
+
DATE_FORMAT_CACHE[key] = formatter;
|
|
46
|
+
}
|
|
47
|
+
return formatter.format(dateParam);
|
|
41
48
|
} catch (error) {
|
|
42
49
|
return isEmpty(dateParam) ? value : new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
|
|
53
|
+
const NUMBER_FORMAT_CACHE = [];
|
|
46
54
|
function formatLocaleNumber(value: any, outputFormat: IFormatOutputFormat, config: IFormatConfig,) {
|
|
47
55
|
const { lang = LANG_DEFAULT, options } = config;
|
|
48
56
|
const langOpts = options || getLocaleOptions(outputFormat);
|
|
49
57
|
const valueToFormat = outputFormat?.format === LOCALE_FORMATS.PERCENTAGE ? value/100 : value;
|
|
50
58
|
try {
|
|
51
|
-
|
|
59
|
+
const key = lang + JSON.stringify(langOpts);
|
|
60
|
+
let formatter = NUMBER_FORMAT_CACHE[key];
|
|
61
|
+
if (!formatter) {
|
|
62
|
+
formatter = new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts);
|
|
63
|
+
NUMBER_FORMAT_CACHE[key] = formatter;
|
|
64
|
+
}
|
|
65
|
+
return formatter.format(valueToFormat);
|
|
52
66
|
} catch (e) {
|
|
53
67
|
return new Intl.NumberFormat(LANG_DEFAULT, langOpts).format(valueToFormat);
|
|
54
68
|
}
|
|
@@ -25,6 +25,7 @@ export const I18N_DASHBOARD: II18nDashboard = {
|
|
|
25
25
|
data_views_updated_message: 'Data views updated successfully.',
|
|
26
26
|
delete_record_message: 'Record Successfully Deleted.',
|
|
27
27
|
refresh_table_message: 'Record Successfully Edited.',
|
|
28
|
+
failed_download: 'The file(s) could not be exported at this time.',
|
|
28
29
|
},
|
|
29
30
|
tooltips: {
|
|
30
31
|
buckets: "Buckets",
|
|
@@ -4,6 +4,7 @@ import { IDateColumnPropertyType } from "../../columns/interfaces/IDateColumnPro
|
|
|
4
4
|
import { DATE_GROUPING_PROPERTY } from "../../dates/constants/DATE_GROUPING_PROPERTY";
|
|
5
5
|
import { DATE_GROUPING_TIME_PROPERTY } from "../../dates/constants/DATE_GROUPING_TIME_PROPERTY";
|
|
6
6
|
import { addFormat } from "../../format/format";
|
|
7
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
7
8
|
import { getI18nDateGroupLabel } from "../../globalization/helpers/getI18nDateGroupLabel";
|
|
8
9
|
import { ITransformValueSettings } from "../interfaces/ITransformValueSettings";
|
|
9
10
|
import { getValueWithSuffixes } from "./getValueWithSuffixes";
|
|
@@ -15,6 +16,8 @@ import { getValueWithSuffixes } from "./getValueWithSuffixes";
|
|
|
15
16
|
* @returns A transformed value
|
|
16
17
|
*/
|
|
17
18
|
export function transformValue(value: string, settings: ITransformValueSettings): string {
|
|
19
|
+
if (isEmpty(value)) return value;
|
|
20
|
+
|
|
18
21
|
const valueWithI18n = getI18nDateGroupLabel(value, settings.property as IDateColumnPropertyType, settings.translate);
|
|
19
22
|
|
|
20
23
|
const valueWithLocalization = addFormat(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
|
|
@@ -4,9 +4,9 @@ import { IModelBranchesMap } from "../../qrvey/interfaces/IModelBranchesMap";
|
|
|
4
4
|
import { BColumnsToUIColumns } from "./BColumnsToUIColumns.adapter";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param branchesMap
|
|
9
|
-
* @returns
|
|
7
|
+
* Adapts the branches map from backend to the UI branches map
|
|
8
|
+
* @param branchesMap the backend branches map
|
|
9
|
+
* @returns The Branches map array
|
|
10
10
|
*/
|
|
11
11
|
export function BBranchesMapToUIBranchesMap(branchesMap: IBModelBranchesMap[]): IModelBranchesMap[] {
|
|
12
12
|
if (isEmpty(branchesMap)) return [];
|