@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
|
@@ -4,6 +4,6 @@ import { OLD_IFilterLogic } from "../interfaces/OLD_IFilterLogic";
|
|
|
4
4
|
* @deprecated soon
|
|
5
5
|
* @param logics
|
|
6
6
|
* @param summaries
|
|
7
|
-
* @returns
|
|
7
|
+
* @returns the filter aggregate structure
|
|
8
8
|
*/
|
|
9
9
|
export declare function getAggFilters(logics?: OLD_IFilterLogic[], summaries?: any[]): IFBFilterAggregate;
|
|
@@ -7,7 +7,7 @@ import { FILTER_OPERATOR } from "../constants/common/FILTER_OPERATOR";
|
|
|
7
7
|
* @deprecated soon
|
|
8
8
|
* @param logics
|
|
9
9
|
* @param summaries
|
|
10
|
-
* @returns
|
|
10
|
+
* @returns the filter aggregate structure
|
|
11
11
|
*/
|
|
12
12
|
export function getAggFilters(logics = [], summaries = []) {
|
|
13
13
|
const aggregateFilters = getAggregateFilters(logics);
|
|
@@ -20,7 +20,7 @@ export function getBackendProperty(filter) {
|
|
|
20
20
|
return filter.property.concat('_').concat(filter.lookupDisplayIndex.toString());
|
|
21
21
|
}
|
|
22
22
|
else if (filter.column.type === COLUMN.IMAGE) {
|
|
23
|
-
return COLUMN_PROPERTY.IMAGE_ANSWER_ID;
|
|
23
|
+
return filter.values.every(value => isEmpty(value.valueid)) ? undefined : COLUMN_PROPERTY.IMAGE_ANSWER_ID;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
return filter.property;
|
|
@@ -73,7 +73,7 @@ function getResultValues(values, filter) {
|
|
|
73
73
|
return (values || []).map((value) => {
|
|
74
74
|
if (value.enabled) {
|
|
75
75
|
if (filter.column.type === COLUMN.IMAGE) {
|
|
76
|
-
return value.valueid;
|
|
76
|
+
return value.valueid || value.imageUrl || value.value;
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
79
|
return value.value;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IFFiltersMergeValues } from "../../interfaces/functions/IFFiltersMergeValues";
|
|
2
|
+
/**
|
|
3
|
+
* Transforms the given MergeFilters settings object. Adds the missing properties if they do not exist.
|
|
4
|
+
* @param settings an object to the MergeFilters settings
|
|
5
|
+
* @returns a new MergeFilters settings object.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getMergeValuesSettings(settings?: IFFiltersMergeValues): IFFiltersMergeValues;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms the given MergeFilters settings object. Adds the missing properties if they do not exist.
|
|
3
|
+
* @param settings an object to the MergeFilters settings
|
|
4
|
+
* @returns a new MergeFilters settings object.
|
|
5
|
+
*/
|
|
6
|
+
export function getMergeValuesSettings(settings) {
|
|
7
|
+
var _a;
|
|
8
|
+
return {
|
|
9
|
+
overwriteValues: (_a = settings === null || settings === void 0 ? void 0 : settings.overwriteValues) !== null && _a !== void 0 ? _a : false,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -22,6 +22,7 @@ export * from './isNullValidator';
|
|
|
22
22
|
export * from './isRangeValidator';
|
|
23
23
|
export * from './isRegularValidator';
|
|
24
24
|
export * from './mergeFilters';
|
|
25
|
+
export * from './mergeValues';
|
|
25
26
|
export * from './resolveDatasetConditions';
|
|
26
27
|
export * from './resolveFilterConditions';
|
|
27
28
|
export * from './resolveScopeConditions';
|
|
@@ -22,6 +22,7 @@ export * from './isNullValidator';
|
|
|
22
22
|
export * from './isRangeValidator';
|
|
23
23
|
export * from './isRegularValidator';
|
|
24
24
|
export * from './mergeFilters';
|
|
25
|
+
export * from './mergeValues';
|
|
25
26
|
export * from './resolveDatasetConditions';
|
|
26
27
|
export * from './resolveFilterConditions';
|
|
27
28
|
export * from './resolveScopeConditions';
|
|
@@ -3,10 +3,7 @@ import { cloneDeep } from "../../../general/object/cloneDeep";
|
|
|
3
3
|
import { FILTER_GROUPED_COLUMN_OPERATOR } from "../../constants/common/FILTER_GROUPED_COLUMN_OPERATOR";
|
|
4
4
|
import { getFilterid } from "./getFilterid";
|
|
5
5
|
import { getMergeFiltersSettings } from "./getMergeFiltersSettings";
|
|
6
|
-
import {
|
|
7
|
-
import { isNullValidator } from "./isNullValidator";
|
|
8
|
-
import { isRangeValidator } from "./isRangeValidator";
|
|
9
|
-
import { isRegularValidator } from "./isRegularValidator";
|
|
6
|
+
import { mergeValues } from "./mergeValues";
|
|
10
7
|
import { resolveDatasetConditions } from "./resolveDatasetConditions";
|
|
11
8
|
import { resolveFilterConditions } from "./resolveFilterConditions";
|
|
12
9
|
import { resolveScopeConditions } from "./resolveScopeConditions";
|
|
@@ -111,60 +108,9 @@ function mergeFilterss(filters1 = [], filters2 = [], settings) {
|
|
|
111
108
|
* @returns a new filter structure with overwritted props
|
|
112
109
|
*/
|
|
113
110
|
function mergeFilterProps(filter1, filter2, settings) {
|
|
111
|
+
var _a, _b, _c;
|
|
114
112
|
if (settings.overwriteFilterProps) {
|
|
115
|
-
filter1 = Object.assign(Object.assign({}, filter1), { extras: filter2.extras, enabled: filter2.enabled
|
|
113
|
+
filter1 = Object.assign(Object.assign({}, filter1), { collapsed: (_a = filter2.collapsed) !== null && _a !== void 0 ? _a : filter1.collapsed, displayed: (_b = filter2.displayed) !== null && _b !== void 0 ? _b : filter1.displayed, dateSection: filter2.dateSection, extras: filter2.extras, enabled: (_c = filter2.enabled) !== null && _c !== void 0 ? _c : filter1.enabled, filterid: filter2.filterid, lookupDisplayIndex: filter2.lookupDisplayIndex, nullValues: filter2.nullValues, selectAll: filter2.selectAll });
|
|
116
114
|
}
|
|
117
115
|
return filter1;
|
|
118
116
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Gets a new value structure array by merging two value structures
|
|
121
|
-
* @param filter1 the target filter structure
|
|
122
|
-
* @param filter2 the filter to be used to merge the values
|
|
123
|
-
* @param settings configuration of the mergeFilter
|
|
124
|
-
* @returns a new value structure array
|
|
125
|
-
*/
|
|
126
|
-
function mergeValues(filter1, filter2, settings) {
|
|
127
|
-
if (isEmpty(filter1) && isEmpty(filter2))
|
|
128
|
-
return [];
|
|
129
|
-
let newValues = [];
|
|
130
|
-
let filter1Values = filter1.values || [];
|
|
131
|
-
const filter2Values = filter2.values || [];
|
|
132
|
-
if (!settings.overwriteValues) {
|
|
133
|
-
if (isInValidator(filter1.validator)) {
|
|
134
|
-
newValues = filter2Values.reduce((values, value2) => {
|
|
135
|
-
const value1Index = filter1Values.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);
|
|
136
|
-
if (value1Index === -1) {
|
|
137
|
-
values.push(value2);
|
|
138
|
-
}
|
|
139
|
-
return values;
|
|
140
|
-
}, filter1Values);
|
|
141
|
-
}
|
|
142
|
-
else if (isRangeValidator(filter1.validator)) {
|
|
143
|
-
newValues = filter2Values.reduce((values, value2) => {
|
|
144
|
-
const value1Index = filter1Values.findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
|
|
145
|
-
if (value1Index === -1) {
|
|
146
|
-
values.push(value2);
|
|
147
|
-
}
|
|
148
|
-
return values;
|
|
149
|
-
}, filter1Values);
|
|
150
|
-
}
|
|
151
|
-
else if (isRegularValidator(filter1.validator) || isNullValidator(filter1.validator)) {
|
|
152
|
-
newValues = filter2Values.reduce((values, value2) => {
|
|
153
|
-
const value1Index = filter1Values.findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
|
|
154
|
-
if (value1Index === -1) {
|
|
155
|
-
values.push(value2);
|
|
156
|
-
}
|
|
157
|
-
return values;
|
|
158
|
-
}, filter1Values);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
filter1Values = filter1Values.concat(filter2Values);
|
|
162
|
-
newValues = filter1Values;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
filter1Values = filter2Values;
|
|
167
|
-
newValues = filter1Values;
|
|
168
|
-
}
|
|
169
|
-
return newValues;
|
|
170
|
-
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IFSFilter } from "../../interfaces/common/IFSFilter";
|
|
2
|
+
import { IFFiltersMergeValues } from "../../interfaces/functions/IFFiltersMergeValues";
|
|
3
|
+
import { IFValue } from "../../interfaces/IFValue";
|
|
4
|
+
/**
|
|
5
|
+
* Gets a new value structure array by merging two value structures
|
|
6
|
+
* @param filter1 the target filter structure
|
|
7
|
+
* @param filter2 the filter to be used to merge the values
|
|
8
|
+
* @param settings configuration of the mergeFilter
|
|
9
|
+
* @returns a new value structure array
|
|
10
|
+
*/
|
|
11
|
+
export declare function mergeValues(filter1: IFSFilter, filter2: IFSFilter, settings?: IFFiltersMergeValues): IFValue[];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isEmpty } from "../../../general/mix/isEmpty";
|
|
2
|
+
import { getMergeValuesSettings } from "./getMergeValuesSettings";
|
|
3
|
+
import { isInValidator } from "./isInValidator";
|
|
4
|
+
import { isNullValidator } from "./isNullValidator";
|
|
5
|
+
import { isRangeValidator } from "./isRangeValidator";
|
|
6
|
+
import { isRegularValidator } from "./isRegularValidator";
|
|
7
|
+
/**
|
|
8
|
+
* Gets a new value structure array by merging two value structures
|
|
9
|
+
* @param filter1 the target filter structure
|
|
10
|
+
* @param filter2 the filter to be used to merge the values
|
|
11
|
+
* @param settings configuration of the mergeFilter
|
|
12
|
+
* @returns a new value structure array
|
|
13
|
+
*/
|
|
14
|
+
export function mergeValues(filter1, filter2, settings) {
|
|
15
|
+
if (isEmpty(filter1) && isEmpty(filter2))
|
|
16
|
+
return [];
|
|
17
|
+
settings = getMergeValuesSettings(settings);
|
|
18
|
+
let newValues = [];
|
|
19
|
+
let filter1Values = filter1.values || [];
|
|
20
|
+
const filter2Values = filter2.values || [];
|
|
21
|
+
if (settings.overwriteValues) {
|
|
22
|
+
filter1Values = filter2Values;
|
|
23
|
+
newValues = filter1Values;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (isInValidator(filter1.validator)) {
|
|
27
|
+
newValues = filter2Values.reduce((values, value2) => {
|
|
28
|
+
var _a;
|
|
29
|
+
const value1Index = filter1Values.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);
|
|
30
|
+
if (value1Index === -1) {
|
|
31
|
+
values.push(value2);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
values[value1Index] = {
|
|
35
|
+
anchor: value2.anchor,
|
|
36
|
+
cursor: value2.cursor,
|
|
37
|
+
enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
|
|
38
|
+
includeCurrent: value2.includeCurrent,
|
|
39
|
+
isCalendarDate: value2.isCalendarDate,
|
|
40
|
+
number: value2.number,
|
|
41
|
+
unit: value2.unit,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return values;
|
|
45
|
+
}, filter1Values);
|
|
46
|
+
}
|
|
47
|
+
else if (isRangeValidator(filter1.validator)) {
|
|
48
|
+
newValues = filter2Values.reduce((values, value2) => {
|
|
49
|
+
var _a;
|
|
50
|
+
const value1Index = filter1Values.findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
|
|
51
|
+
if (value1Index === -1) {
|
|
52
|
+
values.push(value2);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
values[value1Index] = {
|
|
56
|
+
enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
|
|
57
|
+
max: value2.max,
|
|
58
|
+
min: value2.min,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return values;
|
|
62
|
+
}, filter1Values);
|
|
63
|
+
}
|
|
64
|
+
else if (isRegularValidator(filter1.validator) || isNullValidator(filter1.validator)) {
|
|
65
|
+
newValues = filter2Values.reduce((values, value2) => {
|
|
66
|
+
var _a;
|
|
67
|
+
const value1Index = filter1Values.findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
|
|
68
|
+
if (value1Index === -1) {
|
|
69
|
+
values.push(value2);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
values[value1Index] = {
|
|
73
|
+
enabled: (_a = value2.enabled) !== null && _a !== void 0 ? _a : values[value1Index].enabled,
|
|
74
|
+
imageUrl: value2.imageUrl,
|
|
75
|
+
value: value2.value,
|
|
76
|
+
valueid: value2.valueid,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return values;
|
|
80
|
+
}, filter1Values);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
filter1Values = filter1Values.concat(filter2Values);
|
|
84
|
+
newValues = filter1Values;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return newValues;
|
|
88
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { IFFiltersMergeValues } from "./IFFiltersMergeValues";
|
|
1
2
|
/**
|
|
2
3
|
* Structure for MergeFilters property settings
|
|
3
4
|
*/
|
|
4
|
-
export interface IFFiltersMergeFilters {
|
|
5
|
+
export interface IFFiltersMergeFilters extends IFFiltersMergeValues {
|
|
5
6
|
overwriteFilterProps?: boolean;
|
|
6
|
-
overwriteValues?: boolean;
|
|
7
7
|
setGroupedColumnOperator?: boolean;
|
|
8
8
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,7 +9,7 @@ export default class UChartPaginationApi {
|
|
|
9
9
|
uFilter: IFUFlattenedFilter;
|
|
10
10
|
/**
|
|
11
11
|
* Gets afterKey object
|
|
12
|
-
* @returns
|
|
12
|
+
* @returns the afterKey object
|
|
13
13
|
*/
|
|
14
14
|
getAfterKey: () => any;
|
|
15
15
|
/**
|
|
@@ -38,7 +38,7 @@ export default class UChartPaginationApi {
|
|
|
38
38
|
/**
|
|
39
39
|
* Get a dimension body structure foor pagination endpoint
|
|
40
40
|
* @param dimensions
|
|
41
|
-
* @returns
|
|
41
|
+
* @returns the dimension body structure
|
|
42
42
|
*/
|
|
43
43
|
private _getDimensionsBodyAdapter;
|
|
44
44
|
/**
|
|
@@ -16,7 +16,7 @@ export default class UChartPaginationApi {
|
|
|
16
16
|
constructor() {
|
|
17
17
|
/**
|
|
18
18
|
* Gets afterKey object
|
|
19
|
-
* @returns
|
|
19
|
+
* @returns the afterKey object
|
|
20
20
|
*/
|
|
21
21
|
this.getAfterKey = () => {
|
|
22
22
|
return this.afterKey;
|
|
@@ -95,7 +95,7 @@ export default class UChartPaginationApi {
|
|
|
95
95
|
/**
|
|
96
96
|
* Get a dimension body structure foor pagination endpoint
|
|
97
97
|
* @param dimensions
|
|
98
|
-
* @returns
|
|
98
|
+
* @returns the dimension body structure
|
|
99
99
|
*/
|
|
100
100
|
this._getDimensionsBodyAdapter = (dimensions = []) => {
|
|
101
101
|
return dimensions.map(dimension => ({
|
package/dist/format/format.js
CHANGED
|
@@ -21,7 +21,8 @@ export function formatDate(dateString, format) {
|
|
|
21
21
|
return dateString;
|
|
22
22
|
if (!isValidDateString(dateString))
|
|
23
23
|
return dateString;
|
|
24
|
-
|
|
24
|
+
const dateValue = dateString === null || dateString === void 0 ? void 0 : dateString.replace(/Z$/i, '');
|
|
25
|
+
return dayjs(dateValue.split('.')[0]).format(format.replace('HH24:', 'HH:').replace('MI:SS', 'mm:ss').replace('MM:SS', 'mm:ss'));
|
|
25
26
|
}
|
|
26
27
|
export function formatAbbreviated(num, decimals) {
|
|
27
28
|
if (num == 0)
|
|
@@ -76,12 +77,13 @@ export function formatFileSize(bytes) {
|
|
|
76
77
|
return megaBytes < 10 ? `${fixDecimals(megaBytes)} MB` : `${Math.round(megaBytes)} MB`;
|
|
77
78
|
}
|
|
78
79
|
export const addFormat = (value, outputFormat = 'None', config) => {
|
|
80
|
+
var _a, _b;
|
|
79
81
|
if (isEmpty(value) || typeof value === 'object' && isEmpty(value[0]))
|
|
80
82
|
return value;
|
|
81
83
|
switch (outputFormat.type) {
|
|
82
84
|
case 'DATE':
|
|
83
85
|
case 'DATETIME':
|
|
84
|
-
return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat.format);
|
|
86
|
+
return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === 'Default' && ((_a = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _a === void 0 ? void 0 : _a.format) ? (_b = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _b === void 0 ? void 0 : _b.format : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
|
|
85
87
|
case 'NUMERIC': {
|
|
86
88
|
const parse = parseFloat(value);
|
|
87
89
|
const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
|
|
@@ -24,9 +24,10 @@ export const formatWithLocale = (value, outputFormat, config = {}) => {
|
|
|
24
24
|
return formatLocaleNumber(value, outputFormat, config);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
const DATE_FORMAT_CACHE = [];
|
|
27
28
|
function formatLocaleDate(value, outputFormat, config) {
|
|
28
29
|
const { lang = LANG_DEFAULT, options } = config;
|
|
29
|
-
const dateValue = value === null || value === void 0 ? void 0 : value.replace(
|
|
30
|
+
const dateValue = value === null || value === void 0 ? void 0 : value.replace(/Z$/i, '');
|
|
30
31
|
const dateParam = new Date(dateValue);
|
|
31
32
|
let langOpts = options;
|
|
32
33
|
if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
|
|
@@ -35,18 +36,31 @@ function formatLocaleDate(value, outputFormat, config) {
|
|
|
35
36
|
langOpts = DATETIME_OPTIONS;
|
|
36
37
|
}
|
|
37
38
|
try {
|
|
38
|
-
|
|
39
|
+
const key = lang + JSON.stringify(langOpts);
|
|
40
|
+
let formatter = DATE_FORMAT_CACHE[key];
|
|
41
|
+
if (!formatter) {
|
|
42
|
+
formatter = new Intl.DateTimeFormat([lang, LANG_DEFAULT], langOpts);
|
|
43
|
+
DATE_FORMAT_CACHE[key] = formatter;
|
|
44
|
+
}
|
|
45
|
+
return formatter.format(dateParam);
|
|
39
46
|
}
|
|
40
47
|
catch (error) {
|
|
41
48
|
return isEmpty(dateParam) ? value : new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
|
|
42
49
|
}
|
|
43
50
|
}
|
|
51
|
+
const NUMBER_FORMAT_CACHE = [];
|
|
44
52
|
function formatLocaleNumber(value, outputFormat, config) {
|
|
45
53
|
const { lang = LANG_DEFAULT, options } = config;
|
|
46
54
|
const langOpts = options || getLocaleOptions(outputFormat);
|
|
47
55
|
const valueToFormat = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Percentage" /* PERCENTAGE */ ? value / 100 : value;
|
|
48
56
|
try {
|
|
49
|
-
|
|
57
|
+
const key = lang + JSON.stringify(langOpts);
|
|
58
|
+
let formatter = NUMBER_FORMAT_CACHE[key];
|
|
59
|
+
if (!formatter) {
|
|
60
|
+
formatter = new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts);
|
|
61
|
+
NUMBER_FORMAT_CACHE[key] = formatter;
|
|
62
|
+
}
|
|
63
|
+
return formatter.format(valueToFormat);
|
|
50
64
|
}
|
|
51
65
|
catch (e) {
|
|
52
66
|
return new Intl.NumberFormat(LANG_DEFAULT, langOpts).format(valueToFormat);
|
|
@@ -23,6 +23,7 @@ export const I18N_DASHBOARD = {
|
|
|
23
23
|
data_views_updated_message: 'Data views updated successfully.',
|
|
24
24
|
delete_record_message: 'Record Successfully Deleted.',
|
|
25
25
|
refresh_table_message: 'Record Successfully Edited.',
|
|
26
|
+
failed_download: 'The file(s) could not be exported at this time.',
|
|
26
27
|
},
|
|
27
28
|
tooltips: {
|
|
28
29
|
buckets: "Buckets",
|
|
@@ -3,6 +3,7 @@ import { isNumericalColumn } from "../../columns/helpers/isNumericalColumn";
|
|
|
3
3
|
import { DATE_GROUPING_PROPERTY } from "../../dates/constants/DATE_GROUPING_PROPERTY";
|
|
4
4
|
import { DATE_GROUPING_TIME_PROPERTY } from "../../dates/constants/DATE_GROUPING_TIME_PROPERTY";
|
|
5
5
|
import { addFormat } from "../../format/format";
|
|
6
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
6
7
|
import { getI18nDateGroupLabel } from "../../globalization/helpers/getI18nDateGroupLabel";
|
|
7
8
|
import { getValueWithSuffixes } from "./getValueWithSuffixes";
|
|
8
9
|
/**
|
|
@@ -12,6 +13,8 @@ import { getValueWithSuffixes } from "./getValueWithSuffixes";
|
|
|
12
13
|
* @returns A transformed value
|
|
13
14
|
*/
|
|
14
15
|
export function transformValue(value, settings) {
|
|
16
|
+
if (isEmpty(value))
|
|
17
|
+
return value;
|
|
15
18
|
const valueWithI18n = getI18nDateGroupLabel(value, settings.property, settings.translate);
|
|
16
19
|
const valueWithLocalization = addFormat(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
|
|
17
20
|
return getValueWithSuffixes(valueWithLocalization, { suffixTranslateLabel: settings.suffixTranslateLabel, translate: settings.translate });
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IBModelBranchesMap } from "../../qrvey/interfaces/IBModelBranchesMap";
|
|
2
2
|
import { IModelBranchesMap } from "../../qrvey/interfaces/IModelBranchesMap";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param branchesMap
|
|
6
|
-
* @returns
|
|
4
|
+
* Adapts the branches map from backend to the UI branches map
|
|
5
|
+
* @param branchesMap the backend branches map
|
|
6
|
+
* @returns The Branches map array
|
|
7
7
|
*/
|
|
8
8
|
export declare function BBranchesMapToUIBranchesMap(branchesMap: IBModelBranchesMap[]): IModelBranchesMap[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
2
|
import { BColumnsToUIColumns } from "./BColumnsToUIColumns.adapter";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param branchesMap
|
|
6
|
-
* @returns
|
|
4
|
+
* Adapts the branches map from backend to the UI branches map
|
|
5
|
+
* @param branchesMap the backend branches map
|
|
6
|
+
* @returns The Branches map array
|
|
7
7
|
*/
|
|
8
8
|
export function BBranchesMapToUIBranchesMap(branchesMap) {
|
|
9
9
|
if (isEmpty(branchesMap))
|
package/package.json
CHANGED
|
@@ -1,33 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qrvey/utils",
|
|
3
|
-
"version": "1.2.10-
|
|
3
|
+
"version": "1.2.10-8",
|
|
4
4
|
"description": "Helper, Utils for all Qrvey Projects",
|
|
5
5
|
"homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc && tsc -m commonjs --outDir dist/cjs",
|
|
9
9
|
"docs": "./node_modules/.bin/jsdoc -c ./jsdoc.config.json",
|
|
10
|
+
"doxs": "doxdox './dist/**/*.js' --ignore './dist/cjs/**/*.js' --output README.md --layout markdown --package ./package.json",
|
|
11
|
+
"lint": "eslint src --quiet --exit-on-fatal-error --ext .ts,.js",
|
|
12
|
+
"lint-dev": "eslint src --debug --ext .ts,.tsx",
|
|
10
13
|
"publishing": "node prepareToPublish.js && np",
|
|
11
14
|
"publishing-prerelease": "node prepareToPublish.js && np --any-branch --tag=$npm_config_tag",
|
|
12
15
|
"publishing-v2": "node publishing.js --np-new-version=$npm_config_np_new_version --np-any-branch=$npm_config_np_any_branch --np-tag=$npm_config_np_tag",
|
|
13
16
|
"test": "jest test",
|
|
14
|
-
"test:watch": "jest --watch test"
|
|
15
|
-
"lint": "eslint src --quiet --exit-on-fatal-error --ext .ts,.js",
|
|
16
|
-
"lint-dev": "eslint src --debug --ext .ts,.tsx"
|
|
17
|
+
"test:watch": "jest --watch test"
|
|
17
18
|
},
|
|
18
19
|
"author": "Qrvey Inc",
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@types/jest": "27.4.1",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "5.15.0",
|
|
24
|
+
"@typescript-eslint/parser": "5.15.0",
|
|
22
25
|
"doxdox": "3.0.0",
|
|
26
|
+
"eslint": "8.11.0",
|
|
23
27
|
"jest": "27.5.1",
|
|
28
|
+
"jsdoc": "3.6.10",
|
|
24
29
|
"np": "7.6.0",
|
|
25
30
|
"ts-jest": "27.1.3",
|
|
26
31
|
"typedoc": "0.22.13",
|
|
27
|
-
"typescript": "4.6.2"
|
|
28
|
-
"@typescript-eslint/eslint-plugin": "5.15.0",
|
|
29
|
-
"@typescript-eslint/parser": "5.15.0",
|
|
30
|
-
"eslint": "8.11.0"
|
|
32
|
+
"typescript": "4.6.2"
|
|
31
33
|
},
|
|
32
34
|
"dependencies": {
|
|
33
35
|
"d3": "6.3.1",
|
package/publishing.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* New version for publishing a new version of Qrvey Utils
|
|
3
|
+
* 1- Publish the version with np
|
|
4
|
+
* 2- Update the README.md doc with doxdox
|
|
5
|
+
*/
|
|
6
|
+
|
|
2
7
|
const fs = require('fs');
|
|
3
8
|
const util = require('util');
|
|
4
9
|
const childProcess = require('child_process');
|
|
@@ -129,6 +134,7 @@ async function startGeneratingDocs(settings) {
|
|
|
129
134
|
console.log('==>>> Starting the Docs generation');
|
|
130
135
|
|
|
131
136
|
await generatingDocument(settings);
|
|
137
|
+
await changingVersion(settings);
|
|
132
138
|
await pushingChanges(settings);
|
|
133
139
|
}
|
|
134
140
|
|
|
@@ -137,6 +143,13 @@ async function generatingDocument(settings) {
|
|
|
137
143
|
await execute(`doxdox './dist/.+\\.js' --output ${settings.docsFileName} --ignore './dist/cjs/.+\\.js' --package ${settings.packagePath}`);
|
|
138
144
|
}
|
|
139
145
|
|
|
146
|
+
async function changingVersion(settings) {
|
|
147
|
+
console.log('==>>> Replacing the old version in the document');
|
|
148
|
+
const doc = await fs.readFileSync(settings.docsPath, 'utf8');
|
|
149
|
+
const replacedDoc = doc.replace(settings.currentVersion, settings.newVersion);
|
|
150
|
+
await fs.writeFileSync(settings.docsPath, replacedDoc, 'utf8');
|
|
151
|
+
}
|
|
152
|
+
|
|
140
153
|
async function pushingChanges(settings) {
|
|
141
154
|
console.log('==>>> Commiting and Pushing Docs changes...');
|
|
142
155
|
|
|
@@ -176,8 +189,8 @@ async function init() {
|
|
|
176
189
|
|
|
177
190
|
await cleaningProject(settings);
|
|
178
191
|
await buildingBundle(settings);
|
|
179
|
-
await startPublishingVersion(settings);
|
|
180
192
|
await startGeneratingDocs(settings);
|
|
193
|
+
await startPublishingVersion(settings);
|
|
181
194
|
console.info('Finished Publishing');
|
|
182
195
|
} catch (err) {
|
|
183
196
|
console.error('Error: ', err);
|
|
@@ -15,7 +15,7 @@ import { IFSValueRelativeDate } from "../interfaces/common/IFSValueRelativeDate"
|
|
|
15
15
|
* @returns A new value array with the filled properties.
|
|
16
16
|
*/
|
|
17
17
|
export function adaptFilterValues(filter: IFSFilter): IFValue[] {
|
|
18
|
-
const setValue = value => ({ ...value, enabled: isEmpty(value.enabled) ? true : value.enabled });
|
|
18
|
+
const setValue = value => ({ ...value, value: isEmpty(value.value) ? undefined : value.value, enabled: isEmpty(value.enabled) ? true : value.enabled });
|
|
19
19
|
|
|
20
20
|
if (filter.column.type === COLUMN.RANKING && isEmpty(filter.column.aggregate)) {
|
|
21
21
|
return ((filter.values || []) as IFSValueRanking[][]).map(rValues => rValues.map(setValue));
|
|
@@ -9,6 +9,7 @@ import { IFSData } from "../interfaces/common/IFSData";
|
|
|
9
9
|
import { IFSScope } from "../interfaces/common/IFSScope";
|
|
10
10
|
import { IFSFilter } from "../interfaces/common/IFSFilter";
|
|
11
11
|
import { IFSDataset } from "../interfaces/common/IFSDataset";
|
|
12
|
+
import { cloneDeep } from "../../general/object/cloneDeep";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Generates a filter data structure from the flatttened UI filters.
|
|
@@ -90,9 +91,13 @@ function buildDataset(uFilter: IFUFlattenedFilter): IFSDataset {
|
|
|
90
91
|
* @returns an filter structure
|
|
91
92
|
*/
|
|
92
93
|
function buildFilter(uFilter: IFUFlattenedFilter): IFSFilter {
|
|
94
|
+
uFilter = cloneDeep(uFilter);
|
|
95
|
+
|
|
93
96
|
const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
|
|
94
97
|
const property = adaptDateGroupingProperty(uFilter.property);
|
|
95
98
|
|
|
99
|
+
delete uFilter.extras.scopeInfo;
|
|
100
|
+
delete uFilter.extras.dataset;
|
|
96
101
|
return {
|
|
97
102
|
collapsed: uFilter.collapsed,
|
|
98
103
|
column: {
|
|
@@ -410,7 +410,7 @@ function getRankingValues(values: IFSValueRanking[][], rankingGroupIndex?: numbe
|
|
|
410
410
|
return (values || []).map((value: IFSValue) => {
|
|
411
411
|
if (value.enabled) {
|
|
412
412
|
if (props.column.type === COLUMN.IMAGE) {
|
|
413
|
-
return value.valueid;
|
|
413
|
+
return value.valueid || value.imageUrl || value.value;
|
|
414
414
|
} else {
|
|
415
415
|
return value.value;
|
|
416
416
|
}
|
|
@@ -10,6 +10,7 @@ import { IFUFilter } from "../interfaces/ui/IFUFilter";
|
|
|
10
10
|
import { IFUDataset } from "../interfaces/ui/IFUDataset";
|
|
11
11
|
import { getLastIndexFromArray } from "../../general/array/getLastIndexFromArray";
|
|
12
12
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
13
|
+
import { cloneDeep } from "../../general/object/cloneDeep";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Generates a UI filter data structure from the flatttened UI filters.
|
|
@@ -96,9 +97,13 @@ function buildDataset(uFilter: IFUFlattenedFilter): IFUDataset {
|
|
|
96
97
|
* @returns an filter structure
|
|
97
98
|
*/
|
|
98
99
|
function buildFilter(uFilter: IFUFlattenedFilter): IFUFilter {
|
|
100
|
+
uFilter = cloneDeep(uFilter);
|
|
101
|
+
|
|
99
102
|
const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
|
|
100
103
|
const property = adaptDateGroupingProperty(uFilter.property);
|
|
101
104
|
|
|
105
|
+
delete uFilter.extras.scopeInfo;
|
|
106
|
+
delete uFilter.extras.dataset;
|
|
102
107
|
return {
|
|
103
108
|
collapsed: uFilter.collapsed,
|
|
104
109
|
column: {
|
|
@@ -13,7 +13,7 @@ import { OLD_IFilterLogic } from "../interfaces/OLD_IFilterLogic";
|
|
|
13
13
|
* @deprecated soon
|
|
14
14
|
* @param logics
|
|
15
15
|
* @param summaries
|
|
16
|
-
* @returns
|
|
16
|
+
* @returns the filter aggregate structure
|
|
17
17
|
*/
|
|
18
18
|
export function getAggFilters(logics: OLD_IFilterLogic[] = [], summaries: any[] = []): IFBFilterAggregate {
|
|
19
19
|
const aggregateFilters: OLD_IFilterLogic[] = getAggregateFilters(logics) as OLD_IFilterLogic[];
|