@qrvey/filters 0.0.13 → 0.0.15
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/FilterAdapter.d.ts +2 -1
- package/dist/cjs/classes/FilterAdapter.d.ts.map +1 -1
- package/dist/cjs/classes/FilterAdapter.js +8 -6
- package/dist/cjs/classes/FilterManager.d.ts +8 -3
- package/dist/cjs/classes/FilterManager.d.ts.map +1 -1
- package/dist/cjs/classes/FilterManager.js +14 -6
- package/dist/cjs/classes/FilterSettings.d.ts +1 -0
- package/dist/cjs/classes/FilterSettings.d.ts.map +1 -0
- package/dist/cjs/classes/FilterSettings.js +1 -0
- package/dist/cjs/helpers/filter-adapt.helpers.d.ts +7 -13
- package/dist/cjs/helpers/filter-adapt.helpers.d.ts.map +1 -1
- package/dist/cjs/helpers/filter-adapt.helpers.js +31 -183
- package/dist/cjs/helpers/filter-adapt.legacy.helpers.d.ts +26 -0
- package/dist/cjs/helpers/filter-adapt.legacy.helpers.d.ts.map +1 -0
- package/dist/cjs/helpers/filter-adapt.legacy.helpers.js +229 -0
- package/dist/cjs/helpers/filter-adapt.logic.helpers.js +1 -1
- package/dist/cjs/resources/filter-logic.resources.d.ts +0 -4
- package/dist/cjs/resources/filter-logic.resources.d.ts.map +1 -1
- package/dist/cjs/resources/filter-panel.interfaces.d.ts +57 -4
- package/dist/cjs/resources/filter-panel.interfaces.d.ts.map +1 -1
- package/dist/cjs/resources/filter-settings.resources.d.ts +357 -0
- package/dist/cjs/resources/filter-settings.resources.d.ts.map +1 -0
- package/dist/cjs/resources/filter-settings.resources.js +2 -0
- package/dist/cjs/resources/filter-visual.resources.d.ts +0 -8
- package/dist/cjs/resources/filter-visual.resources.d.ts.map +1 -1
- package/dist/cjs/resources/filters.resources.d.ts +2 -0
- package/dist/cjs/resources/filters.resources.d.ts.map +1 -1
- package/dist/classes/FilterAdapter.d.ts +2 -1
- package/dist/classes/FilterAdapter.d.ts.map +1 -1
- package/dist/classes/FilterAdapter.js +7 -5
- package/dist/classes/FilterManager.d.ts +8 -3
- package/dist/classes/FilterManager.d.ts.map +1 -1
- package/dist/classes/FilterManager.js +14 -6
- package/dist/classes/FilterSettings.d.ts +1 -0
- package/dist/classes/FilterSettings.d.ts.map +1 -0
- package/dist/classes/FilterSettings.js +1 -0
- package/dist/helpers/filter-adapt.helpers.d.ts +7 -13
- package/dist/helpers/filter-adapt.helpers.d.ts.map +1 -1
- package/dist/helpers/filter-adapt.helpers.js +30 -181
- package/dist/helpers/filter-adapt.legacy.helpers.d.ts +26 -0
- package/dist/helpers/filter-adapt.legacy.helpers.d.ts.map +1 -0
- package/dist/helpers/filter-adapt.legacy.helpers.js +223 -0
- package/dist/helpers/filter-adapt.logic.helpers.js +1 -1
- package/dist/resources/filter-logic.resources.d.ts +0 -4
- package/dist/resources/filter-logic.resources.d.ts.map +1 -1
- package/dist/resources/filter-panel.interfaces.d.ts +57 -4
- package/dist/resources/filter-panel.interfaces.d.ts.map +1 -1
- package/dist/resources/filter-settings.resources.d.ts +357 -0
- package/dist/resources/filter-settings.resources.d.ts.map +1 -0
- package/dist/resources/filter-settings.resources.js +1 -0
- package/dist/resources/filter-visual.resources.d.ts +0 -8
- package/dist/resources/filter-visual.resources.d.ts.map +1 -1
- package/dist/resources/filters.resources.d.ts +2 -0
- package/dist/resources/filters.resources.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/classes/FilterAdapter.ts +13 -7
- package/src/classes/FilterManager.ts +13 -4
- package/src/helpers/filter-adapt.helpers.ts +36 -242
- package/src/helpers/filter-adapt.legacy.helpers.ts +296 -0
- package/src/helpers/filter-adapt.logic.helpers.ts +1 -1
- package/src/resources/filter-logic.resources.ts +0 -4
- package/src/resources/filter-panel.interfaces.ts +58 -4
- package/src/resources/filter-visual.resources.ts +0 -8
- package/src/resources/filters.resources.ts +2 -0
- package/tests/mock/filters-adapter.mock.ts +0 -7
- package/tests/mock/filters-interactive-table.mock.ts +14 -18
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { isEmpty
|
|
1
|
+
import { isEmpty } from "@qrvey/utils";
|
|
2
2
|
import { getColumnInfo, getDatasetInfo } from "./utils.helpers";
|
|
3
|
-
import { FilterBuilder } from "../classes/FilterBuilder";
|
|
4
|
-
import { FILTER_SCOPE } from "../resources/filter-scopes.resources";
|
|
5
|
-
import { FILTER_SECTION } from "../resources/filter-sections.resources";
|
|
6
3
|
import { DEFAULT_UI_FILTER, } from "../resources/filter-visual.resources";
|
|
7
4
|
import { DEFAULT_FILTER } from "../resources/filters.resources";
|
|
8
5
|
/**
|
|
@@ -20,67 +17,42 @@ export function filterToVisual(filters, datasets = [], interactiveTable) {
|
|
|
20
17
|
};
|
|
21
18
|
}
|
|
22
19
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param interactiveTable
|
|
27
|
-
* @returns
|
|
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
|
|
28
25
|
*/
|
|
29
|
-
export function
|
|
30
|
-
if (isEmpty(
|
|
26
|
+
export function legacyVisualToInteractiveTable(visual, interactiveTable) {
|
|
27
|
+
if (isEmpty(visual) || isEmpty(visual?.scopes))
|
|
31
28
|
return;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
scopes: buildLegacyScopes(filters, datasets, interactiveTable),
|
|
29
|
+
const newInteractiveTable = {
|
|
30
|
+
interactScopes: [],
|
|
31
|
+
interactDatasets: [],
|
|
32
|
+
...interactiveTable,
|
|
37
33
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export function legacyVisualToFilter(filterData) {
|
|
45
|
-
if (isEmpty(filterData) || isEmpty(filterData?.scopes))
|
|
46
|
-
return [];
|
|
47
|
-
const filters = [];
|
|
48
|
-
filterData.scopes.forEach((scope) => {
|
|
34
|
+
visual.scopes.forEach((scope) => {
|
|
35
|
+
newInteractiveTable.interactScopes.push({
|
|
36
|
+
collapsed: scope.collapsed,
|
|
37
|
+
scope: scope.scope,
|
|
38
|
+
scopeId: scope.id,
|
|
39
|
+
});
|
|
49
40
|
if (scope.datasets.length === 0)
|
|
50
41
|
return;
|
|
51
42
|
scope.datasets.forEach((dataset) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
collapsed: filter.collapsed,
|
|
58
|
-
columnId: filter.column.id,
|
|
59
|
-
columnType: filter.column.type,
|
|
60
|
-
customLabel: filter.extras.filterLabel,
|
|
61
|
-
datasetId: dataset.qrveyid,
|
|
62
|
-
deletable: filter.deletable,
|
|
63
|
-
displayed: filter.displayed,
|
|
64
|
-
editable: filter.editable,
|
|
65
|
-
enableable: filter.enableable,
|
|
66
|
-
enabled: filter.enabled,
|
|
67
|
-
extras: filter.extras,
|
|
68
|
-
grouping: filter.property,
|
|
69
|
-
id: "",
|
|
70
|
-
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
71
|
-
operator: filter.operator,
|
|
72
|
-
scope: scope.scope,
|
|
73
|
-
scopeId: scope.scopeid,
|
|
74
|
-
section: filterData.section,
|
|
75
|
-
selectAll: filter.selectAll,
|
|
76
|
-
validator: filter.validator,
|
|
77
|
-
values: filter.values,
|
|
78
|
-
});
|
|
79
|
-
filters.push(fFilter);
|
|
43
|
+
newInteractiveTable.interactDatasets.push({
|
|
44
|
+
collapsed: scope.collapsed,
|
|
45
|
+
scope: scope.scope,
|
|
46
|
+
scopeId: scope.id,
|
|
47
|
+
datasetId: dataset.id,
|
|
80
48
|
});
|
|
81
49
|
});
|
|
82
50
|
});
|
|
83
|
-
|
|
51
|
+
if (isEmpty(newInteractiveTable.interactScopes))
|
|
52
|
+
delete newInteractiveTable.interactScopes;
|
|
53
|
+
if (isEmpty(newInteractiveTable.interactDatasets))
|
|
54
|
+
delete newInteractiveTable.interactDatasets;
|
|
55
|
+
return newInteractiveTable;
|
|
84
56
|
}
|
|
85
57
|
/**
|
|
86
58
|
* Gets a collection of scopes for the visual filter data.
|
|
@@ -123,13 +95,11 @@ function buildScopes(filters = [], datasets = [], interactiveTable) {
|
|
|
123
95
|
* @returns the visual scope structure
|
|
124
96
|
*/
|
|
125
97
|
function buildScope(filter, interactiveTable) {
|
|
126
|
-
const { collapsed
|
|
98
|
+
const { collapsed } = interactiveTable?.interactScopes?.find((interactive) => interactive.scope === filter.scope &&
|
|
127
99
|
interactive.scopeId === filter.scopeId) ?? {};
|
|
128
100
|
return {
|
|
129
101
|
collapsed: collapsed ?? false,
|
|
130
102
|
datasets: [],
|
|
131
|
-
displayed: displayed ?? true,
|
|
132
|
-
enabled: enabled ?? true,
|
|
133
103
|
scope: filter.scope,
|
|
134
104
|
id: filter.scopeId,
|
|
135
105
|
section: filter.section,
|
|
@@ -143,13 +113,11 @@ function buildScope(filter, interactiveTable) {
|
|
|
143
113
|
* @returns an dataset structure
|
|
144
114
|
*/
|
|
145
115
|
function buildDataset(filter, dataset, interactiveTable) {
|
|
146
|
-
const { collapsed
|
|
116
|
+
const { collapsed } = interactiveTable?.interactDatasets?.find((interactive) => interactive.datasetId === filter.datasetId) ?? {};
|
|
147
117
|
return {
|
|
148
118
|
collapsed: collapsed ?? false,
|
|
149
119
|
id: filter.datasetId,
|
|
150
120
|
label: dataset?.label || "",
|
|
151
|
-
displayed: displayed ?? true,
|
|
152
|
-
enabled: enabled ?? true,
|
|
153
121
|
filters: [],
|
|
154
122
|
};
|
|
155
123
|
}
|
|
@@ -172,122 +140,3 @@ function buildFilter(filter, dataset) {
|
|
|
172
140
|
iconTooltip: filter.iconTooltip ?? DEFAULT_UI_FILTER.iconTooltip,
|
|
173
141
|
};
|
|
174
142
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Gets a collection of legacy scopes for the legacy visual filters.
|
|
177
|
-
* The scopes are organized by scope types and IDs
|
|
178
|
-
* Also, adds and organizes filters by datasets
|
|
179
|
-
* @param filters Collection of filters
|
|
180
|
-
* @param datasets Array of the dataset info
|
|
181
|
-
* @param interactiveTable table of interaction properties for each section
|
|
182
|
-
* @returns an array of visual scopes.
|
|
183
|
-
*/
|
|
184
|
-
function buildLegacyScopes(filters = [], datasets = [], interactiveTable) {
|
|
185
|
-
return filters.reduce((scopes, filter) => {
|
|
186
|
-
const datasetInfo = getDatasetInfo({ columnId: filter.columnId, datasetId: filter.datasetId }, datasets);
|
|
187
|
-
const uiFilter = buildLegacyFilter(filter, datasetInfo);
|
|
188
|
-
const uiDataset = buildLegacyDataset(filter, datasetInfo, interactiveTable);
|
|
189
|
-
const uiScope = buildLegacyScope(filter, interactiveTable);
|
|
190
|
-
const scopeIndex = scopes.findIndex((sc) => sc.scope === filter.scope && sc.scopeid === filter.scopeId);
|
|
191
|
-
const datasetIndex = scopeIndex > -1
|
|
192
|
-
? scopes[scopeIndex].datasets.findIndex((dt) => dt.qrveyid === filter.datasetId)
|
|
193
|
-
: -1;
|
|
194
|
-
if (scopeIndex === -1) {
|
|
195
|
-
scopes.push({
|
|
196
|
-
...uiScope,
|
|
197
|
-
datasets: [{ ...uiDataset, filters: [uiFilter] }],
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
else if (datasetIndex === -1) {
|
|
201
|
-
scopes[scopeIndex].datasets.push({ ...uiDataset, filters: [uiFilter] });
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
scopes[scopeIndex].datasets[datasetIndex].filters.push(uiFilter);
|
|
205
|
-
}
|
|
206
|
-
return scopes;
|
|
207
|
-
}, []);
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Gets an legacy scope structure for the legacy filter data
|
|
211
|
-
* @param filter the filter
|
|
212
|
-
* @param interactiveTable table of interaction properties for each section
|
|
213
|
-
* @returns the legacy visual scope structure
|
|
214
|
-
*/
|
|
215
|
-
function buildLegacyScope(filter, interactiveTable) {
|
|
216
|
-
const { collapsed, displayed, enabled } = interactiveTable?.scopes.find((interactive) => interactive.scope === filter.scope &&
|
|
217
|
-
interactive.scopeId === filter.scopeId) ?? {};
|
|
218
|
-
return {
|
|
219
|
-
collapsed: collapsed ?? false,
|
|
220
|
-
datasets: [],
|
|
221
|
-
displayed: displayed ?? true,
|
|
222
|
-
enabled: enabled ?? true,
|
|
223
|
-
scope: filter.scope,
|
|
224
|
-
scopeid: filter.scopeId,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Gets an legacy dataset structure for the legacy visual filter
|
|
229
|
-
* @param filter the filter
|
|
230
|
-
* @param dataset the dataset info
|
|
231
|
-
* @param interactiveTable table of interaction properties for each section
|
|
232
|
-
* @returns an legacy dataset structure
|
|
233
|
-
*/
|
|
234
|
-
function buildLegacyDataset(filter, dataset, interactiveTable) {
|
|
235
|
-
const { collapsed, displayed, enabled } = interactiveTable?.datasets.find((interactive) => interactive.datasetId === filter.datasetId) ?? {};
|
|
236
|
-
return {
|
|
237
|
-
collapsed: collapsed ?? false,
|
|
238
|
-
qrveyid: filter.datasetId,
|
|
239
|
-
label: dataset?.label || "",
|
|
240
|
-
displayed: displayed ?? true,
|
|
241
|
-
enabled: enabled ?? true,
|
|
242
|
-
filters: [],
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Gets an legacy filter structure for the legacy visual filter
|
|
247
|
-
* @param filter a UI structure filter
|
|
248
|
-
* @param dataset the dataset info
|
|
249
|
-
* @returns an legacy filter structure
|
|
250
|
-
*/
|
|
251
|
-
function buildLegacyFilter(filter, dataset) {
|
|
252
|
-
const columnInfo = dataset == null
|
|
253
|
-
? undefined
|
|
254
|
-
: getColumnInfo({ columnId: filter.columnId, datasetId: filter.datasetId }, [dataset]);
|
|
255
|
-
return {
|
|
256
|
-
collapsed: filter.collapsed ?? false,
|
|
257
|
-
column: {
|
|
258
|
-
id: filter.columnId,
|
|
259
|
-
formulaType: columnInfo?.formulaType,
|
|
260
|
-
label: columnInfo?.label || "",
|
|
261
|
-
qrveyid: filter.datasetId,
|
|
262
|
-
aggregate: filter.aggregateType,
|
|
263
|
-
type: filter.columnType,
|
|
264
|
-
},
|
|
265
|
-
deletable: filter.deletable,
|
|
266
|
-
displayed: filter.displayed,
|
|
267
|
-
editable: filter.editable,
|
|
268
|
-
enableable: filter.enableable,
|
|
269
|
-
enabled: filter.enabled,
|
|
270
|
-
filterid: filter.id,
|
|
271
|
-
extras: {
|
|
272
|
-
...filter.extras,
|
|
273
|
-
filterLabel: filter.customLabel,
|
|
274
|
-
panelid: FILTER_SCOPE.CHART === filter.scope ? filter.scopeId : undefined,
|
|
275
|
-
info: !isEmpty(filter.extras?.info)
|
|
276
|
-
? {
|
|
277
|
-
icon: filter.icon || "",
|
|
278
|
-
label: filter.iconTooltip || "",
|
|
279
|
-
}
|
|
280
|
-
: undefined,
|
|
281
|
-
scope: filter.scope,
|
|
282
|
-
scopeid: filter.scopeId,
|
|
283
|
-
section: filter.section,
|
|
284
|
-
},
|
|
285
|
-
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
286
|
-
nullValues: false,
|
|
287
|
-
operator: filter.operator,
|
|
288
|
-
property: filter.grouping,
|
|
289
|
-
selectAll: filter.selectAll,
|
|
290
|
-
validator: filter.validator,
|
|
291
|
-
values: filter.values,
|
|
292
|
-
};
|
|
293
|
-
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IDataset, IFUData } from "@qrvey/utils";
|
|
2
|
+
import { IFilterPanelInteractiveTable } from "../resources/filter-panel.interfaces";
|
|
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
|
+
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
|
+
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
|
+
export declare function legacyVisualToInteractiveTable(legacyVisual: IFUData, interactiveTable?: IFilterPanelInteractiveTable): IFilterPanelInteractiveTable | undefined;
|
|
26
|
+
//# sourceMappingURL=filter-adapt.legacy.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-adapt.legacy.helpers.d.ts","sourceRoot":"","sources":["../../src/helpers/filter-adapt.legacy.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EACR,OAAO,EAMR,MAAM,cAAc,CAAC;AAMtB,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAEpF,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAAE,EAClB,QAAQ,GAAE,QAAQ,EAAO,EACzB,gBAAgB,CAAC,EAAE,4BAA4B,GAC9C,OAAO,GAAG,SAAS,CASrB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,EAAE,CAyCnE;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,YAAY,EAAE,OAAO,EACrB,gBAAgB,CAAC,EAAE,4BAA4B,GAC9C,4BAA4B,GAAG,SAAS,CAgC1C"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { FILTER_SCOPE, FILTER_SECTION, isEmpty, } from "@qrvey/utils";
|
|
2
|
+
import { getColumnInfo, getDatasetInfo } from "./utils.helpers";
|
|
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
|
+
export function filterToLegacyVisual(filters, datasets = [], interactiveTable) {
|
|
12
|
+
if (isEmpty(filters))
|
|
13
|
+
return;
|
|
14
|
+
return {
|
|
15
|
+
enabled: true,
|
|
16
|
+
section: FILTER_SECTION.DX,
|
|
17
|
+
version: "2.1",
|
|
18
|
+
scopes: buildLegacyScopes(filters, datasets, interactiveTable),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
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
|
+
export function legacyVisualToFilter(filterData) {
|
|
27
|
+
if (isEmpty(filterData) || isEmpty(filterData?.scopes))
|
|
28
|
+
return [];
|
|
29
|
+
const filters = [];
|
|
30
|
+
filterData.scopes.forEach((scope) => {
|
|
31
|
+
if (scope.datasets.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
scope.datasets.forEach((dataset) => {
|
|
34
|
+
if (dataset.filters.length === 0)
|
|
35
|
+
return;
|
|
36
|
+
dataset.filters.forEach((filter) => {
|
|
37
|
+
const fFilter = FilterBuilder.createFilter({
|
|
38
|
+
aggregateType: filter.column.aggregate,
|
|
39
|
+
collapsed: filter.collapsed,
|
|
40
|
+
columnId: filter.column.id,
|
|
41
|
+
columnType: filter.column.type,
|
|
42
|
+
customLabel: filter.extras.filterLabel,
|
|
43
|
+
datasetId: dataset.qrveyid,
|
|
44
|
+
deletable: filter.deletable,
|
|
45
|
+
displayed: filter.displayed,
|
|
46
|
+
editable: filter.editable,
|
|
47
|
+
enableable: filter.enableable,
|
|
48
|
+
enabled: filter.enabled,
|
|
49
|
+
extras: filter.extras,
|
|
50
|
+
grouping: filter.property,
|
|
51
|
+
id: "",
|
|
52
|
+
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
53
|
+
operator: filter.operator,
|
|
54
|
+
scope: scope.scope,
|
|
55
|
+
scopeId: scope.scopeid,
|
|
56
|
+
section: filterData.section,
|
|
57
|
+
selectAll: filter.selectAll,
|
|
58
|
+
validator: filter.validator,
|
|
59
|
+
values: filter.values,
|
|
60
|
+
});
|
|
61
|
+
filters.push(fFilter);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
return filters;
|
|
66
|
+
}
|
|
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
|
+
export function legacyVisualToInteractiveTable(legacyVisual, interactiveTable) {
|
|
75
|
+
if (isEmpty(legacyVisual) || isEmpty(legacyVisual?.scopes))
|
|
76
|
+
return;
|
|
77
|
+
const newInteractiveTable = {
|
|
78
|
+
...interactiveTable,
|
|
79
|
+
interactScopes: [],
|
|
80
|
+
interactDatasets: [],
|
|
81
|
+
};
|
|
82
|
+
legacyVisual.scopes.forEach((scope) => {
|
|
83
|
+
newInteractiveTable.interactScopes.push({
|
|
84
|
+
collapsed: scope.collapsed,
|
|
85
|
+
scope: scope.scope,
|
|
86
|
+
scopeId: scope.scopeid,
|
|
87
|
+
});
|
|
88
|
+
if (scope.datasets.length === 0)
|
|
89
|
+
return;
|
|
90
|
+
scope.datasets.forEach((dataset) => {
|
|
91
|
+
newInteractiveTable.interactDatasets.push({
|
|
92
|
+
collapsed: dataset.collapsed,
|
|
93
|
+
scope: scope.scope,
|
|
94
|
+
scopeId: scope.scopeid,
|
|
95
|
+
datasetId: dataset.qrveyid,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
if (isEmpty(newInteractiveTable.interactScopes))
|
|
100
|
+
delete newInteractiveTable.interactScopes;
|
|
101
|
+
if (isEmpty(newInteractiveTable.interactDatasets))
|
|
102
|
+
delete newInteractiveTable.interactDatasets;
|
|
103
|
+
return newInteractiveTable;
|
|
104
|
+
}
|
|
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) {
|
|
115
|
+
return filters.reduce((scopes, filter) => {
|
|
116
|
+
const datasetInfo = getDatasetInfo({ columnId: filter.columnId, datasetId: filter.datasetId }, datasets);
|
|
117
|
+
const uiFilter = buildLegacyFilter(filter, datasetInfo);
|
|
118
|
+
const uiDataset = buildLegacyDataset(filter, datasetInfo, interactiveTable);
|
|
119
|
+
const uiScope = buildLegacyScope(filter, interactiveTable);
|
|
120
|
+
const scopeIndex = scopes.findIndex((sc) => sc.scope === filter.scope && sc.scopeid === filter.scopeId);
|
|
121
|
+
const datasetIndex = scopeIndex > -1
|
|
122
|
+
? scopes[scopeIndex].datasets.findIndex((dt) => dt.qrveyid === filter.datasetId)
|
|
123
|
+
: -1;
|
|
124
|
+
if (scopeIndex === -1) {
|
|
125
|
+
scopes.push({
|
|
126
|
+
...uiScope,
|
|
127
|
+
datasets: [{ ...uiDataset, filters: [uiFilter] }],
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else if (datasetIndex === -1) {
|
|
131
|
+
scopes[scopeIndex].datasets.push({ ...uiDataset, filters: [uiFilter] });
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
scopes[scopeIndex].datasets[datasetIndex].filters.push(uiFilter);
|
|
135
|
+
}
|
|
136
|
+
return scopes;
|
|
137
|
+
}, []);
|
|
138
|
+
}
|
|
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
|
+
function buildLegacyScope(filter, interactiveTable) {
|
|
146
|
+
const { collapsed } = interactiveTable?.interactScopes?.find((interactive) => interactive.scope === filter.scope &&
|
|
147
|
+
interactive.scopeId === filter.scopeId) ?? {};
|
|
148
|
+
return {
|
|
149
|
+
collapsed: collapsed ?? false,
|
|
150
|
+
datasets: [],
|
|
151
|
+
displayed: true,
|
|
152
|
+
enabled: true,
|
|
153
|
+
scope: filter.scope,
|
|
154
|
+
scopeid: filter.scopeId,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
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
|
+
function buildLegacyDataset(filter, dataset, interactiveTable) {
|
|
165
|
+
const { collapsed } = interactiveTable?.interactDatasets?.find((interactive) => interactive.datasetId === filter.datasetId) ?? {};
|
|
166
|
+
return {
|
|
167
|
+
collapsed: collapsed ?? false,
|
|
168
|
+
qrveyid: filter.datasetId,
|
|
169
|
+
label: dataset?.label || "",
|
|
170
|
+
displayed: true,
|
|
171
|
+
enabled: true,
|
|
172
|
+
filters: [],
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Gets an legacy filter structure for the legacy visual filter
|
|
177
|
+
* @param filter a UI structure filter
|
|
178
|
+
* @param dataset the dataset info
|
|
179
|
+
* @returns an legacy filter structure
|
|
180
|
+
*/
|
|
181
|
+
function buildLegacyFilter(filter, dataset) {
|
|
182
|
+
const columnInfo = dataset == null
|
|
183
|
+
? undefined
|
|
184
|
+
: getColumnInfo({ columnId: filter.columnId, datasetId: filter.datasetId }, [dataset]);
|
|
185
|
+
return {
|
|
186
|
+
collapsed: filter.collapsed ?? false,
|
|
187
|
+
column: {
|
|
188
|
+
id: filter.columnId,
|
|
189
|
+
formulaType: columnInfo?.formulaType,
|
|
190
|
+
label: columnInfo?.label || "",
|
|
191
|
+
qrveyid: filter.datasetId,
|
|
192
|
+
aggregate: filter.aggregateType,
|
|
193
|
+
type: filter.columnType,
|
|
194
|
+
},
|
|
195
|
+
deletable: filter.deletable,
|
|
196
|
+
displayed: filter.displayed,
|
|
197
|
+
editable: filter.editable,
|
|
198
|
+
enableable: filter.enableable,
|
|
199
|
+
enabled: filter.enabled,
|
|
200
|
+
filterid: filter.id,
|
|
201
|
+
extras: {
|
|
202
|
+
...filter.extras,
|
|
203
|
+
filterLabel: filter.customLabel,
|
|
204
|
+
panelid: FILTER_SCOPE.CHART === filter.scope ? filter.scopeId : undefined,
|
|
205
|
+
info: !isEmpty(filter.extras?.info)
|
|
206
|
+
? {
|
|
207
|
+
icon: filter.icon || "",
|
|
208
|
+
label: filter.iconTooltip || "",
|
|
209
|
+
}
|
|
210
|
+
: undefined,
|
|
211
|
+
scope: filter.scope,
|
|
212
|
+
scopeid: filter.scopeId,
|
|
213
|
+
section: filter.section,
|
|
214
|
+
},
|
|
215
|
+
lookupDisplayIndex: filter.lookupDisplayIndex,
|
|
216
|
+
nullValues: false,
|
|
217
|
+
operator: filter.operator,
|
|
218
|
+
property: filter.grouping,
|
|
219
|
+
selectAll: filter.selectAll,
|
|
220
|
+
validator: filter.validator,
|
|
221
|
+
values: filter.values,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
@@ -44,7 +44,6 @@ export function visualToLogic(visual) {
|
|
|
44
44
|
*/
|
|
45
45
|
function buildLogic(scope) {
|
|
46
46
|
return {
|
|
47
|
-
enabled: scope.enabled,
|
|
48
47
|
filters: [],
|
|
49
48
|
scope: scope.scope,
|
|
50
49
|
scopeid: scope.id,
|
|
@@ -54,6 +53,7 @@ function buildLogic(scope) {
|
|
|
54
53
|
* Gets the Logic Filters collection based on filters
|
|
55
54
|
* @param filters the filter collection
|
|
56
55
|
* @param groupColumns a flag to know if the
|
|
56
|
+
* @returns the logic filter collection
|
|
57
57
|
*/
|
|
58
58
|
function buildLogicFilters(filters, groupColumns = false) {
|
|
59
59
|
const expression = numericExpression(filters, groupColumns);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-logic.resources.d.ts","sourceRoot":"","sources":["../../src/resources/filter-logic.resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"filter-logic.resources.d.ts","sourceRoot":"","sources":["../../src/resources/filter-logic.resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC;IAC1B;;OAEG;IACH,WAAW,EAAE,kBAAkB,EAAE,GAAG,sBAAsB,EAAE,CAAC;CAC9D;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,eAAe,GAAG,MAAM,CAAC;IACpC;;OAEG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC;;OAEG;IACH,KAAK,CAAC,EAAE,2BAA2B,EAAE,CAAC;CACvC;AAED;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,kCAAkC,GAClC,gCAAgC,GAChC,mCAAmC,GACnC,kCAAkC,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG,MAAM,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,wBAAwB,CAAC;AAE3E;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kCAAkC;IACjD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,oBAAY,sBAAsB;IAChC,MAAM,UAAU;IAChB,SAAS,cAAc;IACvB,QAAQ,YAAY;IACpB,WAAW,gBAAgB;IAC3B,SAAS,aAAa;IACtB,YAAY,iBAAiB;IAC7B,WAAW,eAAe;IAC1B,cAAc,mBAAmB;IACjC,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,eAAe,uBAAuB;IACtC,YAAY,iBAAiB;IAC7B,kBAAkB,0BAA0B;IAC5C,OAAO,aAAa;IACpB,WAAW,iBAAiB;IAC5B,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,EAAE,OAAO;IACT,QAAQ,aAAa;CACtB"}
|
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
import { IFilterScope } from "./filter-scopes.resources";
|
|
2
2
|
import { IFilter } from "./filters.resources";
|
|
3
3
|
export interface IFilterPanelInteractiveTable {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Collection of the interactivity Datasets settings
|
|
6
|
+
*/
|
|
7
|
+
interactDatasets?: IFilterPanelInteractiveDatasetTable[];
|
|
8
|
+
/**
|
|
9
|
+
* Collection of the interactivity Scope settings
|
|
10
|
+
*/
|
|
11
|
+
interactScopes?: IFilterPanelInteractiveScopeTable[];
|
|
12
|
+
/**
|
|
13
|
+
* Scopes Settings
|
|
14
|
+
*/
|
|
15
|
+
scopesSettings?: IFilterPanelInteractiveScopeSetting[];
|
|
16
|
+
/**
|
|
17
|
+
* Displays/Hides the panel (Interact)
|
|
18
|
+
*/
|
|
19
|
+
displayed?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Collapses/Expands the Panel
|
|
22
|
+
*/
|
|
23
|
+
collapsed?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Allows to display the related color for each scope
|
|
26
|
+
*/
|
|
27
|
+
colorized?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The Panel Default View (Interact)
|
|
30
|
+
*/
|
|
31
|
+
defaultCollapsed?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Displays/Hides the icons linked with each scope
|
|
34
|
+
*/
|
|
35
|
+
iconsDisplayed?: boolean;
|
|
6
36
|
}
|
|
7
37
|
/**
|
|
8
38
|
* Structure for the resulting conversion of the UI filter
|
|
@@ -12,16 +42,39 @@ export interface IFilterUIToFilter {
|
|
|
12
42
|
interactiveTable?: IFilterPanelInteractiveTable;
|
|
13
43
|
}
|
|
14
44
|
interface IFilterPanelInteractiveGeneral {
|
|
45
|
+
/**
|
|
46
|
+
* Flag to collapse or expand the related section
|
|
47
|
+
*/
|
|
15
48
|
collapsed: boolean;
|
|
16
|
-
enabled: boolean;
|
|
17
|
-
displayed: boolean;
|
|
18
49
|
}
|
|
19
50
|
interface IFilterPanelInteractiveScopeTable extends IFilterPanelInteractiveGeneral {
|
|
51
|
+
/**
|
|
52
|
+
* The Scope ID
|
|
53
|
+
*/
|
|
20
54
|
scopeId?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The Scope Type
|
|
57
|
+
*/
|
|
21
58
|
scope: IFilterScope;
|
|
22
59
|
}
|
|
23
60
|
interface IFilterPanelInteractiveDatasetTable extends IFilterPanelInteractiveScopeTable {
|
|
61
|
+
/**
|
|
62
|
+
* The Dataset ID
|
|
63
|
+
*/
|
|
24
64
|
datasetId: string;
|
|
25
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Structure for a single scope settings
|
|
68
|
+
*/
|
|
69
|
+
interface IFilterPanelInteractiveScopeSetting {
|
|
70
|
+
/**
|
|
71
|
+
* Hexadecimal/Rgba/Name color to be applied in the scope
|
|
72
|
+
*/
|
|
73
|
+
color?: string;
|
|
74
|
+
/**
|
|
75
|
+
* The Scope Type
|
|
76
|
+
*/
|
|
77
|
+
scope: IFilterScope;
|
|
78
|
+
}
|
|
26
79
|
export {};
|
|
27
80
|
//# sourceMappingURL=filter-panel.interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-panel.interfaces.d.ts","sourceRoot":"","sources":["../../src/resources/filter-panel.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,WAAW,4BAA4B;IAC3C,
|
|
1
|
+
{"version":3,"file":"filter-panel.interfaces.d.ts","sourceRoot":"","sources":["../../src/resources/filter-panel.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,gBAAgB,CAAC,EAAE,mCAAmC,EAAE,CAAC;IACzD;;OAEG;IACH,cAAc,CAAC,EAAE,iCAAiC,EAAE,CAAC;IACrD;;OAEG;IACH,cAAc,CAAC,EAAE,mCAAmC,EAAE,CAAC;IACvD;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,gBAAgB,CAAC,EAAE,4BAA4B,CAAC;CACjD;AAED,UAAU,8BAA8B;IACtC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,UAAU,iCACR,SAAQ,8BAA8B;IACtC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,UAAU,mCACR,SAAQ,iCAAiC;IACzC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,UAAU,mCAAmC;IAC3C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;CACrB"}
|