@qrvey/filters 0.0.29 → 0.0.31
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/CHANGELOG.md +12 -0
- package/dist/cjs/classes/FilterBuilder.d.ts +8 -5
- package/dist/cjs/classes/FilterBuilder.d.ts.map +1 -1
- package/dist/cjs/classes/FilterBuilder.js +39 -17
- package/dist/cjs/classes/FilterSearcher.d.ts +15 -2
- package/dist/cjs/classes/FilterSearcher.d.ts.map +1 -1
- package/dist/cjs/classes/FilterSearcher.js +47 -1
- package/dist/cjs/helpers/filter-settings.helpers.d.ts.map +1 -1
- package/dist/cjs/helpers/filter-settings.helpers.js +1 -0
- package/dist/cjs/models/filter-builder.models.d.ts +9 -7
- package/dist/cjs/models/filter-builder.models.d.ts.map +1 -1
- package/dist/cjs/resources/filter-functions.resources.d.ts +12 -1
- package/dist/cjs/resources/filter-functions.resources.d.ts.map +1 -1
- package/dist/classes/FilterBuilder.d.ts +8 -5
- package/dist/classes/FilterBuilder.d.ts.map +1 -1
- package/dist/classes/FilterBuilder.js +40 -18
- package/dist/classes/FilterSearcher.d.ts +15 -2
- package/dist/classes/FilterSearcher.d.ts.map +1 -1
- package/dist/classes/FilterSearcher.js +48 -2
- package/dist/helpers/filter-settings.helpers.d.ts.map +1 -1
- package/dist/helpers/filter-settings.helpers.js +1 -0
- package/dist/models/filter-builder.models.d.ts +9 -7
- package/dist/models/filter-builder.models.d.ts.map +1 -1
- package/dist/resources/filter-functions.resources.d.ts +12 -1
- package/dist/resources/filter-functions.resources.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/classes/FilterBuilder.ts +51 -21
- package/src/classes/FilterSearcher.ts +76 -3
- package/src/helpers/filter-settings.helpers.ts +1 -0
- package/src/models/filter-builder.models.ts +10 -6
- package/src/resources/filter-functions.resources.ts +11 -1
- package/tests/classes/FilterBuilder.test.ts +79 -10
- package/tests/classes/FilterSearcher.test.ts +50 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,20 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [v0.0.31](https://bitbucket.org/qrvey/qrvey_filters/compare/v0.0.31..v0.0.30)
|
|
8
|
+
|
|
9
|
+
- fix: :bug: fixed the ordering filters by scope, datasets and columns [`#8`](https://bitbucket.org/qrvey/qrvey_filters/pull-requests/8)
|
|
10
|
+
|
|
11
|
+
#### [v0.0.30](https://bitbucket.org/qrvey/qrvey_filters/compare/v0.0.30..v0.0.29)
|
|
12
|
+
|
|
13
|
+
> 19 February 2025
|
|
14
|
+
|
|
15
|
+
- fix: added new config to order the given filters manually [`#7`](https://bitbucket.org/qrvey/qrvey_filters/pull-requests/7)
|
|
16
|
+
|
|
7
17
|
#### [v0.0.29](https://bitbucket.org/qrvey/qrvey_filters/compare/v0.0.29..v0.0.28)
|
|
8
18
|
|
|
19
|
+
> 7 February 2025
|
|
20
|
+
|
|
9
21
|
- fix: adjusted addFilter module to change the operator based on the new criteria [`#6`](https://bitbucket.org/qrvey/qrvey_filters/pull-requests/6)
|
|
10
22
|
- chore :upgraded Qrvey Utils to latest version [`87be141`](https://bitbucket.org/qrvey/qrvey_filters/commits/87be141d628b77607b0daa50e5e5d371a0892650)
|
|
11
23
|
|
|
@@ -25,20 +25,23 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
|
|
|
25
25
|
* Adds various filter into the collection.
|
|
26
26
|
* Inserts them next to the last similar filter
|
|
27
27
|
* @param newFilters the filter to add
|
|
28
|
+
* @param inIndexes collection of indexes to add the new filters
|
|
28
29
|
* @param settings the settings object to setup this function
|
|
29
30
|
* @returns the new collection of filters
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
addMultiple(newFilters: IFilter[], inIndexes?: number[], settings?: IFilterAddSettings): IFilterBuilderMultipleReturn;
|
|
32
33
|
/**
|
|
33
34
|
* Adds one filter into the collection.
|
|
34
35
|
* - Inserts it next to the last similar filter
|
|
35
36
|
* - If the new one is match with the last similar filter, the operator will change to OR
|
|
36
37
|
* - If the id is not provided, a new one is created.
|
|
38
|
+
* - If the inIndex nunber is provided, this will be the index where the filter is inserted
|
|
37
39
|
* @param filter the filter to add
|
|
40
|
+
* @param inIndex the index to add the new filter
|
|
38
41
|
* @param settings settings object to setup this function
|
|
39
42
|
* @returns the new collection of filters
|
|
40
43
|
*/
|
|
41
|
-
addSingle(filter: IFilter, settings?: IFilterAddSettings): IFilterBuilderSingleReturn;
|
|
44
|
+
addSingle(filter: IFilter, inIndex?: number, settings?: IFilterAddSettings): IFilterBuilderSingleReturn;
|
|
42
45
|
/**
|
|
43
46
|
* Adds one value from filter
|
|
44
47
|
* @param id the ID to search the filter to add value
|
|
@@ -70,7 +73,7 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
|
|
|
70
73
|
* @param ids a collection of ID to search filters to remove
|
|
71
74
|
* @returns the new filter collection
|
|
72
75
|
*/
|
|
73
|
-
|
|
76
|
+
deleteMultiple(ids: string[]): IFilterBuilderMultipleReturn;
|
|
74
77
|
/**
|
|
75
78
|
* Removes one filter from the collection
|
|
76
79
|
* @param id the ID to search the filter to remove
|
|
@@ -103,7 +106,7 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
|
|
|
103
106
|
* @param settings settings object for the function
|
|
104
107
|
* @returns the new filter collection
|
|
105
108
|
*/
|
|
106
|
-
|
|
109
|
+
editMultiple(ids: string[], filters: Partial<IFilter>[], settings?: IFilterBuilderEditSettings): IFilterBuilderMultipleReturn;
|
|
107
110
|
/**
|
|
108
111
|
* Edits one filter from the collection
|
|
109
112
|
* @param id the ID to search the filter to edit
|
|
@@ -146,7 +149,7 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
|
|
|
146
149
|
* @param settings the settings object to setup this function
|
|
147
150
|
* @returns the new filter collection
|
|
148
151
|
*/
|
|
149
|
-
|
|
152
|
+
mergeMultiple(filters: IFilter[], settings?: IFilterMergeSettings): IFilterBuilderMultipleReturn;
|
|
150
153
|
/**
|
|
151
154
|
* Merge values from filter
|
|
152
155
|
* @param id the ID to search the filter to merge values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilder.d.ts","sourceRoot":"","sources":["../../../src/classes/FilterBuilder.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,
|
|
1
|
+
{"version":3,"file":"FilterBuilder.d.ts","sourceRoot":"","sources":["../../../src/classes/FilterBuilder.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EAErB,oBAAoB,EACpB,oBAAoB,EACpB,2BAA2B,EAC5B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,YAAY,EAIb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAGL,OAAO,EACR,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,qBAAa,aACX,YACE,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB;IAWP,SAAS,CAAC,OAAO,EAA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37,18 @@ class FilterBuilder {
|
|
|
37
37
|
* Adds various filter into the collection.
|
|
38
38
|
* Inserts them next to the last similar filter
|
|
39
39
|
* @param newFilters the filter to add
|
|
40
|
+
* @param inIndexes collection of indexes to add the new filters
|
|
40
41
|
* @param settings the settings object to setup this function
|
|
41
42
|
* @returns the new collection of filters
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
addMultiple(newFilters, inIndexes, settings) {
|
|
44
45
|
if ((0, utils_1.isEmpty)(newFilters))
|
|
45
46
|
return { resulting: this.filters };
|
|
46
47
|
const filters = (0, utils_1.objectCopy)(this.filters);
|
|
47
48
|
const affected = [];
|
|
48
49
|
try {
|
|
49
|
-
newFilters.forEach((newFilter) => {
|
|
50
|
-
const affectedFilter = this.addSingle(newFilter, settings);
|
|
50
|
+
newFilters.forEach((newFilter, index) => {
|
|
51
|
+
const affectedFilter = this.addSingle(newFilter, inIndexes?.[index], settings);
|
|
51
52
|
affected.push(affectedFilter.affected);
|
|
52
53
|
});
|
|
53
54
|
}
|
|
@@ -67,11 +68,13 @@ class FilterBuilder {
|
|
|
67
68
|
* - Inserts it next to the last similar filter
|
|
68
69
|
* - If the new one is match with the last similar filter, the operator will change to OR
|
|
69
70
|
* - If the id is not provided, a new one is created.
|
|
71
|
+
* - If the inIndex nunber is provided, this will be the index where the filter is inserted
|
|
70
72
|
* @param filter the filter to add
|
|
73
|
+
* @param inIndex the index to add the new filter
|
|
71
74
|
* @param settings settings object to setup this function
|
|
72
75
|
* @returns the new collection of filters
|
|
73
76
|
*/
|
|
74
|
-
addSingle(filter, settings) {
|
|
77
|
+
addSingle(filter, inIndex, settings) {
|
|
75
78
|
if ((0, utils_1.isEmpty)(filter))
|
|
76
79
|
return { resulting: this.filters };
|
|
77
80
|
if (FilterValidation_1.FilterValidation.isDuplicated(this.filters, filter))
|
|
@@ -81,14 +84,27 @@ class FilterBuilder {
|
|
|
81
84
|
const newSettings = (0, filter_settings_helpers_1.getFilterAddSettings)(settings);
|
|
82
85
|
if ((0, utils_1.isEmpty)(filter.id) || newSettings.automaticId)
|
|
83
86
|
newFilter.id = (0, getFilterId_1.getFilterId)(newFilter);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
let indexResult;
|
|
88
|
+
let nextIndex;
|
|
89
|
+
if ((0, utils_1.isNaNV2)(inIndex)) {
|
|
90
|
+
indexResult = this.searchEngine.findLastIndexByFilter(newFilter, inIndex);
|
|
91
|
+
nextIndex = indexResult.index + 1;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
indexResult = {
|
|
95
|
+
index: inIndex,
|
|
96
|
+
nextToColumnFilter: false,
|
|
97
|
+
nextToDatasetFilter: false,
|
|
98
|
+
nextToScopeFilter: false,
|
|
99
|
+
};
|
|
100
|
+
nextIndex = indexResult.index;
|
|
101
|
+
}
|
|
102
|
+
if (indexResult.index > -1) {
|
|
103
|
+
this.filters.splice(nextIndex, 0, newFilter);
|
|
104
|
+
if (newSettings.automaticOperator &&
|
|
105
|
+
indexResult.nextToColumnFilter &&
|
|
106
|
+
indexResult.index > -1)
|
|
107
|
+
this.filters[indexResult.index].operator = filter_operators_resources_1.FILTER_OPERATOR.OR;
|
|
92
108
|
}
|
|
93
109
|
else {
|
|
94
110
|
this.filters.push(newFilter);
|
|
@@ -177,7 +193,7 @@ class FilterBuilder {
|
|
|
177
193
|
* @param ids a collection of ID to search filters to remove
|
|
178
194
|
* @returns the new filter collection
|
|
179
195
|
*/
|
|
180
|
-
|
|
196
|
+
deleteMultiple(ids) {
|
|
181
197
|
if (!Array.isArray(ids))
|
|
182
198
|
return { resulting: this.filters };
|
|
183
199
|
const filters = (0, utils_1.objectCopy)(this.filters);
|
|
@@ -286,7 +302,7 @@ class FilterBuilder {
|
|
|
286
302
|
* @param settings settings object for the function
|
|
287
303
|
* @returns the new filter collection
|
|
288
304
|
*/
|
|
289
|
-
|
|
305
|
+
editMultiple(ids, filters, settings) {
|
|
290
306
|
if (!Array.isArray(ids) ||
|
|
291
307
|
!Array.isArray(filters) ||
|
|
292
308
|
ids.length !== filters.length)
|
|
@@ -423,7 +439,7 @@ class FilterBuilder {
|
|
|
423
439
|
affected = affectedMergeFilter;
|
|
424
440
|
}
|
|
425
441
|
else {
|
|
426
|
-
const { affected: affectedAddSingle } = this.addSingle(filter, settings);
|
|
442
|
+
const { affected: affectedAddSingle } = this.addSingle(filter, undefined, settings);
|
|
427
443
|
affected = affectedAddSingle;
|
|
428
444
|
}
|
|
429
445
|
return {
|
|
@@ -438,7 +454,7 @@ class FilterBuilder {
|
|
|
438
454
|
* @param settings the settings object to setup this function
|
|
439
455
|
* @returns the new filter collection
|
|
440
456
|
*/
|
|
441
|
-
|
|
457
|
+
mergeMultiple(filters, settings) {
|
|
442
458
|
if (!Array.isArray(filters) || (0, utils_1.isEmpty)(filters))
|
|
443
459
|
return { resulting: this.filters };
|
|
444
460
|
const originalFilters = (0, utils_1.objectCopy)(this.filters);
|
|
@@ -558,8 +574,14 @@ class FilterBuilder {
|
|
|
558
574
|
replaceByParams(filters, params, settings) {
|
|
559
575
|
const original = (0, utils_1.objectCopy)(this.filters);
|
|
560
576
|
const newSettings = (0, filter_settings_helpers_1.getReplaceByParamsSettings)(settings);
|
|
577
|
+
let filterIndexes = undefined;
|
|
578
|
+
if (newSettings.addingInSameIndex) {
|
|
579
|
+
filterIndexes = this.searchEngine.filterIndexesByParams(params, settings);
|
|
580
|
+
if ((0, utils_1.isEmpty)(filterIndexes))
|
|
581
|
+
filterIndexes = undefined;
|
|
582
|
+
}
|
|
561
583
|
this.filters = this.searchEngine.excludeByParams(params, newSettings);
|
|
562
|
-
const resulting = this.
|
|
584
|
+
const resulting = this.addMultiple(filters, filterIndexes, newSettings);
|
|
563
585
|
this.sync();
|
|
564
586
|
return {
|
|
565
587
|
resulting: this.filters,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFilterSearcherParams } from "../models/filter-searcher.models";
|
|
2
|
-
import { IFilterParamSettings } from "../resources/filter-functions.resources";
|
|
2
|
+
import { IFilterFindLastIndexReturn, IFilterParamSettings } from "../resources/filter-functions.resources";
|
|
3
3
|
import { IFilter } from "../resources/filters.resources";
|
|
4
4
|
/**
|
|
5
5
|
* Class to search filters.
|
|
@@ -31,7 +31,7 @@ export declare class FilterSearcher implements IFilterSearcherParams {
|
|
|
31
31
|
*/
|
|
32
32
|
filterByParams(params: Partial<IFilter>, settings?: IFilterParamSettings): IFilter[];
|
|
33
33
|
/**
|
|
34
|
-
* Searchs filters by the given params and returns the
|
|
34
|
+
* Searchs filters by the given params and returns the indexes
|
|
35
35
|
* @param params params to search the filters
|
|
36
36
|
* @param settings settings for this function
|
|
37
37
|
* @returns the new collection of filters
|
|
@@ -53,6 +53,19 @@ export declare class FilterSearcher implements IFilterSearcherParams {
|
|
|
53
53
|
* @returns the new collection of filters
|
|
54
54
|
*/
|
|
55
55
|
findIndexByParams(params: Partial<IFilter>, settings?: IFilterParamSettings): number;
|
|
56
|
+
/**
|
|
57
|
+
* **************************************************************************************************
|
|
58
|
+
**************************************** By Filters *************************************************
|
|
59
|
+
****************************************************************************************************
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Gets an index where the new filter is going to be added
|
|
63
|
+
* If an index is given, the searching is skipped
|
|
64
|
+
* @param newFilter the new filter to add
|
|
65
|
+
* @param index a custom index
|
|
66
|
+
* @returns the index result object
|
|
67
|
+
*/
|
|
68
|
+
findLastIndexByFilter(newFilter: IFilter, index?: number): IFilterFindLastIndexReturn;
|
|
56
69
|
/**
|
|
57
70
|
* **************************************************************************************************
|
|
58
71
|
****************************************** Getters *************************************************
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterSearcher.d.ts","sourceRoot":"","sources":["../../../src/classes/FilterSearcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FilterSearcher.d.ts","sourceRoot":"","sources":["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AAI;CAG5C"}
|
|
@@ -47,7 +47,7 @@ class FilterSearcher {
|
|
|
47
47
|
return this.filters.filter((filter) => (0, resolveFilterConditions_1.resolveFilterConditions)(filter, params, completeSettings));
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
|
-
* Searchs filters by the given params and returns the
|
|
50
|
+
* Searchs filters by the given params and returns the indexes
|
|
51
51
|
* @param params params to search the filters
|
|
52
52
|
* @param settings settings for this function
|
|
53
53
|
* @returns the new collection of filters
|
|
@@ -88,6 +88,52 @@ class FilterSearcher {
|
|
|
88
88
|
return -1;
|
|
89
89
|
return this.filters.findIndex((filter) => (0, resolveFilterConditions_1.resolveFilterConditions)(filter, params, (0, filter_settings_helpers_1.getParamFiltersSettings)(settings)));
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* **************************************************************************************************
|
|
93
|
+
**************************************** By Filters *************************************************
|
|
94
|
+
****************************************************************************************************
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* Gets an index where the new filter is going to be added
|
|
98
|
+
* If an index is given, the searching is skipped
|
|
99
|
+
* @param newFilter the new filter to add
|
|
100
|
+
* @param index a custom index
|
|
101
|
+
* @returns the index result object
|
|
102
|
+
*/
|
|
103
|
+
findLastIndexByFilter(newFilter, index = -1) {
|
|
104
|
+
const result = {
|
|
105
|
+
index: -1,
|
|
106
|
+
nextToColumnFilter: false,
|
|
107
|
+
nextToDatasetFilter: false,
|
|
108
|
+
nextToScopeFilter: false,
|
|
109
|
+
};
|
|
110
|
+
if ((0, utils_1.isEmpty)(newFilter))
|
|
111
|
+
return result;
|
|
112
|
+
const newIndex = (0, utils_1.isNaNV2)(index) ? -1 : index;
|
|
113
|
+
if (this.filters.length <= newIndex)
|
|
114
|
+
return { ...result, index: this.filters.length - 1 };
|
|
115
|
+
if (newIndex > -1)
|
|
116
|
+
return { ...result, index: newIndex };
|
|
117
|
+
// Look index next to Scope - Dataset - column
|
|
118
|
+
let lastIndex = (0, utils_1.getLastIndexFromArray)(this.filters, (aFilter) => aFilter.columnId === newFilter.columnId &&
|
|
119
|
+
aFilter.datasetId === newFilter.datasetId &&
|
|
120
|
+
aFilter.scope === newFilter.scope &&
|
|
121
|
+
aFilter.scopeId === newFilter.scopeId);
|
|
122
|
+
if (lastIndex > -1)
|
|
123
|
+
return { ...result, index: lastIndex, nextToColumnFilter: true };
|
|
124
|
+
// Look index next to Scope - Dataset
|
|
125
|
+
lastIndex = (0, utils_1.getLastIndexFromArray)(this.filters, (aFilter) => aFilter.datasetId === newFilter.datasetId &&
|
|
126
|
+
aFilter.scope === newFilter.scope &&
|
|
127
|
+
aFilter.scopeId === newFilter.scopeId);
|
|
128
|
+
if (lastIndex > -1)
|
|
129
|
+
return { ...result, index: lastIndex, nextToDatasetFilter: true };
|
|
130
|
+
// Look index next to Scope
|
|
131
|
+
lastIndex = (0, utils_1.getLastIndexFromArray)(this.filters, (aFilter) => aFilter.scope === newFilter.scope &&
|
|
132
|
+
aFilter.scopeId === newFilter.scopeId);
|
|
133
|
+
if (lastIndex > -1)
|
|
134
|
+
return { ...result, index: lastIndex, nextToScopeFilter: true };
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
91
137
|
/**
|
|
92
138
|
* **************************************************************************************************
|
|
93
139
|
****************************************** Getters *************************************************
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-settings.helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/filter-settings.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,uCAAuC,EACvC,oBAAoB,EACpB,2BAA2B,EAC5B,MAAM,yCAAyC,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,CAAC,EAAE,0BAA0B,GACpC,0BAA0B,CAQ5B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,kBAAkB,CAQpB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,qBAAqB,CAMvB;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,CAAC,EAAE,uCAAuC,GACjD,uCAAuC,CAkBzC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,oBAAoB,CAYtB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,CAAC,EAAE,2BAA2B,GACrC,2BAA2B,
|
|
1
|
+
{"version":3,"file":"filter-settings.helpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/filter-settings.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,EACrB,uCAAuC,EACvC,oBAAoB,EACpB,2BAA2B,EAC5B,MAAM,yCAAyC,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,CAAC,EAAE,0BAA0B,GACpC,0BAA0B,CAQ5B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,CAAC,EAAE,kBAAkB,GAC5B,kBAAkB,CAQpB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,CAAC,EAAE,qBAAqB,GAC/B,qBAAqB,CAMvB;AAED;;;;;GAKG;AACH,wBAAgB,oCAAoC,CAClD,QAAQ,CAAC,EAAE,uCAAuC,GACjD,uCAAuC,CAkBzC;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,oBAAoB,CAYtB;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,CAAC,EAAE,2BAA2B,GACrC,2BAA2B,CAM7B"}
|
|
@@ -89,6 +89,7 @@ function getReplaceByParamsSettings(settings) {
|
|
|
89
89
|
return {
|
|
90
90
|
...settings,
|
|
91
91
|
automaticOperator: settings?.automaticOperator ?? false,
|
|
92
|
+
addingInSameIndex: settings?.addingInSameIndex ?? false,
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
exports.getReplaceByParamsSettings = getReplaceByParamsSettings;
|
|
@@ -8,19 +8,21 @@ export interface IFilterBuilderAdd {
|
|
|
8
8
|
/**
|
|
9
9
|
* Adds one filter into the collection.
|
|
10
10
|
* Inserts it next to the last similar filter
|
|
11
|
-
* @param
|
|
11
|
+
* @param filter the filter to add
|
|
12
|
+
* @param inIndex the index to add the new filter
|
|
12
13
|
* @param settings the settings object to setup this function
|
|
13
14
|
* @returns the new collection of filters
|
|
14
15
|
*/
|
|
15
|
-
addSingle: (filter: IFilter, settings?: IFilterAddSettings) => IFilterBuilderSingleReturn;
|
|
16
|
+
addSingle: (filter: IFilter, inIndex?: number, settings?: IFilterAddSettings) => IFilterBuilderSingleReturn;
|
|
16
17
|
/**
|
|
17
18
|
* Adds various filter into the collection.
|
|
18
19
|
* Inserts them next to the last similar filter
|
|
19
|
-
* @param
|
|
20
|
+
* @param filter the filter to add
|
|
21
|
+
* @param inIndexes collection of indexes to add the new filters
|
|
20
22
|
* @param settings the settings object to setup this function
|
|
21
23
|
* @returns the new collection of filters
|
|
22
24
|
*/
|
|
23
|
-
|
|
25
|
+
addMultiple: (filter: IFilter[], inIndexes?: number[], settings?: IFilterAddSettings) => IFilterBuilderMultipleReturn;
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
26
28
|
* Structure module for the editing filter values
|
|
@@ -56,7 +58,7 @@ export interface IFilterBuilderDelete {
|
|
|
56
58
|
* @param ids a collection of ID to search filters to remove
|
|
57
59
|
* @returns the new filter collection
|
|
58
60
|
*/
|
|
59
|
-
|
|
61
|
+
deleteMultiple: (ids: string[]) => IFilterBuilderMultipleReturn;
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* Structure module for the editing filter values
|
|
@@ -96,7 +98,7 @@ export interface IFilterBuilderEdit {
|
|
|
96
98
|
* @param settings settings object for the function
|
|
97
99
|
* @returns the new filter collection
|
|
98
100
|
*/
|
|
99
|
-
|
|
101
|
+
editMultiple: (ids: string[], filter: Partial<IFilter>[] | IFilter[], settings?: IFilterBuilderEditSettings) => IFilterBuilderMultipleReturn;
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
102
104
|
* Structure module for the editing filter values
|
|
@@ -136,7 +138,7 @@ export interface IFilterBuilderMerge {
|
|
|
136
138
|
* @param settings the settings object to setup this function
|
|
137
139
|
* @returns the new filter collection
|
|
138
140
|
*/
|
|
139
|
-
|
|
141
|
+
mergeMultiple: (filters: IFilter[], settings?: IFilterMergeSettings) => IFilterBuilderMultipleReturn;
|
|
140
142
|
}
|
|
141
143
|
/**
|
|
142
144
|
* Structure module for the editing filter values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-builder.models.d.ts","sourceRoot":"","sources":["../../../src/models/filter-builder.models.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC
|
|
1
|
+
{"version":3,"file":"filter-builder.models.d.ts","sourceRoot":"","sources":["../../../src/models/filter-builder.models.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,SAAS,EAAE,CACT,MAAM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AO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB"}
|
|
@@ -59,5 +59,16 @@ export type IFilterMergeSettings = IFilterAddSettings;
|
|
|
59
59
|
/**
|
|
60
60
|
* Settings object for the Replace Param function
|
|
61
61
|
*/
|
|
62
|
-
export type IFilterReplaceParamSettings = IFilterParamSettings & IFilterAddSettings
|
|
62
|
+
export type IFilterReplaceParamSettings = IFilterParamSettings & IFilterAddSettings & {
|
|
63
|
+
addingInSameIndex?: boolean;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The object to return for the findLastIndex function
|
|
67
|
+
*/
|
|
68
|
+
export interface IFilterFindLastIndexReturn {
|
|
69
|
+
index: number;
|
|
70
|
+
nextToColumnFilter: boolean;
|
|
71
|
+
nextToDatasetFilter: boolean;
|
|
72
|
+
nextToScopeFilter: boolean;
|
|
73
|
+
}
|
|
63
74
|
//# sourceMappingURL=filter-functions.resources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-functions.resources.d.ts","sourceRoot":"","sources":["../../../src/resources/filter-functions.resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,2BAA2B,EAAE,kBAGzC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAED,eAAO,MAAM,8BAA8B,EAAE,qBAG5C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,8BAA8B,EAAE,oBAI5C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,6BAA6B,EAAE,0BAG3C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,uCAAuC;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,eAAO,MAAM,gDAAgD,EAAE,uCAO5D,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAC5D,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"filter-functions.resources.d.ts","sourceRoot":"","sources":["../../../src/resources/filter-functions.resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,2BAA2B,E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20 +25,23 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
|
|
|
25
25
|
* Adds various filter into the collection.
|
|
26
26
|
* Inserts them next to the last similar filter
|
|
27
27
|
* @param newFilters the filter to add
|
|
28
|
+
* @param inIndexes collection of indexes to add the new filters
|
|
28
29
|
* @param settings the settings object to setup this function
|
|
29
30
|
* @returns the new collection of filters
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
addMultiple(newFilters: IFilter[], inIndexes?: number[], settings?: IFilterAddSettings): IFilterBuilderMultipleReturn;
|
|
32
33
|
/**
|
|
33
34
|
* Adds one filter into the collection.
|
|
34
35
|
* - Inserts it next to the last similar filter
|
|
35
36
|
* - If the new one is match with the last similar filter, the operator will change to OR
|
|
36
37
|
* - If the id is not provided, a new one is created.
|
|
38
|
+
* - If the inIndex nunber is provided, this will be the index where the filter is inserted
|
|
37
39
|
* @param filter the filter to add
|
|
40
|
+
* @param inIndex the index to add the new filter
|
|
38
41
|
* @param settings settings object to setup this function
|
|
39
42
|
* @returns the new collection of filters
|
|
40
43
|
*/
|
|
41
|
-
addSingle(filter: IFilter, settings?: IFilterAddSettings): IFilterBuilderSingleReturn;
|
|
44
|
+
addSingle(filter: IFilter, inIndex?: number, settings?: IFilterAddSettings): IFilterBuilderSingleReturn;
|
|
42
45
|
/**
|
|
43
46
|
* Adds one value from filter
|
|
44
47
|
* @param id the ID to search the filter to add value
|
|
@@ -70,7 +73,7 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
|
|
|
70
73
|
* @param ids a collection of ID to search filters to remove
|
|
71
74
|
* @returns the new filter collection
|
|
72
75
|
*/
|
|
73
|
-
|
|
76
|
+
deleteMultiple(ids: string[]): IFilterBuilderMultipleReturn;
|
|
74
77
|
/**
|
|
75
78
|
* Removes one filter from the collection
|
|
76
79
|
* @param id the ID to search the filter to remove
|
|
@@ -103,7 +106,7 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
|
|
|
103
106
|
* @param settings settings object for the function
|
|
104
107
|
* @returns the new filter collection
|
|
105
108
|
*/
|
|
106
|
-
|
|
109
|
+
editMultiple(ids: string[], filters: Partial<IFilter>[], settings?: IFilterBuilderEditSettings): IFilterBuilderMultipleReturn;
|
|
107
110
|
/**
|
|
108
111
|
* Edits one filter from the collection
|
|
109
112
|
* @param id the ID to search the filter to edit
|
|
@@ -146,7 +149,7 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
|
|
|
146
149
|
* @param settings the settings object to setup this function
|
|
147
150
|
* @returns the new filter collection
|
|
148
151
|
*/
|
|
149
|
-
|
|
152
|
+
mergeMultiple(filters: IFilter[], settings?: IFilterMergeSettings): IFilterBuilderMultipleReturn;
|
|
150
153
|
/**
|
|
151
154
|
* Merge values from filter
|
|
152
155
|
* @param id the ID to search the filter to merge values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterBuilder.d.ts","sourceRoot":"","sources":["../../src/classes/FilterBuilder.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,qBAAqB,
|
|
1
|
+
{"version":3,"file":"FilterBuilder.d.ts","sourceRoot":"","sources":["../../src/classes/FilterBuilder.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,EAC5B,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,q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OAAO;IA0CV;;;;;;;OAOG;IACI,eAAe,CACpB,OAAO,EAAE,OAAO,EAAE,EAClB,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EACxB,QAAQ,CAAC,EAAE,2BAA2B,GACrC,4BAA4B;IAqB/B;;OAEG;IACH,OAAO,CAAC,IAAI;IAIZ;;;;OAIG;IAEH;;;OAGG;IACI,UAAU,IAAI,OAAO,EAAE;IAI9B;;;;OAIG;IAEH;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI;CAI5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isEmpty, isNaNV2, objectCopy } from "@qrvey/utils";
|
|
2
2
|
import { FilterSearcher } from "./FilterSearcher";
|
|
3
3
|
import { FilterValidation } from "./FilterValidation";
|
|
4
4
|
import { FilterValues } from "./FilterValues";
|
|
@@ -34,17 +34,18 @@ export class FilterBuilder {
|
|
|
34
34
|
* Adds various filter into the collection.
|
|
35
35
|
* Inserts them next to the last similar filter
|
|
36
36
|
* @param newFilters the filter to add
|
|
37
|
+
* @param inIndexes collection of indexes to add the new filters
|
|
37
38
|
* @param settings the settings object to setup this function
|
|
38
39
|
* @returns the new collection of filters
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
|
+
addMultiple(newFilters, inIndexes, settings) {
|
|
41
42
|
if (isEmpty(newFilters))
|
|
42
43
|
return { resulting: this.filters };
|
|
43
44
|
const filters = objectCopy(this.filters);
|
|
44
45
|
const affected = [];
|
|
45
46
|
try {
|
|
46
|
-
newFilters.forEach((newFilter) => {
|
|
47
|
-
const affectedFilter = this.addSingle(newFilter, settings);
|
|
47
|
+
newFilters.forEach((newFilter, index) => {
|
|
48
|
+
const affectedFilter = this.addSingle(newFilter, inIndexes?.[index], settings);
|
|
48
49
|
affected.push(affectedFilter.affected);
|
|
49
50
|
});
|
|
50
51
|
}
|
|
@@ -64,11 +65,13 @@ export class FilterBuilder {
|
|
|
64
65
|
* - Inserts it next to the last similar filter
|
|
65
66
|
* - If the new one is match with the last similar filter, the operator will change to OR
|
|
66
67
|
* - If the id is not provided, a new one is created.
|
|
68
|
+
* - If the inIndex nunber is provided, this will be the index where the filter is inserted
|
|
67
69
|
* @param filter the filter to add
|
|
70
|
+
* @param inIndex the index to add the new filter
|
|
68
71
|
* @param settings settings object to setup this function
|
|
69
72
|
* @returns the new collection of filters
|
|
70
73
|
*/
|
|
71
|
-
addSingle(filter, settings) {
|
|
74
|
+
addSingle(filter, inIndex, settings) {
|
|
72
75
|
if (isEmpty(filter))
|
|
73
76
|
return { resulting: this.filters };
|
|
74
77
|
if (FilterValidation.isDuplicated(this.filters, filter))
|
|
@@ -78,14 +81,27 @@ export class FilterBuilder {
|
|
|
78
81
|
const newSettings = getFilterAddSettings(settings);
|
|
79
82
|
if (isEmpty(filter.id) || newSettings.automaticId)
|
|
80
83
|
newFilter.id = getFilterId(newFilter);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
let indexResult;
|
|
85
|
+
let nextIndex;
|
|
86
|
+
if (isNaNV2(inIndex)) {
|
|
87
|
+
indexResult = this.searchEngine.findLastIndexByFilter(newFilter, inIndex);
|
|
88
|
+
nextIndex = indexResult.index + 1;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
indexResult = {
|
|
92
|
+
index: inIndex,
|
|
93
|
+
nextToColumnFilter: false,
|
|
94
|
+
nextToDatasetFilter: false,
|
|
95
|
+
nextToScopeFilter: false,
|
|
96
|
+
};
|
|
97
|
+
nextIndex = indexResult.index;
|
|
98
|
+
}
|
|
99
|
+
if (indexResult.index > -1) {
|
|
100
|
+
this.filters.splice(nextIndex, 0, newFilter);
|
|
101
|
+
if (newSettings.automaticOperator &&
|
|
102
|
+
indexResult.nextToColumnFilter &&
|
|
103
|
+
indexResult.index > -1)
|
|
104
|
+
this.filters[indexResult.index].operator = FILTER_OPERATOR.OR;
|
|
89
105
|
}
|
|
90
106
|
else {
|
|
91
107
|
this.filters.push(newFilter);
|
|
@@ -174,7 +190,7 @@ export class FilterBuilder {
|
|
|
174
190
|
* @param ids a collection of ID to search filters to remove
|
|
175
191
|
* @returns the new filter collection
|
|
176
192
|
*/
|
|
177
|
-
|
|
193
|
+
deleteMultiple(ids) {
|
|
178
194
|
if (!Array.isArray(ids))
|
|
179
195
|
return { resulting: this.filters };
|
|
180
196
|
const filters = objectCopy(this.filters);
|
|
@@ -283,7 +299,7 @@ export class FilterBuilder {
|
|
|
283
299
|
* @param settings settings object for the function
|
|
284
300
|
* @returns the new filter collection
|
|
285
301
|
*/
|
|
286
|
-
|
|
302
|
+
editMultiple(ids, filters, settings) {
|
|
287
303
|
if (!Array.isArray(ids) ||
|
|
288
304
|
!Array.isArray(filters) ||
|
|
289
305
|
ids.length !== filters.length)
|
|
@@ -420,7 +436,7 @@ export class FilterBuilder {
|
|
|
420
436
|
affected = affectedMergeFilter;
|
|
421
437
|
}
|
|
422
438
|
else {
|
|
423
|
-
const { affected: affectedAddSingle } = this.addSingle(filter, settings);
|
|
439
|
+
const { affected: affectedAddSingle } = this.addSingle(filter, undefined, settings);
|
|
424
440
|
affected = affectedAddSingle;
|
|
425
441
|
}
|
|
426
442
|
return {
|
|
@@ -435,7 +451,7 @@ export class FilterBuilder {
|
|
|
435
451
|
* @param settings the settings object to setup this function
|
|
436
452
|
* @returns the new filter collection
|
|
437
453
|
*/
|
|
438
|
-
|
|
454
|
+
mergeMultiple(filters, settings) {
|
|
439
455
|
if (!Array.isArray(filters) || isEmpty(filters))
|
|
440
456
|
return { resulting: this.filters };
|
|
441
457
|
const originalFilters = objectCopy(this.filters);
|
|
@@ -555,8 +571,14 @@ export class FilterBuilder {
|
|
|
555
571
|
replaceByParams(filters, params, settings) {
|
|
556
572
|
const original = objectCopy(this.filters);
|
|
557
573
|
const newSettings = getReplaceByParamsSettings(settings);
|
|
574
|
+
let filterIndexes = undefined;
|
|
575
|
+
if (newSettings.addingInSameIndex) {
|
|
576
|
+
filterIndexes = this.searchEngine.filterIndexesByParams(params, settings);
|
|
577
|
+
if (isEmpty(filterIndexes))
|
|
578
|
+
filterIndexes = undefined;
|
|
579
|
+
}
|
|
558
580
|
this.filters = this.searchEngine.excludeByParams(params, newSettings);
|
|
559
|
-
const resulting = this.
|
|
581
|
+
const resulting = this.addMultiple(filters, filterIndexes, newSettings);
|
|
560
582
|
this.sync();
|
|
561
583
|
return {
|
|
562
584
|
resulting: this.filters,
|