@qrvey/utils 1.1.2-0 → 1.1.4
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 +458 -378
- package/dist/cjs/constants/COLUMN_PROPERTY.d.ts +6 -6
- package/dist/cjs/constants/COLUMN_PROPERTY_VALUE.d.ts +1 -2
- package/dist/cjs/constants/COLUMN_PROPERTY_VALUE.js +3 -8
- package/dist/cjs/date/constants/DATE_PROPERTY_VALUE.d.ts +6 -6
- package/dist/cjs/date/constants/DATE_PROPERTY_VALUE.js +6 -6
- package/dist/cjs/date/constants/DATE_P_PROPERTIES.js +6 -6
- package/dist/cjs/date/constants/DATE_P_VALUES.js +3 -3
- package/dist/cjs/date/constants/DATE_TIME_P_VALUES.js +3 -3
- package/dist/cjs/date/constants/DATE_TIME_VALUES.js +3 -3
- package/dist/cjs/date/constants/DATE_VALUES.d.ts +6 -0
- package/dist/cjs/date/constants/DATE_VALUES.js +10 -0
- package/dist/cjs/filters/adapters/FDToFlatUI.js +3 -1
- package/dist/cjs/filters/adapters/FDToUI.js +3 -1
- package/dist/cjs/filters/adapters/UIToFlatUI.js +3 -1
- package/dist/cjs/filters/adapters/UIToOldLogic.js +3 -1
- package/dist/cjs/filters/adapters/adaptDateGroupingProperty.d.ts +8 -0
- package/dist/cjs/filters/adapters/adaptDateGroupingProperty.js +19 -0
- package/dist/cjs/filters/adapters/adaptFilterData.js +1 -1
- package/dist/cjs/filters/adapters/flatUIToFD.js +3 -1
- package/dist/cjs/filters/adapters/flatUIToOldLogic.js +1 -5
- package/dist/cjs/filters/adapters/flatUIToUI.js +3 -1
- package/dist/cjs/filters/adapters/index.d.ts +1 -0
- package/dist/cjs/filters/adapters/index.js +1 -0
- package/dist/cjs/filters/adapters/logicToFlatUI.js +77 -63
- package/dist/cjs/filters/helpers/backend/getBackendGroupValue.js +4 -3
- package/dist/cjs/filters/helpers/backend/getBackendProperty.js +1 -5
- package/dist/cjs/filters/helpers/ui/getFilterPropertyLabel.d.ts +7 -0
- package/dist/cjs/filters/helpers/ui/getFilterPropertyLabel.js +13 -0
- package/dist/cjs/filters/helpers/ui/index.d.ts +1 -0
- package/dist/cjs/filters/helpers/ui/index.js +1 -0
- package/dist/cjs/general/array/filterNestedTree.d.ts +5 -2
- package/dist/cjs/general/array/filterNestedTree.js +13 -5
- package/dist/cjs/general/mix/getTag.d.ts +7 -0
- package/dist/cjs/general/mix/getTag.js +16 -0
- package/dist/cjs/general/mix/index.d.ts +1 -0
- package/dist/cjs/general/mix/index.js +1 -0
- package/dist/cjs/general/mix/isEmpty.js +8 -4
- package/dist/cjs/general/mix/isNull.js +1 -1
- package/dist/cjs/general/mix/randomId.d.ts +6 -3
- package/dist/cjs/general/mix/randomId.js +24 -7
- package/dist/cjs/general/mix/size.d.ts +5 -5
- package/dist/cjs/general/mix/size.js +9 -6
- package/dist/cjs/general/object/get.d.ts +1 -1
- package/dist/cjs/general/object/getAttribute.d.ts +9 -2
- package/dist/cjs/general/object/getAttribute.js +39 -8
- package/dist/cjs/general/object/hasProperty.d.ts +1 -1
- package/dist/cjs/general/object/hasProperty.js +10 -2
- package/dist/cjs/general/object/index.d.ts +1 -0
- package/dist/cjs/general/object/index.js +1 -0
- package/dist/cjs/general/object/isObject.js +2 -1
- package/dist/cjs/general/object/objectCopy.d.ts +7 -0
- package/dist/cjs/general/object/objectCopy.js +32 -0
- package/dist/cjs/general/string/capitalize.d.ts +3 -3
- package/dist/cjs/general/string/capitalize.js +6 -3
- package/dist/cjs/qrvey/getPropertyLabel.d.ts +2 -0
- package/dist/cjs/qrvey/getPropertyLabel.js +14 -0
- package/dist/cjs/qrvey/index.d.ts +1 -0
- package/dist/cjs/qrvey/index.js +1 -0
- package/dist/constants/COLUMN_PROPERTY.d.ts +6 -6
- package/dist/constants/COLUMN_PROPERTY_VALUE.d.ts +1 -2
- package/dist/constants/COLUMN_PROPERTY_VALUE.js +4 -9
- package/dist/date/constants/DATE_PROPERTY_VALUE.d.ts +6 -6
- package/dist/date/constants/DATE_PROPERTY_VALUE.js +6 -6
- package/dist/date/constants/DATE_P_PROPERTIES.js +6 -6
- package/dist/date/constants/DATE_P_VALUES.js +3 -3
- package/dist/date/constants/DATE_TIME_P_VALUES.js +3 -3
- package/dist/date/constants/DATE_TIME_VALUES.js +3 -3
- package/dist/date/constants/DATE_VALUES.d.ts +6 -0
- package/dist/date/constants/DATE_VALUES.js +7 -0
- package/dist/filters/adapters/FDToFlatUI.js +3 -1
- package/dist/filters/adapters/FDToUI.js +3 -1
- package/dist/filters/adapters/UIToFlatUI.js +3 -1
- package/dist/filters/adapters/UIToOldLogic.js +3 -1
- package/dist/filters/adapters/adaptDateGroupingProperty.d.ts +8 -0
- package/dist/filters/adapters/adaptDateGroupingProperty.js +15 -0
- package/dist/filters/adapters/adaptFilterData.js +1 -1
- package/dist/filters/adapters/flatUIToFD.js +3 -1
- package/dist/filters/adapters/flatUIToOldLogic.js +1 -5
- package/dist/filters/adapters/flatUIToUI.js +3 -1
- package/dist/filters/adapters/index.d.ts +1 -0
- package/dist/filters/adapters/index.js +1 -0
- package/dist/filters/adapters/logicToFlatUI.js +79 -65
- package/dist/filters/helpers/backend/getBackendGroupValue.js +4 -3
- package/dist/filters/helpers/backend/getBackendProperty.js +2 -6
- package/dist/filters/helpers/ui/getFilterPropertyLabel.d.ts +7 -0
- package/dist/filters/helpers/ui/getFilterPropertyLabel.js +9 -0
- package/dist/filters/helpers/ui/index.d.ts +1 -0
- package/dist/filters/helpers/ui/index.js +1 -0
- package/dist/general/array/filterNestedTree.d.ts +5 -2
- package/dist/general/array/filterNestedTree.js +13 -5
- package/dist/general/mix/getTag.d.ts +7 -0
- package/dist/general/mix/getTag.js +12 -0
- package/dist/general/mix/index.d.ts +1 -0
- package/dist/general/mix/index.js +1 -0
- package/dist/general/mix/isEmpty.js +8 -4
- package/dist/general/mix/isNull.js +1 -1
- package/dist/general/mix/randomId.d.ts +6 -3
- package/dist/general/mix/randomId.js +24 -7
- package/dist/general/mix/size.d.ts +5 -5
- package/dist/general/mix/size.js +9 -6
- package/dist/general/object/get.d.ts +1 -1
- package/dist/general/object/getAttribute.d.ts +9 -2
- package/dist/general/object/getAttribute.js +39 -8
- package/dist/general/object/hasProperty.d.ts +1 -1
- package/dist/general/object/hasProperty.js +8 -0
- package/dist/general/object/index.d.ts +1 -0
- package/dist/general/object/index.js +1 -0
- package/dist/general/object/isObject.js +2 -1
- package/dist/general/object/objectCopy.d.ts +7 -0
- package/dist/general/object/objectCopy.js +28 -0
- package/dist/general/string/capitalize.d.ts +3 -3
- package/dist/general/string/capitalize.js +6 -3
- package/dist/qrvey/getPropertyLabel.d.ts +2 -0
- package/dist/qrvey/getPropertyLabel.js +10 -0
- package/dist/qrvey/index.d.ts +1 -0
- package/dist/qrvey/index.js +1 -0
- package/package.json +1 -1
- package/src/constants/COLUMN_PROPERTY.ts +7 -7
- package/src/constants/COLUMN_PROPERTY_VALUE.ts +4 -10
- package/src/date/constants/DATE_P_VALUES.ts +3 -3
- package/src/date/constants/DATE_TIME_P_VALUES.ts +3 -3
- package/src/date/constants/DATE_TIME_VALUES.ts +3 -3
- package/src/date/constants/DATE_VALUES.ts +9 -0
- package/src/filters/adapters/FDToFlatUI.ts +3 -1
- package/src/filters/adapters/FDToUI.ts +4 -0
- package/src/filters/adapters/UIToFlatUI.ts +3 -1
- package/src/filters/adapters/UIToOldLogic.ts +4 -1
- package/src/filters/adapters/adaptDateGroupingProperty.ts +18 -0
- package/src/filters/adapters/adaptFilterData.ts +1 -1
- package/src/filters/adapters/flatUIToFD.ts +4 -1
- package/src/filters/adapters/flatUIToOldLogic.ts +1 -3
- package/src/filters/adapters/flatUIToUI.ts +4 -1
- package/src/filters/adapters/index.ts +1 -0
- package/src/filters/adapters/logicToFlatUI.ts +87 -70
- package/src/filters/helpers/backend/getAggFiltersBySummaryIndex.ts +1 -1
- package/src/filters/helpers/backend/getBackendGroupValue.ts +4 -3
- package/src/filters/helpers/backend/getBackendProperty.ts +2 -4
- package/src/filters/helpers/ui/getFilterPropertyLabel.ts +11 -0
- package/src/filters/helpers/ui/index.ts +1 -0
- package/src/general/array/filterNestedTree.ts +13 -4
- package/src/general/mix/getTag.ts +12 -0
- package/src/general/mix/index.ts +1 -0
- package/src/general/mix/isEmpty.ts +9 -4
- package/src/general/mix/isNull.ts +1 -1
- package/src/general/mix/randomId.ts +24 -7
- package/src/general/mix/size.ts +10 -6
- package/src/general/object/get.ts +1 -1
- package/src/general/object/getAttribute.ts +47 -9
- package/src/general/object/hasProperty.ts +10 -1
- package/src/general/object/index.ts +1 -0
- package/src/general/object/isObject.ts +3 -1
- package/src/general/object/objectCopy.ts +35 -0
- package/src/general/string/capitalize.ts +7 -3
- package/src/qrvey/getPropertyLabel.ts +9 -0
- package/src/qrvey/index.ts +1 -0
- package/test/general/array/filterNestedTree.test.js +115 -0
- package/test/general/mix/getTag.test.js +101 -0
- package/test/general/mix/isEmpty.test.js +30 -24
- package/test/general/mix/isNull.test.js +72 -0
- package/test/general/mix/randomId.test.js +134 -0
- package/test/general/mix/size.test.js +87 -0
- package/test/general/object/cloneDeep.test.js +8 -16
- package/test/general/object/getAttribute.test.js +316 -0
- package/test/general/object/hasProperty.test.js +103 -0
- package/test/general/object/objectCopy.test.js +105 -0
- package/test/general/string/capitalize.test.js +87 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const DATE_TIME_VALUES = [
|
|
2
|
-
{ label: '
|
|
3
|
-
{ label: '
|
|
4
|
-
{ label: '
|
|
2
|
+
{ label: 'Date, Hour', value: "hour" /* DATE_HOUR */, display: true },
|
|
3
|
+
{ label: 'Date, Minute', value: "minute" /* DATE_MINUTE */, display: true },
|
|
4
|
+
{ label: 'Date, Second', value: "second" /* DATE_SECOND */, display: true },
|
|
5
5
|
];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const DATE_VALUES = [
|
|
2
|
+
{ value: "day" /* DATE_DAY */, label: 'Full Date', display: true },
|
|
3
|
+
{ value: "year" /* DATE_YEAR */, label: 'Year', display: true },
|
|
4
|
+
{ value: "quarter" /* DATE_QUARTER */, label: 'Quarter, Year', display: true },
|
|
5
|
+
{ value: "month" /* DATE_MONTH */, label: 'Month, Year', display: true },
|
|
6
|
+
{ value: "week" /* DATE_WEEK */, label: 'Week, Year', display: true }
|
|
7
|
+
];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cloneDeep, isEmpty, _get } from "../../general";
|
|
2
2
|
import { getUIValues } from "../helpers";
|
|
3
|
+
import { adaptDateGroupingProperty } from "./adaptDateGroupingProperty";
|
|
3
4
|
/**
|
|
4
5
|
* Generates a Flattened UI filter structure from Filter Data structure.
|
|
5
6
|
* @param filterData The filter data object.
|
|
@@ -39,6 +40,7 @@ function FD21ToFlatUI(scopes = [], datasetsInfo = []) {
|
|
|
39
40
|
if (!isEmpty(datasetInfo))
|
|
40
41
|
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
41
42
|
const info = !isEmpty(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
|
|
43
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
42
44
|
const uFilter = {
|
|
43
45
|
collapsed: filter.collapsed,
|
|
44
46
|
column: {
|
|
@@ -75,7 +77,7 @@ function FD21ToFlatUI(scopes = [], datasetsInfo = []) {
|
|
|
75
77
|
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
76
78
|
nullValues: filter.nullValues,
|
|
77
79
|
operator: filter.operator,
|
|
78
|
-
property:
|
|
80
|
+
property: property,
|
|
79
81
|
uiValues: getUIValues(filter),
|
|
80
82
|
validator: filter.validator,
|
|
81
83
|
values: filter.values,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { cloneDeep, isEmpty, _get } from "../../general";
|
|
2
3
|
import { FILTER_STRUCTURE_VERSION } from "../constants";
|
|
3
4
|
import { getUIValues } from "../helpers";
|
|
@@ -43,6 +44,7 @@ function FD21ToUI(scopes = [], section = "ANYWHERE" /* ANYWHERE */, enabled = tr
|
|
|
43
44
|
let columnInfo;
|
|
44
45
|
if (!isEmpty(datasetInfo))
|
|
45
46
|
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
47
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
46
48
|
return Object.assign(Object.assign({}, filter), { column: {
|
|
47
49
|
aggregate: filter.column.aggregate,
|
|
48
50
|
calculation: filter.column.calculation,
|
|
@@ -54,7 +56,7 @@ function FD21ToUI(scopes = [], section = "ANYWHERE" /* ANYWHERE */, enabled = tr
|
|
|
54
56
|
outputFormat: _get(datasetInfo, 'outputFormat'),
|
|
55
57
|
qrveyid: filter.column.qrveyid,
|
|
56
58
|
type: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.type) || filter.column.type,
|
|
57
|
-
}, uiValues: getUIValues(filter) });
|
|
59
|
+
}, property, uiValues: getUIValues(filter) });
|
|
58
60
|
}) });
|
|
59
61
|
}) })));
|
|
60
62
|
return ufData;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { cloneDeep, isEmpty } from "../../general";
|
|
2
3
|
import { getUIValues } from "../helpers";
|
|
3
4
|
/**
|
|
@@ -38,6 +39,7 @@ function UI21ToFlatUI(scopes = [], datasetsInfo = []) {
|
|
|
38
39
|
if (!isEmpty(datasetInfo))
|
|
39
40
|
columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
|
|
40
41
|
const info = !isEmpty(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
|
|
42
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
41
43
|
const uFilter = {
|
|
42
44
|
collapsed: filter.collapsed,
|
|
43
45
|
column: {
|
|
@@ -74,7 +76,7 @@ function UI21ToFlatUI(scopes = [], datasetsInfo = []) {
|
|
|
74
76
|
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
75
77
|
nullValues: filter.nullValues,
|
|
76
78
|
operator: filter.operator,
|
|
77
|
-
property
|
|
79
|
+
property,
|
|
78
80
|
uiValues: getUIValues(filter),
|
|
79
81
|
validator: filter.validator,
|
|
80
82
|
values: filter.values,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { cloneDeep, isEmpty } from "../../general";
|
|
2
3
|
import { getBackendGroupValue, getBackendProperty, getBackendValidator, getBackendValues, getUIValues } from "../helpers";
|
|
3
4
|
import { flatUIToOldLogic } from "./flatUIToOldLogic";
|
|
@@ -99,6 +100,7 @@ const getFilterDetail = (filter, scope, dataset) => {
|
|
|
99
100
|
label: filter.extras.info.label,
|
|
100
101
|
};
|
|
101
102
|
}
|
|
103
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
102
104
|
return {
|
|
103
105
|
collapsed: filter.collapsed,
|
|
104
106
|
column: {
|
|
@@ -126,7 +128,7 @@ const getFilterDetail = (filter, scope, dataset) => {
|
|
|
126
128
|
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
127
129
|
nullValues: filter.nullValues,
|
|
128
130
|
operator: filter.operator,
|
|
129
|
-
property
|
|
131
|
+
property,
|
|
130
132
|
scope: scope.scope,
|
|
131
133
|
scopeid: filter.extras.scopeid,
|
|
132
134
|
scopeEnabled: scope.enabled,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IFProperty } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* [TODO: For 2022, eliminate this adapter]
|
|
4
|
+
* Get the new property base on the old date grouping properties
|
|
5
|
+
* @param property
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function adaptDateGroupingProperty(property: IFProperty | any): IFProperty;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [TODO: For 2022, eliminate this adapter]
|
|
3
|
+
* Get the new property base on the old date grouping properties
|
|
4
|
+
* @param property
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export function adaptDateGroupingProperty(property) {
|
|
8
|
+
return property === 'p&quarter' ? "quarter_only" /* DATE_YEAR_QUARTER */ :
|
|
9
|
+
property === 'p&month' ? "month_only" /* DATE_YEAR_MONTH */ :
|
|
10
|
+
property === 'p&day' ? "day_only" /* DATE_MONTH_DAY */ :
|
|
11
|
+
property === 'p&hour' ? "hour_only" /* DATE_DAY_HOUR */ :
|
|
12
|
+
property === 'p&minute' ? "minute_only" /* DATE_HOUR_MINUTE */ :
|
|
13
|
+
property === 'p&second' ? "second_only" /* DATE_MINUTE_SECOND */ :
|
|
14
|
+
property;
|
|
15
|
+
}
|
|
@@ -10,7 +10,7 @@ import { UIToFD } from "./UIToFD";
|
|
|
10
10
|
* @param datasetsInfo Collection of datasets information. If getUIFilterData is true, the datasetsInfo should be mandatory
|
|
11
11
|
* @returns A new filter data structure v2.1
|
|
12
12
|
*/
|
|
13
|
-
export function adaptFilterData(filterData, getUIFilterData =
|
|
13
|
+
export function adaptFilterData(filterData, getUIFilterData = true, datasetsInfo = []) {
|
|
14
14
|
if (isEmpty(filterData))
|
|
15
15
|
return;
|
|
16
16
|
filterData = cloneDeep(filterData);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { isEmpty } from "../../general";
|
|
2
3
|
import { FILTER_STRUCTURE_VERSION } from "../constants";
|
|
3
4
|
/**
|
|
@@ -76,6 +77,7 @@ function buildDataset(uFilter) {
|
|
|
76
77
|
*/
|
|
77
78
|
function buildFilter(uFilter) {
|
|
78
79
|
const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
|
|
80
|
+
const property = adaptDateGroupingProperty(uFilter.property);
|
|
79
81
|
return {
|
|
80
82
|
collapsed: uFilter.collapsed,
|
|
81
83
|
column: {
|
|
@@ -94,7 +96,7 @@ function buildFilter(uFilter) {
|
|
|
94
96
|
lookupDisplayIndex: uFilter.lookupDisplayIndex,
|
|
95
97
|
nullValues: uFilter.nullValues,
|
|
96
98
|
operator: uFilter.operator,
|
|
97
|
-
property
|
|
99
|
+
property,
|
|
98
100
|
validator: uFilter.validator,
|
|
99
101
|
values: uFilter.values,
|
|
100
102
|
};
|
|
@@ -165,14 +165,10 @@ function getGroupValue(props) {
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
function getProperty(props) {
|
|
168
|
-
var _a;
|
|
169
168
|
if (isEmpty(props.column.aggregate)) {
|
|
170
|
-
if (isNullValidator(props.validator)) {
|
|
169
|
+
if (isNullValidator(props.validator) || isDateColumn(props.column)) {
|
|
171
170
|
return undefined;
|
|
172
171
|
}
|
|
173
|
-
else if (isDateColumn(props.column)) {
|
|
174
|
-
return arePropertiesDateP(props.column, props.property) ? (_a = props.property) === null || _a === void 0 ? void 0 : _a.split('p&')[1] : undefined;
|
|
175
|
-
}
|
|
176
172
|
else if (props.column.type === COLUMN.EXPRESSION && props.property != null) {
|
|
177
173
|
return undefined;
|
|
178
174
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from ".";
|
|
1
2
|
import { isEmpty, getLastIndexFromArray } from "../../general";
|
|
2
3
|
import { FILTER_STRUCTURE_VERSION } from "../constants";
|
|
3
4
|
import { getUIValues } from "../helpers";
|
|
@@ -83,6 +84,7 @@ function buildDataset(uFilter) {
|
|
|
83
84
|
*/
|
|
84
85
|
function buildFilter(uFilter) {
|
|
85
86
|
const info = !isEmpty(uFilter.extras.info) ? { icon: uFilter.extras.info.icon, label: uFilter.extras.info.label } : undefined;
|
|
87
|
+
const property = adaptDateGroupingProperty(uFilter.property);
|
|
86
88
|
return {
|
|
87
89
|
collapsed: uFilter.collapsed,
|
|
88
90
|
column: {
|
|
@@ -108,7 +110,7 @@ function buildFilter(uFilter) {
|
|
|
108
110
|
lookupDisplayIndex: uFilter.lookupDisplayIndex,
|
|
109
111
|
nullValues: uFilter.nullValues,
|
|
110
112
|
operator: uFilter.operator,
|
|
111
|
-
property
|
|
113
|
+
property,
|
|
112
114
|
uiValues: getUIValues(uFilter),
|
|
113
115
|
validator: uFilter.validator,
|
|
114
116
|
values: uFilter.values,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// FROM Logic structure = Old logic structure (v2.0)
|
|
2
2
|
// TO Logic structure = Cleaner logic structure
|
|
3
|
+
import { adaptDateGroupingProperty } from ".";
|
|
3
4
|
import { COLUMN } from "../../constants";
|
|
4
|
-
import { isEmpty, _get } from "../../general";
|
|
5
|
+
import { isEmpty, _get, _hasProperty } from "../../general";
|
|
5
6
|
import { FILTER_VALIDATOR_VALUE } from "../constants";
|
|
6
|
-
import { getFilterid, getUIValues, isNullValidator } from "../helpers";
|
|
7
|
+
import { getFilterid, getUIValues, isNullValidator, } from "../helpers";
|
|
7
8
|
/**
|
|
8
9
|
* Adapts the Old logic structure (v2.0) to the flattened UI filter Structure.
|
|
9
10
|
* @param logics The old logic structure (v2.0)
|
|
@@ -16,75 +17,88 @@ export function logicToFlatUI(logics = []) {
|
|
|
16
17
|
logics.forEach(scopeItem => {
|
|
17
18
|
if (scopeItem.filters.length > 0) {
|
|
18
19
|
scopeItem.filters.forEach(filterItem => {
|
|
19
|
-
filterItem.expressions
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (index === -1 && (!uiExtras.nullValues || expression.validationType !== "IS_EMPTY" /* IS_NULL */)) {
|
|
24
|
-
const scopeid = scopeItem.scope !== "GLOBAL" /* GLOBAL */ ? _get(scopeItem, 'uiExtras.scopeid') : undefined;
|
|
25
|
-
const info = !isEmpty(uiExtras.info) ? { icon: uiExtras.info.icon, label: uiExtras.info.label } : undefined;
|
|
26
|
-
const uFilter = {
|
|
27
|
-
collapsed: uiExtras.collapsed,
|
|
28
|
-
column: {
|
|
29
|
-
id: (_a = uiExtras.column) === null || _a === void 0 ? void 0 : _a.id,
|
|
30
|
-
formulaType: (_b = uiExtras.column) === null || _b === void 0 ? void 0 : _b.formulaType,
|
|
31
|
-
linkid: (_c = uiExtras.column) === null || _c === void 0 ? void 0 : _c.linkid,
|
|
32
|
-
linked: (_d = uiExtras.column) === null || _d === void 0 ? void 0 : _d.linked,
|
|
33
|
-
qrveyid: (_e = uiExtras.column) === null || _e === void 0 ? void 0 : _e.qrveyid,
|
|
34
|
-
aggregate: (_g = (_f = uiExtras.column) === null || _f === void 0 ? void 0 : _f.aggregate) === null || _g === void 0 ? void 0 : _g.label,
|
|
35
|
-
calculation: (_j = (_h = uiExtras.column) === null || _h === void 0 ? void 0 : _h.calculation) === null || _j === void 0 ? void 0 : _j.value,
|
|
36
|
-
label: (_k = uiExtras.column) === null || _k === void 0 ? void 0 : _k.text,
|
|
37
|
-
property: uiExtras.column.property,
|
|
38
|
-
sorting: uiExtras.column.sorting,
|
|
39
|
-
outputFormat: (_l = uiExtras.column) === null || _l === void 0 ? void 0 : _l.outputFormat,
|
|
40
|
-
type: (_m = uiExtras.column) === null || _m === void 0 ? void 0 : _m.type,
|
|
41
|
-
},
|
|
42
|
-
dateSection: uiExtras.dateSection,
|
|
43
|
-
displayed: true,
|
|
44
|
-
enabled: expression.enabled,
|
|
45
|
-
extras: Object.assign(Object.assign({}, uiExtras.extras), { panelid: uiExtras.panelid, filterLabel: uiExtras.panelName, info,
|
|
46
|
-
scopeid, scope: scopeItem.scope, section: uiExtras.section, scopeInfo: {
|
|
47
|
-
collapsed: (_o = scopeItem.uiExtras) === null || _o === void 0 ? void 0 : _o.collapsed,
|
|
48
|
-
enabled: scopeItem.enabled,
|
|
49
|
-
displayed: true,
|
|
50
|
-
scope: scopeItem.scope,
|
|
51
|
-
scopeid,
|
|
52
|
-
}, dataset: {
|
|
53
|
-
collapsed: false,
|
|
54
|
-
enabled: true,
|
|
55
|
-
displayed: true,
|
|
56
|
-
qrveyid: (_p = uiExtras.column) === null || _p === void 0 ? void 0 : _p.qrveyid,
|
|
57
|
-
label: (_r = (_q = uiExtras.column) === null || _q === void 0 ? void 0 : _q.dataset) === null || _r === void 0 ? void 0 : _r.name,
|
|
58
|
-
linkid: (_s = uiExtras.column) === null || _s === void 0 ? void 0 : _s.linkid,
|
|
59
|
-
} }),
|
|
60
|
-
filterid: undefined,
|
|
61
|
-
lookupDisplayIndex: uiExtras.lookupDisplayIndex,
|
|
62
|
-
nullValues: uiExtras.nullValues,
|
|
63
|
-
operator: uiExtras.operator,
|
|
64
|
-
property: uiExtras.property,
|
|
65
|
-
uiValues: getUIValues(uiExtras),
|
|
66
|
-
validator: uiExtras.validator,
|
|
67
|
-
values: getValues(uiExtras),
|
|
68
|
-
};
|
|
69
|
-
uFilter.filterid = getFilterid(uFilter);
|
|
70
|
-
uFilters.push(uFilter);
|
|
71
|
-
}
|
|
72
|
-
if (uiExtras.column.type === COLUMN.RANKING && isEmpty(uiExtras.column.aggregate)) {
|
|
73
|
-
// Restore uiExtras.values array into single IFilterDetail object values array
|
|
74
|
-
if (index > -1)
|
|
75
|
-
uFilters[index].values.push(uiExtras.values[0]);
|
|
76
|
-
const refinedRankingValues = refineRankingValues((index > -1 ? uFilters[index].values : uiExtras.values), uiExtras.uiValue);
|
|
77
|
-
if (index > -1)
|
|
78
|
-
uFilters[index].values = refinedRankingValues;
|
|
79
|
-
else
|
|
80
|
-
uFilters[uFilters.length - 1].values = refinedRankingValues;
|
|
81
|
-
}
|
|
20
|
+
filterItem.expressions.forEach((expression1) => {
|
|
21
|
+
_hasProperty(expression1, 'expressions') ? expression1.expressions.forEach((expression2) => {
|
|
22
|
+
buildFilterByExpression(expression2, scopeItem, uFilters);
|
|
23
|
+
}) : buildFilterByExpression(expression1, scopeItem, uFilters);
|
|
82
24
|
});
|
|
25
|
+
// (filterItem.expressions[0].expressions as OLD_IFilterExpression[]).forEach((expression: OLD_IFilterExpression) => {
|
|
26
|
+
// buildFilterByExpression(expression, scopeItem, uFilters);
|
|
27
|
+
// });
|
|
83
28
|
});
|
|
84
29
|
}
|
|
85
30
|
});
|
|
86
31
|
return uFilters;
|
|
87
32
|
}
|
|
33
|
+
function buildFilterByExpression(expression, scopeItem, uFilters) {
|
|
34
|
+
const uiExtras = expression.uiExtras;
|
|
35
|
+
const index = uiExtras.column.type === COLUMN.RANKING ? getFilter(uFilters, expression.uiExtras, true) : -1;
|
|
36
|
+
if (index === -1 && (!uiExtras.nullValues || expression.validationType !== "IS_EMPTY" /* IS_NULL */)) {
|
|
37
|
+
const uFilter = getFilterByExpression(expression, scopeItem);
|
|
38
|
+
uFilter.filterid = getFilterid(uFilter);
|
|
39
|
+
uFilters.push(uFilter);
|
|
40
|
+
}
|
|
41
|
+
if (uiExtras.column.type === COLUMN.RANKING && isEmpty(uiExtras.column.aggregate)) {
|
|
42
|
+
// Restore uiExtras.values array into single IFilterDetail object values array
|
|
43
|
+
if (index > -1)
|
|
44
|
+
uFilters[index].values.push(uiExtras.values[0]);
|
|
45
|
+
const refinedRankingValues = refineRankingValues((index > -1 ? uFilters[index].values : uiExtras.values), uiExtras.uiValue);
|
|
46
|
+
if (index > -1)
|
|
47
|
+
uFilters[index].values = refinedRankingValues;
|
|
48
|
+
else
|
|
49
|
+
uFilters[uFilters.length - 1].values = refinedRankingValues;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function getFilterByExpression(expression, scopeItem) {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
54
|
+
const uiExtras = expression.uiExtras;
|
|
55
|
+
const scopeid = scopeItem.scope !== "GLOBAL" /* GLOBAL */ ? _get(scopeItem, 'uiExtras.scopeid') : undefined;
|
|
56
|
+
const info = !isEmpty(uiExtras.info) ? { icon: uiExtras.info.icon, label: uiExtras.info.label } : undefined;
|
|
57
|
+
const property = adaptDateGroupingProperty(uiExtras.property);
|
|
58
|
+
return {
|
|
59
|
+
collapsed: uiExtras.collapsed,
|
|
60
|
+
column: {
|
|
61
|
+
id: (_a = uiExtras.column) === null || _a === void 0 ? void 0 : _a.id,
|
|
62
|
+
formulaType: (_b = uiExtras.column) === null || _b === void 0 ? void 0 : _b.formulaType,
|
|
63
|
+
linkid: (_c = uiExtras.column) === null || _c === void 0 ? void 0 : _c.linkid,
|
|
64
|
+
linked: (_d = uiExtras.column) === null || _d === void 0 ? void 0 : _d.linked,
|
|
65
|
+
qrveyid: (_e = uiExtras.column) === null || _e === void 0 ? void 0 : _e.qrveyid,
|
|
66
|
+
aggregate: (_g = (_f = uiExtras.column) === null || _f === void 0 ? void 0 : _f.aggregate) === null || _g === void 0 ? void 0 : _g.label,
|
|
67
|
+
calculation: (_j = (_h = uiExtras.column) === null || _h === void 0 ? void 0 : _h.calculation) === null || _j === void 0 ? void 0 : _j.value,
|
|
68
|
+
label: (_k = uiExtras.column) === null || _k === void 0 ? void 0 : _k.text,
|
|
69
|
+
property: uiExtras.column.property,
|
|
70
|
+
sorting: uiExtras.column.sorting,
|
|
71
|
+
outputFormat: (_l = uiExtras.column) === null || _l === void 0 ? void 0 : _l.outputFormat,
|
|
72
|
+
type: (_m = uiExtras.column) === null || _m === void 0 ? void 0 : _m.type,
|
|
73
|
+
},
|
|
74
|
+
dateSection: uiExtras.dateSection,
|
|
75
|
+
displayed: true,
|
|
76
|
+
enabled: expression.enabled,
|
|
77
|
+
extras: Object.assign(Object.assign({}, uiExtras.extras), { panelid: uiExtras.panelid, filterLabel: uiExtras.panelName, info,
|
|
78
|
+
scopeid, scope: scopeItem.scope, section: uiExtras.section, scopeInfo: {
|
|
79
|
+
collapsed: (_o = scopeItem.uiExtras) === null || _o === void 0 ? void 0 : _o.collapsed,
|
|
80
|
+
enabled: scopeItem.enabled,
|
|
81
|
+
displayed: true,
|
|
82
|
+
scope: scopeItem.scope,
|
|
83
|
+
scopeid,
|
|
84
|
+
}, dataset: {
|
|
85
|
+
collapsed: false,
|
|
86
|
+
enabled: true,
|
|
87
|
+
displayed: true,
|
|
88
|
+
qrveyid: (_p = uiExtras.column) === null || _p === void 0 ? void 0 : _p.qrveyid,
|
|
89
|
+
label: (_r = (_q = uiExtras.column) === null || _q === void 0 ? void 0 : _q.dataset) === null || _r === void 0 ? void 0 : _r.name,
|
|
90
|
+
linkid: (_s = uiExtras.column) === null || _s === void 0 ? void 0 : _s.linkid,
|
|
91
|
+
} }),
|
|
92
|
+
filterid: undefined,
|
|
93
|
+
lookupDisplayIndex: uiExtras.lookupDisplayIndex,
|
|
94
|
+
nullValues: uiExtras.nullValues,
|
|
95
|
+
operator: uiExtras.operator,
|
|
96
|
+
property,
|
|
97
|
+
uiValues: getUIValues(uiExtras),
|
|
98
|
+
validator: uiExtras.validator,
|
|
99
|
+
values: getValues(uiExtras),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
88
102
|
function getValues(uiExtras) {
|
|
89
103
|
if (isNullValidator(uiExtras.validator) && isEmpty(uiExtras.values)) {
|
|
90
104
|
return [{ value: FILTER_VALIDATOR_VALUE[uiExtras.validator].label, enabled: uiExtras.uiValue[0].enabled != null ? uiExtras.uiValue[0].enabled : true }];
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { adaptDateGroupingProperty } from "../..";
|
|
1
2
|
import { isEmpty } from "../../../general";
|
|
2
3
|
import { isDateColumn } from "../../../qrvey/isDateColumn";
|
|
3
|
-
import { arePropertiesDateP } from "../common";
|
|
4
4
|
/**
|
|
5
5
|
* Gets a group value for the backend logic structure
|
|
6
6
|
* @param filter The filter
|
|
7
7
|
* @returns a property
|
|
8
8
|
*/
|
|
9
9
|
export function getBackendGroupValue(filter) {
|
|
10
|
-
if (
|
|
11
|
-
|
|
10
|
+
if (isEmpty(filter.column.aggregate) && isDateColumn(filter.column) && filter.property != null) {
|
|
11
|
+
const property = adaptDateGroupingProperty(filter.property);
|
|
12
|
+
return property;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { COLUMN } from "../../../constants";
|
|
2
2
|
import { isEmpty } from "../../../general";
|
|
3
3
|
import { isDateColumn } from "../../../qrvey/isDateColumn";
|
|
4
|
-
import {
|
|
4
|
+
import { isNullValidator } from "../common";
|
|
5
5
|
/**
|
|
6
6
|
* Gets a property for the logic structure
|
|
7
7
|
* @param filter The filter
|
|
8
8
|
* @returns a property
|
|
9
9
|
*/
|
|
10
10
|
export function getBackendProperty(filter) {
|
|
11
|
-
var _a;
|
|
12
11
|
if (isEmpty(filter.column.aggregate)) {
|
|
13
|
-
if (isNullValidator(filter.validator)) {
|
|
12
|
+
if (isNullValidator(filter.validator) || isDateColumn(filter.column)) {
|
|
14
13
|
return undefined;
|
|
15
14
|
}
|
|
16
|
-
else if (isDateColumn(filter.column)) {
|
|
17
|
-
return arePropertiesDateP(filter.column, filter.property) ? (_a = filter.property) === null || _a === void 0 ? void 0 : _a.split('p&')[1] : undefined;
|
|
18
|
-
}
|
|
19
15
|
else if (filter.column.type === COLUMN.EXPRESSION && filter.property != null) {
|
|
20
16
|
return undefined;
|
|
21
17
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IFSFilter, IFUFilter } from "../..";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the label of the filter property
|
|
4
|
+
* @param filter The UI Filter
|
|
5
|
+
* @returns a string of the filter property label
|
|
6
|
+
*/
|
|
7
|
+
export declare function getFilterPropertyLabel(filter: IFUFilter | IFSFilter): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { getPropertyLabel } from "../../..";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the label of the filter property
|
|
4
|
+
* @param filter The UI Filter
|
|
5
|
+
* @returns a string of the filter property label
|
|
6
|
+
*/
|
|
7
|
+
export function getFilterPropertyLabel(filter) {
|
|
8
|
+
return getPropertyLabel(filter.column, filter.property);
|
|
9
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './excludeUIFiltersByAggregate';
|
|
2
2
|
export * from './excludeUIFlatFiltersByScopes';
|
|
3
|
+
export * from './getFilterPropertyLabel';
|
|
3
4
|
export * from './getOutputFormatByColumn';
|
|
4
5
|
export * from './getUIFlatFilterByParams';
|
|
5
6
|
export * from './getUIFlatFiltersByParams';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './excludeUIFiltersByAggregate';
|
|
2
2
|
export * from './excludeUIFlatFiltersByScopes';
|
|
3
|
+
export * from './getFilterPropertyLabel';
|
|
3
4
|
export * from './getOutputFormatByColumn';
|
|
4
5
|
export * from './getUIFlatFilterByParams';
|
|
5
6
|
export * from './getUIFlatFiltersByParams';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Filters a nested tree array by a custom condition on the
|
|
2
|
+
* Filters a nested tree array by a custom condition on the last child node
|
|
3
|
+
* - If the given arguments are not valid, the function returns the first argument.
|
|
4
|
+
* - If the childArrKey is not matched in the object, the condition tries to resolve the filter anyway and returns an empty array.
|
|
5
|
+
* - If the condition is not fulfilled, the function returns a filtered array, probably a empty array inside of the child array
|
|
3
6
|
* @param arr nested tree array
|
|
4
7
|
* @param childArrKey property representing the children array on the nested tree
|
|
5
8
|
* @param condition function callback that determines if the filter is applied on the last child node of the nested tree
|
|
6
9
|
* @returns array filtered
|
|
7
10
|
*/
|
|
8
|
-
export declare function filterNestedTree(arr
|
|
11
|
+
export declare function filterNestedTree<T = any>(arr?: T[], childArrKey?: string, condition?: any): T[];
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { isEmpty } from "../mix";
|
|
2
2
|
import { cloneDeep } from "../object/cloneDeep";
|
|
3
3
|
/**
|
|
4
|
-
* Filters a nested tree array by a custom condition on the
|
|
4
|
+
* Filters a nested tree array by a custom condition on the last child node
|
|
5
|
+
* - If the given arguments are not valid, the function returns the first argument.
|
|
6
|
+
* - If the childArrKey is not matched in the object, the condition tries to resolve the filter anyway and returns an empty array.
|
|
7
|
+
* - If the condition is not fulfilled, the function returns a filtered array, probably a empty array inside of the child array
|
|
5
8
|
* @param arr nested tree array
|
|
6
9
|
* @param childArrKey property representing the children array on the nested tree
|
|
7
10
|
* @param condition function callback that determines if the filter is applied on the last child node of the nested tree
|
|
8
11
|
* @returns array filtered
|
|
9
12
|
*/
|
|
10
|
-
export function filterNestedTree(arr, childArrKey, condition) {
|
|
11
|
-
if (
|
|
12
|
-
return
|
|
13
|
+
export function filterNestedTree(arr = [], childArrKey = '', condition = undefined) {
|
|
14
|
+
if (!isValid(arr, childArrKey, condition))
|
|
15
|
+
return arr;
|
|
13
16
|
return cloneDeep(arr).filter(obj => {
|
|
14
|
-
const hasChildArr = Array.isArray(obj[childArrKey]) && obj[childArrKey].length;
|
|
17
|
+
const hasChildArr = Array.isArray(obj[childArrKey]) && obj[childArrKey].length > 0;
|
|
15
18
|
if (hasChildArr)
|
|
16
19
|
obj[childArrKey] = filterNestedTree(obj[childArrKey], childArrKey, condition);
|
|
17
20
|
return hasChildArr || condition(obj);
|
|
18
21
|
});
|
|
19
22
|
}
|
|
23
|
+
function isValid(arr = [], childArrKey = '', condition = undefined) {
|
|
24
|
+
return (!isEmpty(arr) && Array.isArray(arr))
|
|
25
|
+
&& (!isEmpty(childArrKey) && typeof childArrKey === 'string')
|
|
26
|
+
&& (!isEmpty(condition) && typeof condition === "function");
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the `toStringTag` of `value`.
|
|
3
|
+
*
|
|
4
|
+
* @param {*} value The value to query.
|
|
5
|
+
* @returns {string} Returns the `toStringTag`.
|
|
6
|
+
*/
|
|
7
|
+
export function getTag(value) {
|
|
8
|
+
if (value == null) {
|
|
9
|
+
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
10
|
+
}
|
|
11
|
+
return Object.prototype.toString.call(value);
|
|
12
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getTag } from ".";
|
|
2
|
+
import { isObject } from "..";
|
|
1
3
|
/**
|
|
2
4
|
* Validates if the given argument is empty
|
|
3
5
|
* @param variable the given variable
|
|
@@ -5,11 +7,13 @@
|
|
|
5
7
|
* @returns true: the given argument is empty; false: is not.
|
|
6
8
|
*/
|
|
7
9
|
export function isEmpty(variable, includeFalsy = false) {
|
|
8
|
-
return
|
|
9
|
-
|| variable == null
|
|
10
|
+
return variable == null
|
|
10
11
|
|| (typeof variable == 'number' && includeFalsy && (Number(variable) === 0 || Object.is(variable, -0) || isNaN(variable)))
|
|
11
|
-
|| (typeof variable == 'string' && variable ===
|
|
12
|
+
|| (typeof variable == 'string' && variable.length === 0)
|
|
12
13
|
|| (typeof variable == 'boolean' && includeFalsy && variable === false)
|
|
13
14
|
|| (Array.isArray(variable) && variable.length === 0)
|
|
14
|
-
|| (variable
|
|
15
|
+
|| ((getTag(variable) === '[object Map]' || getTag(variable) === '[object Set]') && variable.size === 0)
|
|
16
|
+
|| (variable instanceof Date && isNaN(variable.valueOf()))
|
|
17
|
+
|| (typeof variable === 'function' && Object.prototype.toString.call(variable).indexOf("Function") === 0)
|
|
18
|
+
|| ((!(variable instanceof Date) && typeof variable !== 'function') && isObject(variable) && Object.entries(variable).length === 0);
|
|
15
19
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Creates a random string
|
|
3
|
+
* - If the first given argument is different than a length number, the variable is replaced by a default number
|
|
4
|
+
* - If the optional second given argument is passed the random string is permutated.
|
|
3
5
|
* @param {Number} length size of the generated string. Default 8
|
|
4
|
-
* @
|
|
6
|
+
* @param {Array} exclude collection of strings that is going to be excluded of the random string.
|
|
7
|
+
* @return {String} Random string
|
|
5
8
|
*/
|
|
6
|
-
export declare function randomId(
|
|
9
|
+
export declare function randomId(length?: number, exclude?: string[]): string;
|