@qrvey/filters 0.0.44 → 0.1.0
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 +63 -1
- package/dist/cjs/classes/FilterAdapter.js +1 -80
- package/dist/cjs/classes/FilterBuilder.js +33 -251
- package/dist/cjs/classes/FilterManager.js +7 -64
- package/dist/cjs/classes/FilterResources.js +3 -116
- package/dist/cjs/classes/FilterSearcher.js +0 -77
- package/dist/cjs/classes/FilterValidation.js +0 -93
- package/dist/cjs/classes/FilterValues.js +0 -24
- package/dist/cjs/classes/index.js +8 -21
- package/dist/cjs/helpers/filter-adapt.helpers.js +3 -46
- package/dist/cjs/helpers/filter-adapt.legacy.helpers.js +6 -53
- package/dist/cjs/helpers/filter-adapt.logic.helpers.js +7 -128
- package/dist/cjs/helpers/filter-builder.helpers.js +1 -8
- package/dist/cjs/helpers/filter-settings.helpers.js +6 -41
- package/dist/cjs/helpers/filter-validators.helpers.js +15 -9
- package/dist/cjs/helpers/filter-verbose.helpers.js +211 -0
- package/dist/cjs/helpers/getAggregateFilters.js +11 -0
- package/dist/cjs/helpers/getFilterId.js +1 -17
- package/dist/cjs/helpers/getFilterType.js +1 -8
- package/dist/cjs/helpers/index.js +12 -20
- package/dist/cjs/helpers/isDateDistinctGrouping.js +15 -0
- package/dist/cjs/helpers/isRankingFilter.js +10 -0
- package/dist/cjs/helpers/resolveFilterConditions.js +2 -10
- package/dist/cjs/helpers/utils.helpers.js +2 -19
- package/dist/cjs/index.js +5 -18
- package/dist/cjs/models/index.js +4 -17
- package/dist/cjs/resources/filter-grouping.resources.js +0 -18
- package/dist/cjs/resources/filter-logic.resources.js +0 -3
- package/dist/cjs/resources/filter-scopes.resources.js +10 -27
- package/dist/cjs/resources/filter-validators.resources.js +0 -3
- package/dist/cjs/resources/filter-verbose.resources.js +13 -0
- package/dist/cjs/resources/filters.resources.js +0 -12
- package/dist/cjs/resources/index.js +12 -24
- package/dist/classes/FilterAdapter.d.ts +0 -80
- package/dist/classes/FilterAdapter.js +1 -80
- package/dist/classes/FilterBuilder.d.ts +2 -177
- package/dist/classes/FilterBuilder.js +33 -251
- package/dist/classes/FilterManager.d.ts +7 -62
- package/dist/classes/FilterManager.js +7 -64
- package/dist/classes/FilterResources.d.ts +1 -115
- package/dist/classes/FilterResources.js +3 -116
- package/dist/classes/FilterSearcher.d.ts +2 -77
- package/dist/classes/FilterSearcher.js +0 -77
- package/dist/classes/FilterValidation.d.ts +1 -47
- package/dist/classes/FilterValidation.js +0 -93
- package/dist/classes/FilterValues.d.ts +0 -25
- package/dist/classes/FilterValues.js +0 -24
- package/dist/classes/index.d.ts +0 -1
- package/dist/helpers/filter-adapt.helpers.d.ts +0 -15
- package/dist/helpers/filter-adapt.helpers.js +1 -43
- package/dist/helpers/filter-adapt.legacy.helpers.d.ts +0 -20
- package/dist/helpers/filter-adapt.legacy.helpers.js +3 -49
- package/dist/helpers/filter-adapt.logic.helpers.d.ts +0 -22
- package/dist/helpers/filter-adapt.logic.helpers.js +3 -123
- package/dist/helpers/filter-builder.helpers.d.ts +0 -7
- package/dist/helpers/filter-builder.helpers.js +0 -6
- package/dist/helpers/filter-settings.helpers.d.ts +0 -35
- package/dist/helpers/filter-settings.helpers.js +0 -34
- package/dist/helpers/filter-validators.helpers.d.ts +3 -6
- package/dist/helpers/filter-validators.helpers.js +11 -7
- package/dist/helpers/filter-verbose.helpers.d.ts +6 -0
- package/dist/helpers/filter-verbose.helpers.js +206 -0
- package/dist/helpers/getAggregateFilters.d.ts +3 -0
- package/dist/helpers/getAggregateFilters.js +7 -0
- package/dist/helpers/getFilterId.d.ts +0 -16
- package/dist/helpers/getFilterId.js +0 -15
- package/dist/helpers/getFilterType.d.ts +0 -7
- package/dist/helpers/getFilterType.js +0 -6
- package/dist/helpers/index.d.ts +5 -1
- package/dist/helpers/index.js +5 -0
- package/dist/helpers/isDateDistinctGrouping.d.ts +2 -0
- package/dist/helpers/isDateDistinctGrouping.js +12 -0
- package/dist/helpers/isRankingFilter.d.ts +2 -0
- package/dist/helpers/isRankingFilter.js +7 -0
- package/dist/helpers/resolveFilterConditions.d.ts +0 -8
- package/dist/helpers/resolveFilterConditions.js +1 -8
- package/dist/helpers/utils.helpers.d.ts +0 -17
- package/dist/helpers/utils.helpers.js +0 -16
- package/dist/index.d.ts +0 -1
- package/dist/models/filter-builder.models.d.ts +0 -156
- package/dist/models/filter-resources.models.d.ts +0 -53
- package/dist/models/filter-searcher.models.d.ts +5 -34
- package/dist/models/filter-validation.models.d.ts +0 -40
- package/dist/models/index.d.ts +0 -1
- package/dist/resources/filter-functions.resources.d.ts +0 -49
- package/dist/resources/filter-grouping.resources.d.ts +0 -7
- package/dist/resources/filter-grouping.resources.js +0 -18
- package/dist/resources/filter-logic.resources.d.ts +0 -79
- package/dist/resources/filter-logic.resources.js +0 -3
- package/dist/resources/filter-operators.resources.d.ts +0 -1
- package/dist/resources/filter-panel.interfaces.d.ts +0 -49
- package/dist/resources/filter-scopes.resources.d.ts +2 -25
- package/dist/resources/filter-scopes.resources.js +10 -27
- package/dist/resources/filter-validation.resources.d.ts +0 -1
- package/dist/resources/filter-validators.resources.d.ts +0 -1
- package/dist/resources/filter-validators.resources.js +0 -3
- package/dist/resources/filter-values.resources.d.ts +0 -13
- package/dist/resources/filter-verbose.resources.d.ts +23 -0
- package/dist/resources/filter-verbose.resources.js +10 -0
- package/dist/resources/filter-visual.resources.d.ts +0 -50
- package/dist/resources/filters.resources.d.ts +1 -102
- package/dist/resources/filters.resources.js +0 -12
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +1 -0
- package/package.json +59 -44
- package/.eslintignore +0 -6
- package/.eslintrc.json +0 -122
- package/.husky/pre-commit +0 -4
- package/.lintstagedrc +0 -7
- package/.prettierignore +0 -6
- package/.prettierrc.json +0 -1
- package/CHANGELOG.md +0 -268
- package/CODE_OF_CONDUCT.md +0 -132
- package/bitbucket-pipelines.yml +0 -92
- package/dist/cjs/classes/FilterAdapter.d.ts +0 -107
- package/dist/cjs/classes/FilterAdapter.d.ts.map +0 -1
- package/dist/cjs/classes/FilterBuilder.d.ts +0 -206
- package/dist/cjs/classes/FilterBuilder.d.ts.map +0 -1
- package/dist/cjs/classes/FilterManager.d.ts +0 -84
- package/dist/cjs/classes/FilterManager.d.ts.map +0 -1
- package/dist/cjs/classes/FilterResources.d.ts +0 -139
- package/dist/cjs/classes/FilterResources.d.ts.map +0 -1
- package/dist/cjs/classes/FilterSearcher.d.ts +0 -90
- package/dist/cjs/classes/FilterSearcher.d.ts.map +0 -1
- package/dist/cjs/classes/FilterValidation.d.ts +0 -58
- package/dist/cjs/classes/FilterValidation.d.ts.map +0 -1
- package/dist/cjs/classes/FilterValues.d.ts +0 -33
- package/dist/cjs/classes/FilterValues.d.ts.map +0 -1
- package/dist/cjs/classes/index.d.ts +0 -8
- package/dist/cjs/classes/index.d.ts.map +0 -1
- package/dist/cjs/helpers/filter-adapt.helpers.d.ts +0 -21
- package/dist/cjs/helpers/filter-adapt.helpers.d.ts.map +0 -1
- package/dist/cjs/helpers/filter-adapt.legacy.helpers.d.ts +0 -26
- package/dist/cjs/helpers/filter-adapt.legacy.helpers.d.ts.map +0 -1
- package/dist/cjs/helpers/filter-adapt.logic.helpers.d.ts +0 -29
- package/dist/cjs/helpers/filter-adapt.logic.helpers.d.ts.map +0 -1
- package/dist/cjs/helpers/filter-builder.helpers.d.ts +0 -11
- package/dist/cjs/helpers/filter-builder.helpers.d.ts.map +0 -1
- package/dist/cjs/helpers/filter-settings.helpers.d.ts +0 -42
- package/dist/cjs/helpers/filter-settings.helpers.d.ts.map +0 -1
- package/dist/cjs/helpers/filter-validators.helpers.d.ts +0 -8
- package/dist/cjs/helpers/filter-validators.helpers.d.ts.map +0 -1
- package/dist/cjs/helpers/getFilterId.d.ts +0 -18
- package/dist/cjs/helpers/getFilterId.d.ts.map +0 -1
- package/dist/cjs/helpers/getFilterType.d.ts +0 -11
- package/dist/cjs/helpers/getFilterType.d.ts.map +0 -1
- package/dist/cjs/helpers/index.d.ts +0 -7
- package/dist/cjs/helpers/index.d.ts.map +0 -1
- package/dist/cjs/helpers/resolveFilterConditions.d.ts +0 -11
- package/dist/cjs/helpers/resolveFilterConditions.d.ts.map +0 -1
- package/dist/cjs/helpers/utils.helpers.d.ts +0 -26
- package/dist/cjs/helpers/utils.helpers.d.ts.map +0 -1
- package/dist/cjs/index.d.ts +0 -5
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/models/filter-builder.models.d.ts +0 -203
- package/dist/cjs/models/filter-builder.models.d.ts.map +0 -1
- package/dist/cjs/models/filter-resources.models.d.ts +0 -71
- package/dist/cjs/models/filter-resources.models.d.ts.map +0 -1
- package/dist/cjs/models/filter-searcher.models.d.ts +0 -42
- package/dist/cjs/models/filter-searcher.models.d.ts.map +0 -1
- package/dist/cjs/models/filter-validation.models.d.ts +0 -59
- package/dist/cjs/models/filter-validation.models.d.ts.map +0 -1
- package/dist/cjs/models/index.d.ts +0 -4
- package/dist/cjs/models/index.d.ts.map +0 -1
- package/dist/cjs/resources/filter-functions.resources.d.ts +0 -94
- package/dist/cjs/resources/filter-functions.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filter-grouping.resources.d.ts +0 -103
- package/dist/cjs/resources/filter-grouping.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filter-logic.resources.d.ts +0 -135
- package/dist/cjs/resources/filter-logic.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filter-operators.resources.d.ts +0 -16
- package/dist/cjs/resources/filter-operators.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filter-panel.interfaces.d.ts +0 -80
- package/dist/cjs/resources/filter-panel.interfaces.d.ts.map +0 -1
- package/dist/cjs/resources/filter-scopes.resources.d.ts +0 -62
- package/dist/cjs/resources/filter-scopes.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filter-validation.resources.d.ts +0 -20
- package/dist/cjs/resources/filter-validation.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filter-validators.resources.d.ts +0 -80
- package/dist/cjs/resources/filter-validators.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filter-values.resources.d.ts +0 -40
- package/dist/cjs/resources/filter-values.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filter-visual.resources.d.ts +0 -77
- package/dist/cjs/resources/filter-visual.resources.d.ts.map +0 -1
- package/dist/cjs/resources/filters.resources.d.ts +0 -168
- package/dist/cjs/resources/filters.resources.d.ts.map +0 -1
- package/dist/cjs/resources/index.d.ts +0 -11
- package/dist/cjs/resources/index.d.ts.map +0 -1
- package/dist/classes/FilterAdapter.d.ts.map +0 -1
- package/dist/classes/FilterBuilder.d.ts.map +0 -1
- package/dist/classes/FilterManager.d.ts.map +0 -1
- package/dist/classes/FilterResources.d.ts.map +0 -1
- package/dist/classes/FilterSearcher.d.ts.map +0 -1
- package/dist/classes/FilterValidation.d.ts.map +0 -1
- package/dist/classes/FilterValues.d.ts.map +0 -1
- package/dist/classes/index.d.ts.map +0 -1
- package/dist/helpers/filter-adapt.helpers.d.ts.map +0 -1
- package/dist/helpers/filter-adapt.legacy.helpers.d.ts.map +0 -1
- package/dist/helpers/filter-adapt.logic.helpers.d.ts.map +0 -1
- package/dist/helpers/filter-builder.helpers.d.ts.map +0 -1
- package/dist/helpers/filter-settings.helpers.d.ts.map +0 -1
- package/dist/helpers/filter-validators.helpers.d.ts.map +0 -1
- package/dist/helpers/getFilterId.d.ts.map +0 -1
- package/dist/helpers/getFilterType.d.ts.map +0 -1
- package/dist/helpers/index.d.ts.map +0 -1
- package/dist/helpers/resolveFilterConditions.d.ts.map +0 -1
- package/dist/helpers/utils.helpers.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/models/filter-builder.models.d.ts.map +0 -1
- package/dist/models/filter-resources.models.d.ts.map +0 -1
- package/dist/models/filter-searcher.models.d.ts.map +0 -1
- package/dist/models/filter-validation.models.d.ts.map +0 -1
- package/dist/models/index.d.ts.map +0 -1
- package/dist/resources/filter-functions.resources.d.ts.map +0 -1
- package/dist/resources/filter-grouping.resources.d.ts.map +0 -1
- package/dist/resources/filter-logic.resources.d.ts.map +0 -1
- package/dist/resources/filter-operators.resources.d.ts.map +0 -1
- package/dist/resources/filter-panel.interfaces.d.ts.map +0 -1
- package/dist/resources/filter-scopes.resources.d.ts.map +0 -1
- package/dist/resources/filter-validation.resources.d.ts.map +0 -1
- package/dist/resources/filter-validators.resources.d.ts.map +0 -1
- package/dist/resources/filter-values.resources.d.ts.map +0 -1
- package/dist/resources/filter-visual.resources.d.ts.map +0 -1
- package/dist/resources/filters.resources.d.ts.map +0 -1
- package/dist/resources/index.d.ts.map +0 -1
- package/jest.config.js +0 -10
- package/jsdoc.config.json +0 -14
- package/scripts/clean-build/index.js +0 -62
- package/sonar-project.properties +0 -2
- package/src/classes/FilterAdapter.ts +0 -208
- package/src/classes/FilterBuilder.ts +0 -821
- package/src/classes/FilterManager.ts +0 -126
- package/src/classes/FilterResources.ts +0 -411
- package/src/classes/FilterSearcher.ts +0 -243
- package/src/classes/FilterValidation.ts +0 -221
- package/src/classes/FilterValues.ts +0 -89
- package/src/classes/index.ts +0 -7
- package/src/helpers/filter-adapt.helpers.ts +0 -204
- package/src/helpers/filter-adapt.legacy.helpers.ts +0 -298
- package/src/helpers/filter-adapt.logic.helpers.ts +0 -631
- package/src/helpers/filter-builder.helpers.ts +0 -28
- package/src/helpers/filter-settings.helpers.ts +0 -133
- package/src/helpers/filter-validators.helpers.ts +0 -15
- package/src/helpers/getFilterId.ts +0 -35
- package/src/helpers/getFilterType.ts +0 -23
- package/src/helpers/index.ts +0 -6
- package/src/helpers/resolveFilterConditions.ts +0 -29
- package/src/helpers/utils.helpers.ts +0 -37
- package/src/index.ts +0 -4
- package/src/models/filter-builder.models.ts +0 -256
- package/src/models/filter-resources.models.ts +0 -89
- package/src/models/filter-searcher.models.ts +0 -61
- package/src/models/filter-validation.models.ts +0 -71
- package/src/models/index.ts +0 -3
- package/src/resources/filter-functions.resources.ts +0 -132
- package/src/resources/filter-grouping.resources.ts +0 -531
- package/src/resources/filter-logic.resources.ts +0 -148
- package/src/resources/filter-operators.resources.ts +0 -40
- package/src/resources/filter-panel.interfaces.ts +0 -86
- package/src/resources/filter-scopes.resources.ts +0 -152
- package/src/resources/filter-validation.resources.ts +0 -90
- package/src/resources/filter-validators.resources.ts +0 -411
- package/src/resources/filter-values.resources.ts +0 -57
- package/src/resources/filter-visual.resources.ts +0 -86
- package/src/resources/filters.resources.ts +0 -232
- package/src/resources/index.ts +0 -10
- package/tests/classes/FilterAdapter.test.ts +0 -124
- package/tests/classes/FilterBuilder.test.ts +0 -903
- package/tests/classes/FilterResources.test.ts +0 -267
- package/tests/classes/FilterSearcher.test.ts +0 -188
- package/tests/classes/FilterValidation.test.ts +0 -54
- package/tests/helpers/getFilterId.test.ts +0 -121
- package/tests/mock/datasets.mock.ts +0 -61
- package/tests/mock/filters-adapter.mock.ts +0 -646
- package/tests/mock/filters-interactive-table.mock.ts +0 -59
- package/tests/mock/filters.mock.ts +0 -277
- package/tsconfig.doc.json +0 -4
- package/tsconfig.eslint.json +0 -4
- package/tsconfig.json +0 -113
|
@@ -1,64 +1,7 @@
|
|
|
1
1
|
import { getFilterType } from "../helpers/getFilterType";
|
|
2
2
|
import { FILTER_GROUPING_COLUMNS, FILTER_GROUPING_VALIDATORS, } from "../resources/filter-grouping.resources";
|
|
3
3
|
import { FILTER_TYPE } from "../resources/filters.resources";
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
4
|
export class FilterValidation {
|
|
8
|
-
// /**
|
|
9
|
-
// *
|
|
10
|
-
// * @param filter
|
|
11
|
-
// */
|
|
12
|
-
// filter(filter: IFilter): IFilterValidationSingleError {
|
|
13
|
-
// const errors: IFilterValidationError[] = [];
|
|
14
|
-
// if (isEmpty(filter) || !isObject(filter))
|
|
15
|
-
// errors.push({ type: FILTER_VALIDATION.EMPTY_FILTER });
|
|
16
|
-
// return {
|
|
17
|
-
// infoErrors: getInfoErrors(errors),
|
|
18
|
-
// errors,
|
|
19
|
-
// };
|
|
20
|
-
// }
|
|
21
|
-
// /**
|
|
22
|
-
// *
|
|
23
|
-
// * @param filter
|
|
24
|
-
// * @param values
|
|
25
|
-
// */
|
|
26
|
-
// static values(
|
|
27
|
-
// filter: IFilter,
|
|
28
|
-
// values: IFilterInputValue[],
|
|
29
|
-
// ): IFilterValidationSingleError {
|
|
30
|
-
// const errors: IFilterValidationError[] = [];
|
|
31
|
-
// if (isEmpty(filter)) errors.push({ type: FILTER_VALIDATION.EMPTY_FILTER });
|
|
32
|
-
// const { columnType, validator, values: filterValues } = filter;
|
|
33
|
-
// const filterType = getFilterType(columnType, validator);
|
|
34
|
-
// switch (filterType) {
|
|
35
|
-
// case FILTER_TYPE.NULL:
|
|
36
|
-
// if (!isEmpty(filterValues) || !isEmpty(values))
|
|
37
|
-
// errors.push({ type: FILTER_VALIDATION.EMPTY_FILTER });
|
|
38
|
-
// break;
|
|
39
|
-
// case FILTER_TYPE.RANGE:
|
|
40
|
-
// if (isEmpty(values))
|
|
41
|
-
// errors.push({ type: FILTER_VALIDATION.NOT_EMPTY_VALUES });
|
|
42
|
-
// else if (values)
|
|
43
|
-
// FilterValidation.rangeValues(filter, values)
|
|
44
|
-
// default:
|
|
45
|
-
// break;
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
// private static rangeValues(filter: IFilter, values: IFilterInputValueRange[]): IFilterValidationSingleError {
|
|
49
|
-
// const errors: IFilterValidationError[] = [];
|
|
50
|
-
// filter.validator
|
|
51
|
-
// FILTER_VALIDATOR.
|
|
52
|
-
// values.forEach(value => {
|
|
53
|
-
// if (value.max
|
|
54
|
-
// });
|
|
55
|
-
// }
|
|
56
|
-
/**
|
|
57
|
-
* Validated if the given filter exists into the filter collection
|
|
58
|
-
* @param filters the collection of filters
|
|
59
|
-
* @param filter the filter to validate
|
|
60
|
-
* @returns True when the filter is duplicated in the collection
|
|
61
|
-
*/
|
|
62
5
|
static isDuplicated(filters, filter) {
|
|
63
6
|
if (!Array.isArray(filters))
|
|
64
7
|
return false;
|
|
@@ -73,12 +16,6 @@ export class FilterValidation {
|
|
|
73
16
|
_filter.validator === filter.validator &&
|
|
74
17
|
FilterValidation.isFilterValueDuplicated(_filter, filter));
|
|
75
18
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Validates if the given regular value is duplicated with another value collection
|
|
78
|
-
* @param filter1 the filter info
|
|
79
|
-
* @param filter2 the filter info to compare
|
|
80
|
-
* @returns true when the value is duplicated
|
|
81
|
-
*/
|
|
82
19
|
static isFilterValueDuplicated(filter1, filter2) {
|
|
83
20
|
const filterType1 = getFilterType(filter1.columnType, filter1.validator);
|
|
84
21
|
const filterType2 = getFilterType(filter2.columnType, filter2.validator);
|
|
@@ -95,52 +32,22 @@ export class FilterValidation {
|
|
|
95
32
|
return this.isFilterRegularValueDuplicated(filter1.values, filter2.values);
|
|
96
33
|
}
|
|
97
34
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Validates if the given regular value is duplicated with another value collection
|
|
100
|
-
* @param values1 the filter regular values collection
|
|
101
|
-
* @param values2 the filter regular values collection
|
|
102
|
-
* @returns true when the regular value is duplicated
|
|
103
|
-
*/
|
|
104
35
|
static isFilterRegularValueDuplicated(values1, values2) {
|
|
105
36
|
return values1.every((value1) => values2.some((value2) => value1.id === value2.id && value1.value === value2.value));
|
|
106
37
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Validates if the given range value is duplicated with another value collection
|
|
109
|
-
* @param values1 the filter range values collection
|
|
110
|
-
* @param values2 the filter range values colleciton
|
|
111
|
-
* @returns true when the range value is duplicated
|
|
112
|
-
*/
|
|
113
38
|
static isFilterRangeValueDuplicated(values1, values2) {
|
|
114
39
|
return values1.every((value1) => values2.some((value2) => value1.id === value2.id &&
|
|
115
40
|
value1.max === value2.max &&
|
|
116
41
|
value1.min === value2.min));
|
|
117
42
|
}
|
|
118
|
-
/**
|
|
119
|
-
* Validates if the given relative value is duplicated with another value collection
|
|
120
|
-
* @param values1 the filter relative values collection
|
|
121
|
-
* @param values2 the filter relative values collection
|
|
122
|
-
* @returns true when the relative value is duplicated
|
|
123
|
-
*/
|
|
124
43
|
static isFilterRelativeValueDuplicated(values1, values2) {
|
|
125
44
|
return values1.every((value1) => values2.some((value2) => value1.id === value2.id &&
|
|
126
45
|
value1.cursor === value2.cursor &&
|
|
127
46
|
value1.unit === value2.unit));
|
|
128
47
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Validates if the given ranking value is duplicated with another value collection
|
|
131
|
-
* @param _values1 the filter ranking values collection
|
|
132
|
-
* @param _values2 the filter ranking values collection
|
|
133
|
-
* @returns true when the ranking value is duplicated
|
|
134
|
-
*/
|
|
135
48
|
static isFilterRankingValueDuplicated(_values1, _values2) {
|
|
136
49
|
return false;
|
|
137
50
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Validates if the grouping is valid to set for the given params
|
|
140
|
-
* @param columnType the column type
|
|
141
|
-
* @param validator the filter validator
|
|
142
|
-
* @returns true when the grouping is valid
|
|
143
|
-
*/
|
|
144
51
|
static isGroupingValid(columnType, validator) {
|
|
145
52
|
return (FILTER_GROUPING_COLUMNS.includes(columnType) &&
|
|
146
53
|
FILTER_GROUPING_VALIDATORS.includes(validator));
|
|
@@ -1,33 +1,8 @@
|
|
|
1
1
|
import { IFilterInputValue, IFilterInputValueRange, IFilterInputValueRegular, IFilterInputValueRelativeDate, IFilterValueRange, IFilterValueRegular, IFilterValueRelativeDate } from "../resources/filter-values.resources";
|
|
2
2
|
import { IFilterType } from "../resources/filters.resources";
|
|
3
|
-
/**
|
|
4
|
-
* Class to manipulate filter values and input values
|
|
5
|
-
*/
|
|
6
3
|
export declare class FilterValues {
|
|
7
|
-
/**
|
|
8
|
-
* Gets the Filter Values based on Regular Input values
|
|
9
|
-
* @param values the regular input values
|
|
10
|
-
* @returns the Filter Regular Values
|
|
11
|
-
*/
|
|
12
4
|
static getFilterRegularValues(values?: IFilterInputValueRegular[]): IFilterValueRegular[];
|
|
13
|
-
/**
|
|
14
|
-
* Gets the Filter Values based on Range Input values
|
|
15
|
-
* @param values the range input values
|
|
16
|
-
* @returns the Filter Range Values
|
|
17
|
-
*/
|
|
18
5
|
static getFilterRangeValues(values?: IFilterInputValueRange[]): IFilterValueRange[];
|
|
19
|
-
/**
|
|
20
|
-
* Gets the Filter Values based on Relative Input values
|
|
21
|
-
* @param values the relative range input value
|
|
22
|
-
* @returns the Filter Relative Value
|
|
23
|
-
*/
|
|
24
6
|
static getFilterRelativeValues(values?: IFilterInputValueRelativeDate[]): IFilterValueRelativeDate[];
|
|
25
|
-
/**
|
|
26
|
-
* Gets the Filter Values based on the flter type
|
|
27
|
-
* @param filterType the filter type
|
|
28
|
-
* @param values the input values
|
|
29
|
-
* @returns the Filter Values
|
|
30
|
-
*/
|
|
31
7
|
static getFilterValues(filterType: IFilterType, values?: IFilterInputValue[]): IFilterValueRegular[];
|
|
32
8
|
}
|
|
33
|
-
//# sourceMappingURL=FilterValues.d.ts.map
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { FILTER_TYPE } from "../resources/filters.resources";
|
|
2
|
-
/**
|
|
3
|
-
* Class to manipulate filter values and input values
|
|
4
|
-
*/
|
|
5
2
|
export class FilterValues {
|
|
6
|
-
/**
|
|
7
|
-
* Gets the Filter Values based on Regular Input values
|
|
8
|
-
* @param values the regular input values
|
|
9
|
-
* @returns the Filter Regular Values
|
|
10
|
-
*/
|
|
11
3
|
static getFilterRegularValues(values = []) {
|
|
12
4
|
return values.map((value) => ({
|
|
13
5
|
displayed: true,
|
|
@@ -15,11 +7,6 @@ export class FilterValues {
|
|
|
15
7
|
value: `${value}`,
|
|
16
8
|
}));
|
|
17
9
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Gets the Filter Values based on Range Input values
|
|
20
|
-
* @param values the range input values
|
|
21
|
-
* @returns the Filter Range Values
|
|
22
|
-
*/
|
|
23
10
|
static getFilterRangeValues(values = []) {
|
|
24
11
|
return values.map((value) => ({
|
|
25
12
|
displayed: true,
|
|
@@ -28,11 +15,6 @@ export class FilterValues {
|
|
|
28
15
|
min: value.min,
|
|
29
16
|
}));
|
|
30
17
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Gets the Filter Values based on Relative Input values
|
|
33
|
-
* @param values the relative range input value
|
|
34
|
-
* @returns the Filter Relative Value
|
|
35
|
-
*/
|
|
36
18
|
static getFilterRelativeValues(values = []) {
|
|
37
19
|
return values.map((value) => ({
|
|
38
20
|
displayed: true,
|
|
@@ -40,12 +22,6 @@ export class FilterValues {
|
|
|
40
22
|
...value,
|
|
41
23
|
}));
|
|
42
24
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Gets the Filter Values based on the flter type
|
|
45
|
-
* @param filterType the filter type
|
|
46
|
-
* @param values the input values
|
|
47
|
-
* @returns the Filter Values
|
|
48
|
-
*/
|
|
49
25
|
static getFilterValues(filterType, values = []) {
|
|
50
26
|
switch (filterType) {
|
|
51
27
|
case FILTER_TYPE.REGULAR:
|
package/dist/classes/index.d.ts
CHANGED
|
@@ -2,20 +2,5 @@ import { IDataset } from "@qrvey/utils";
|
|
|
2
2
|
import { IFilterPanelInteractiveTable } from "../resources/filter-panel.interfaces";
|
|
3
3
|
import { IFilterVisual } from "../resources/filter-visual.resources";
|
|
4
4
|
import { IFilter } from "../resources/filters.resources";
|
|
5
|
-
/**
|
|
6
|
-
* Generates a visual filter structure from the filter collection.
|
|
7
|
-
* @param filters Array of filters
|
|
8
|
-
* @param datasets Array of the dataset info
|
|
9
|
-
* @param interactiveTable table of interaction properties for each section
|
|
10
|
-
* @returns a Filter Data structure
|
|
11
|
-
*/
|
|
12
5
|
export declare function filterToVisual(filters: IFilter[], datasets?: IDataset[], interactiveTable?: IFilterPanelInteractiveTable): IFilterVisual | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Gets the Interactive Table object from the visual filters
|
|
15
|
-
* If an interactive table object is given, it will be merged with the new one
|
|
16
|
-
* @param visual the visual filters
|
|
17
|
-
* @param interactiveTable the interactive table object
|
|
18
|
-
* @returns the interactive table object
|
|
19
|
-
*/
|
|
20
6
|
export declare function legacyVisualToInteractiveTable(visual: IFilterVisual, interactiveTable?: IFilterPanelInteractiveTable): IFilterPanelInteractiveTable | undefined;
|
|
21
|
-
//# sourceMappingURL=filter-adapt.helpers.d.ts.map
|
|
@@ -2,13 +2,6 @@ import { isEmpty } from "@qrvey/utils";
|
|
|
2
2
|
import { getColumnInfo, getDatasetInfo } from "./utils.helpers";
|
|
3
3
|
import { DEFAULT_UI_FILTER, } from "../resources/filter-visual.resources";
|
|
4
4
|
import { DEFAULT_FILTER } from "../resources/filters.resources";
|
|
5
|
-
/**
|
|
6
|
-
* Generates a visual filter structure from the filter collection.
|
|
7
|
-
* @param filters Array of filters
|
|
8
|
-
* @param datasets Array of the dataset info
|
|
9
|
-
* @param interactiveTable table of interaction properties for each section
|
|
10
|
-
* @returns a Filter Data structure
|
|
11
|
-
*/
|
|
12
5
|
export function filterToVisual(filters, datasets = [], interactiveTable) {
|
|
13
6
|
if (isEmpty(filters) || !Array.isArray(filters))
|
|
14
7
|
return;
|
|
@@ -16,13 +9,6 @@ export function filterToVisual(filters, datasets = [], interactiveTable) {
|
|
|
16
9
|
scopes: buildScopes(filters, datasets, interactiveTable),
|
|
17
10
|
};
|
|
18
11
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Gets the Interactive Table object from the visual filters
|
|
21
|
-
* If an interactive table object is given, it will be merged with the new one
|
|
22
|
-
* @param visual the visual filters
|
|
23
|
-
* @param interactiveTable the interactive table object
|
|
24
|
-
* @returns the interactive table object
|
|
25
|
-
*/
|
|
26
12
|
export function legacyVisualToInteractiveTable(visual, interactiveTable) {
|
|
27
13
|
if (isEmpty(visual) || isEmpty(visual?.scopes))
|
|
28
14
|
return;
|
|
@@ -54,16 +40,7 @@ export function legacyVisualToInteractiveTable(visual, interactiveTable) {
|
|
|
54
40
|
delete newInteractiveTable.interactDatasets;
|
|
55
41
|
return newInteractiveTable;
|
|
56
42
|
}
|
|
57
|
-
|
|
58
|
-
* Gets a collection of scopes for the visual filter data.
|
|
59
|
-
* The scopes are organized by scope types and IDs
|
|
60
|
-
* Also, adds and organizes filters by datasets
|
|
61
|
-
* @param filters Collection of filters
|
|
62
|
-
* @param datasets Array of the dataset info
|
|
63
|
-
* @param interactiveTable table of interaction properties for each section
|
|
64
|
-
* @returns an array of visual scopes.
|
|
65
|
-
*/
|
|
66
|
-
function buildScopes(filters = [], datasets = [], interactiveTable) {
|
|
43
|
+
function buildScopes(filters, datasets, interactiveTable) {
|
|
67
44
|
return filters.reduce((scopes, filter) => {
|
|
68
45
|
const datasetInfo = getDatasetInfo({ columnId: filter.columnId, datasetId: filter.datasetId }, datasets);
|
|
69
46
|
const uiFilter = buildFilter(filter, datasetInfo);
|
|
@@ -88,12 +65,6 @@ function buildScopes(filters = [], datasets = [], interactiveTable) {
|
|
|
88
65
|
return scopes;
|
|
89
66
|
}, []);
|
|
90
67
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Gets an scope structure for the filter data
|
|
93
|
-
* @param filter the filter
|
|
94
|
-
* @param interactiveTable table of interaction properties for each section
|
|
95
|
-
* @returns the visual scope structure
|
|
96
|
-
*/
|
|
97
68
|
function buildScope(filter, interactiveTable) {
|
|
98
69
|
const { collapsed } = interactiveTable?.interactScopes?.find((interactive) => interactive.scope === filter.scope &&
|
|
99
70
|
interactive.scopeId === filter.scopeId) ?? {};
|
|
@@ -104,13 +75,6 @@ function buildScope(filter, interactiveTable) {
|
|
|
104
75
|
id: filter.scopeId,
|
|
105
76
|
};
|
|
106
77
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Gets an dataset structure for the visual filter
|
|
109
|
-
* @param filter the filter
|
|
110
|
-
* @param dataset the dataset info
|
|
111
|
-
* @param interactiveTable table of interaction properties for each section
|
|
112
|
-
* @returns an dataset structure
|
|
113
|
-
*/
|
|
114
78
|
function buildDataset(filter, dataset, interactiveTable) {
|
|
115
79
|
const { collapsed } = interactiveTable?.interactDatasets?.find((interactive) => interactive.datasetId === filter.datasetId) ?? {};
|
|
116
80
|
return {
|
|
@@ -120,12 +84,6 @@ function buildDataset(filter, dataset, interactiveTable) {
|
|
|
120
84
|
filters: [],
|
|
121
85
|
};
|
|
122
86
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Gets an filter structure for the visual filter
|
|
125
|
-
* @param filter a UI structure filter
|
|
126
|
-
* @param dataset the dataset info
|
|
127
|
-
* @returns an filter structure
|
|
128
|
-
*/
|
|
129
87
|
function buildFilter(filter, dataset) {
|
|
130
88
|
const columnInfo = dataset == null
|
|
131
89
|
? undefined
|
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
import { IDataset, IFUData } from "@qrvey/utils";
|
|
2
2
|
import { IFilterPanelInteractiveTable } from "../resources/filter-panel.interfaces";
|
|
3
3
|
import { IFilter } from "../resources/filters.resources";
|
|
4
|
-
/**
|
|
5
|
-
* Generates a legacy visual filter structure from the filter collection.
|
|
6
|
-
* @param filters Array of filters
|
|
7
|
-
* @param datasets Array of the dataset info
|
|
8
|
-
* @param interactiveTable table of interaction properties for each section
|
|
9
|
-
* @returns a Filter Data structure
|
|
10
|
-
*/
|
|
11
4
|
export declare function filterToLegacyVisual(filters: IFilter[], datasets?: IDataset[], interactiveTable?: IFilterPanelInteractiveTable): IFUData | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Generates a legacy visual filter structure from the filter collection.
|
|
14
|
-
* @param filterData the legacy filter
|
|
15
|
-
* @returns a Filter collection
|
|
16
|
-
*/
|
|
17
5
|
export declare function legacyVisualToFilter(filterData: IFUData): IFilter[];
|
|
18
|
-
/**
|
|
19
|
-
* Gets the Interactive Table object from the legacy visual filters
|
|
20
|
-
* If an interactive table object is given, it will be merged with the new one
|
|
21
|
-
* @param legacyVisual the legacy visual filters
|
|
22
|
-
* @param interactiveTable the interactive table object
|
|
23
|
-
* @returns the interactive table object
|
|
24
|
-
*/
|
|
25
6
|
export declare function legacyVisualToInteractiveTable(legacyVisual: IFUData, interactiveTable?: IFilterPanelInteractiveTable): IFilterPanelInteractiveTable | undefined;
|
|
26
|
-
//# sourceMappingURL=filter-adapt.legacy.helpers.d.ts.map
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { FILTER_SCOPE, FILTER_SECTION, isEmpty, } from "@qrvey/utils";
|
|
2
2
|
import { getColumnInfo, getDatasetInfo } from "./utils.helpers";
|
|
3
3
|
import { FilterBuilder } from "../classes/FilterBuilder";
|
|
4
|
-
/**
|
|
5
|
-
* Generates a legacy visual filter structure from the filter collection.
|
|
6
|
-
* @param filters Array of filters
|
|
7
|
-
* @param datasets Array of the dataset info
|
|
8
|
-
* @param interactiveTable table of interaction properties for each section
|
|
9
|
-
* @returns a Filter Data structure
|
|
10
|
-
*/
|
|
11
4
|
export function filterToLegacyVisual(filters, datasets = [], interactiveTable) {
|
|
12
5
|
if (isEmpty(filters))
|
|
13
6
|
return;
|
|
@@ -18,11 +11,6 @@ export function filterToLegacyVisual(filters, datasets = [], interactiveTable) {
|
|
|
18
11
|
scopes: buildLegacyScopes(filters, datasets, interactiveTable),
|
|
19
12
|
};
|
|
20
13
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Generates a legacy visual filter structure from the filter collection.
|
|
23
|
-
* @param filterData the legacy filter
|
|
24
|
-
* @returns a Filter collection
|
|
25
|
-
*/
|
|
26
14
|
export function legacyVisualToFilter(filterData) {
|
|
27
15
|
if (isEmpty(filterData) || isEmpty(filterData?.scopes))
|
|
28
16
|
return [];
|
|
@@ -64,13 +52,6 @@ export function legacyVisualToFilter(filterData) {
|
|
|
64
52
|
});
|
|
65
53
|
return filters;
|
|
66
54
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Gets the Interactive Table object from the legacy visual filters
|
|
69
|
-
* If an interactive table object is given, it will be merged with the new one
|
|
70
|
-
* @param legacyVisual the legacy visual filters
|
|
71
|
-
* @param interactiveTable the interactive table object
|
|
72
|
-
* @returns the interactive table object
|
|
73
|
-
*/
|
|
74
55
|
export function legacyVisualToInteractiveTable(legacyVisual, interactiveTable) {
|
|
75
56
|
if (isEmpty(legacyVisual) || isEmpty(legacyVisual?.scopes))
|
|
76
57
|
return;
|
|
@@ -102,16 +83,7 @@ export function legacyVisualToInteractiveTable(legacyVisual, interactiveTable) {
|
|
|
102
83
|
delete newInteractiveTable.interactDatasets;
|
|
103
84
|
return newInteractiveTable;
|
|
104
85
|
}
|
|
105
|
-
|
|
106
|
-
* Gets a collection of legacy scopes for the legacy visual filters.
|
|
107
|
-
* The scopes are organized by scope types and IDs
|
|
108
|
-
* Also, adds and organizes filters by datasets
|
|
109
|
-
* @param filters Collection of filters
|
|
110
|
-
* @param datasets Array of the dataset info
|
|
111
|
-
* @param interactiveTable table of interaction properties for each section
|
|
112
|
-
* @returns an array of visual scopes.
|
|
113
|
-
*/
|
|
114
|
-
function buildLegacyScopes(filters = [], datasets = [], interactiveTable) {
|
|
86
|
+
function buildLegacyScopes(filters, datasets, interactiveTable) {
|
|
115
87
|
return filters.reduce((scopes, filter) => {
|
|
116
88
|
const datasetInfo = getDatasetInfo({ columnId: filter.columnId, datasetId: filter.datasetId }, datasets);
|
|
117
89
|
const uiFilter = buildLegacyFilter(filter, datasetInfo);
|
|
@@ -136,12 +108,6 @@ function buildLegacyScopes(filters = [], datasets = [], interactiveTable) {
|
|
|
136
108
|
return scopes;
|
|
137
109
|
}, []);
|
|
138
110
|
}
|
|
139
|
-
/**
|
|
140
|
-
* Gets an legacy scope structure for the legacy filter data
|
|
141
|
-
* @param filter the filter
|
|
142
|
-
* @param interactiveTable table of interaction properties for each section
|
|
143
|
-
* @returns the legacy visual scope structure
|
|
144
|
-
*/
|
|
145
111
|
function buildLegacyScope(filter, interactiveTable) {
|
|
146
112
|
const { collapsed } = interactiveTable?.interactScopes?.find((interactive) => interactive.scope === filter.scope &&
|
|
147
113
|
interactive.scopeId === filter.scopeId) ?? {};
|
|
@@ -154,13 +120,6 @@ function buildLegacyScope(filter, interactiveTable) {
|
|
|
154
120
|
scopeid: filter.scopeId,
|
|
155
121
|
};
|
|
156
122
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Gets an legacy dataset structure for the legacy visual filter
|
|
159
|
-
* @param filter the filter
|
|
160
|
-
* @param dataset the dataset info
|
|
161
|
-
* @param interactiveTable table of interaction properties for each section
|
|
162
|
-
* @returns an legacy dataset structure
|
|
163
|
-
*/
|
|
164
123
|
function buildLegacyDataset(filter, dataset, interactiveTable) {
|
|
165
124
|
const { collapsed } = interactiveTable?.interactDatasets?.find((interactive) => interactive.datasetId === filter.datasetId &&
|
|
166
125
|
interactive.scope === filter.scope &&
|
|
@@ -174,22 +133,17 @@ function buildLegacyDataset(filter, dataset, interactiveTable) {
|
|
|
174
133
|
filters: [],
|
|
175
134
|
};
|
|
176
135
|
}
|
|
177
|
-
/**
|
|
178
|
-
* Gets an legacy filter structure for the legacy visual filter
|
|
179
|
-
* @param filter a UI structure filter
|
|
180
|
-
* @param dataset the dataset info
|
|
181
|
-
* @returns an legacy filter structure
|
|
182
|
-
*/
|
|
183
136
|
function buildLegacyFilter(filter, dataset) {
|
|
184
137
|
const columnInfo = dataset == null
|
|
185
138
|
? undefined
|
|
186
139
|
: getColumnInfo({ columnId: filter.columnId, datasetId: filter.datasetId }, [dataset]);
|
|
140
|
+
const columnLabel = columnInfo?.label ?? "";
|
|
187
141
|
return {
|
|
188
142
|
collapsed: filter.collapsed ?? false,
|
|
189
143
|
column: {
|
|
190
144
|
id: filter.columnId,
|
|
191
145
|
formulaType: columnInfo?.formulaType,
|
|
192
|
-
label:
|
|
146
|
+
label: columnLabel,
|
|
193
147
|
qrveyid: filter.datasetId,
|
|
194
148
|
aggregate: filter.aggregateType,
|
|
195
149
|
type: filter.columnType,
|
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
import { IFilterLogic, IFilterLogicExpression, IFilterLogicExpressionValue } from "../resources/filter-logic.resources";
|
|
2
2
|
import { IFilterUI, IFilterVisual } from "../resources/filter-visual.resources";
|
|
3
3
|
import { IFilter } from "../resources/filters.resources";
|
|
4
|
-
/**
|
|
5
|
-
* Generates a Logic structure from the filter collection
|
|
6
|
-
* @param filters the filter collection
|
|
7
|
-
* @returns the logic structure
|
|
8
|
-
*/
|
|
9
4
|
export declare function filterToLogic(filters: IFilter[]): IFilterLogic[];
|
|
10
|
-
/**
|
|
11
|
-
* Generates a Logic structure from the visual filter structure
|
|
12
|
-
* @param visual the visual filter structure
|
|
13
|
-
* @returns the logic structure
|
|
14
|
-
*/
|
|
15
5
|
export declare function visualToLogic(visual: IFilterVisual): IFilterLogic[];
|
|
16
|
-
/**
|
|
17
|
-
* Builds filter expression by the filter data.
|
|
18
|
-
* - If the resulting value array is empty the enabled property will be false.
|
|
19
|
-
* @param filter The filter to transform
|
|
20
|
-
* @returns a filter expression
|
|
21
|
-
*/
|
|
22
6
|
export declare function buildLogicExpression(filter: IFilterUI): IFilterLogicExpression;
|
|
23
|
-
/**
|
|
24
|
-
* Gets the expresion values in the logic format
|
|
25
|
-
* @param filter The filter structure
|
|
26
|
-
* @returns A collection of backend expression value
|
|
27
|
-
*/
|
|
28
7
|
export declare function getFilterLogicValues(filter: IFilterUI): IFilterLogicExpressionValue[];
|
|
29
|
-
//# sourceMappingURL=filter-adapt.logic.helpers.d.ts.map
|