@qrvey/filters 0.0.1 → 0.0.2

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/classes/FilterAdapter.d.ts +97 -0
  3. package/dist/classes/FilterAdapter.d.ts.map +1 -0
  4. package/dist/classes/FilterAdapter.js +113 -0
  5. package/dist/classes/FilterBuilder.d.ts +37 -4
  6. package/dist/classes/FilterBuilder.d.ts.map +1 -1
  7. package/dist/classes/FilterBuilder.js +55 -3
  8. package/dist/classes/FilterManager.d.ts +55 -11
  9. package/dist/classes/FilterManager.d.ts.map +1 -1
  10. package/dist/classes/FilterManager.js +64 -14
  11. package/dist/classes/FilterResources.d.ts +14 -14
  12. package/dist/classes/FilterResources.d.ts.map +1 -1
  13. package/dist/classes/FilterResources.js +17 -17
  14. package/dist/classes/{FilterSearch.d.ts → FilterSearcher.d.ts} +23 -4
  15. package/dist/classes/FilterSearcher.d.ts.map +1 -0
  16. package/dist/classes/{FilterSearch.js → FilterSearcher.js} +37 -7
  17. package/dist/classes/index.d.ts +1 -1
  18. package/dist/classes/index.d.ts.map +1 -1
  19. package/dist/classes/index.js +1 -1
  20. package/dist/helpers/filter-adapt.helpers.d.ts +21 -0
  21. package/dist/helpers/filter-adapt.helpers.d.ts.map +1 -0
  22. package/dist/helpers/filter-adapt.helpers.js +230 -0
  23. package/dist/helpers/filter-settings.helpers.d.ts +2 -2
  24. package/dist/helpers/filter-settings.helpers.d.ts.map +1 -1
  25. package/dist/helpers/filter-settings.helpers.js +6 -6
  26. package/dist/helpers/getFilterId.d.ts.map +1 -1
  27. package/dist/helpers/getFilterId.js +6 -4
  28. package/dist/helpers/getFilterType.d.ts +6 -3
  29. package/dist/helpers/getFilterType.d.ts.map +1 -1
  30. package/dist/helpers/getFilterType.js +5 -4
  31. package/dist/helpers/utils.helpers.d.ts +26 -0
  32. package/dist/helpers/utils.helpers.d.ts.map +1 -0
  33. package/dist/helpers/utils.helpers.js +26 -0
  34. package/dist/models/filter-builder.models.d.ts +15 -1
  35. package/dist/models/filter-builder.models.d.ts.map +1 -1
  36. package/dist/models/filter-resources.models.d.ts +11 -11
  37. package/dist/models/filter-resources.models.d.ts.map +1 -1
  38. package/dist/resources/filter-functions.resources.d.ts +2 -2
  39. package/dist/resources/filter-functions.resources.d.ts.map +1 -1
  40. package/dist/resources/filter-functions.resources.js +1 -1
  41. package/dist/resources/filter-grouping.resources.d.ts +7 -7
  42. package/dist/resources/filter-logic.resources.d.ts +136 -0
  43. package/dist/resources/filter-logic.resources.d.ts.map +1 -0
  44. package/dist/resources/filter-logic.resources.js +25 -0
  45. package/dist/resources/filter-panel.interfaces.d.ts +6 -0
  46. package/dist/resources/filter-panel.interfaces.d.ts.map +1 -1
  47. package/dist/resources/filter-scopes.resources.d.ts +36 -11
  48. package/dist/resources/filter-scopes.resources.d.ts.map +1 -1
  49. package/dist/resources/filter-scopes.resources.js +17 -3
  50. package/dist/resources/filter-validators.resources.d.ts +5 -5
  51. package/dist/resources/filter-values.resources.d.ts +0 -8
  52. package/dist/resources/filter-values.resources.d.ts.map +1 -1
  53. package/dist/resources/filter-values.resources.js +13 -0
  54. package/dist/resources/filter-visual.resources.d.ts +93 -0
  55. package/dist/resources/filter-visual.resources.d.ts.map +1 -0
  56. package/dist/resources/filter-visual.resources.js +2 -0
  57. package/dist/resources/filters.resources.d.ts +65 -13
  58. package/dist/resources/filters.resources.d.ts.map +1 -1
  59. package/dist/resources/filters.resources.js +1 -27
  60. package/jest.config.js +4 -1
  61. package/package.json +15 -11
  62. package/src/classes/FilterAdapter.ts +158 -0
  63. package/src/classes/FilterBuilder.ts +97 -7
  64. package/src/classes/FilterManager.ts +83 -15
  65. package/src/classes/FilterResources.ts +39 -38
  66. package/src/classes/{FilterSearch.ts → FilterSearcher.ts} +63 -12
  67. package/src/classes/index.ts +1 -1
  68. package/src/helpers/filter-adapt.helpers.ts +379 -0
  69. package/src/helpers/filter-settings.helpers.ts +9 -9
  70. package/src/helpers/getFilterId.ts +7 -3
  71. package/src/helpers/getFilterType.ts +10 -6
  72. package/src/helpers/utils.helpers.ts +37 -0
  73. package/src/models/filter-builder.models.ts +23 -1
  74. package/src/models/filter-resources.models.ts +13 -13
  75. package/src/resources/filter-functions.resources.ts +2 -2
  76. package/src/resources/filter-grouping.resources.ts +7 -7
  77. package/src/resources/filter-logic.resources.ts +149 -0
  78. package/src/resources/filter-panel.interfaces.ts +8 -0
  79. package/src/resources/filter-scopes.resources.ts +36 -12
  80. package/src/resources/filter-validators.resources.ts +5 -5
  81. package/src/resources/filter-values.resources.ts +14 -14
  82. package/src/resources/filter-visual.resources.ts +102 -0
  83. package/src/resources/filters.resources.ts +65 -47
  84. package/tests/helpers/getFilterId.test.ts +123 -0
  85. package/dist/classes/FilterSearch.d.ts.map +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ ### Changelog
2
+
3
+ All notable changes to this project will be documented in this file. Dates are displayed in UTC.
4
+
5
+ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
+
7
+ #### 0.0.2
8
+
9
+ - feat: :star: Starting the Filter Manager bundle [`545923a`](https://bitbucket.org/qrvey/qrvey_filters/commits/545923a96a626ef26656baf30000bd5c38002792)
10
+ - feat: :zap: added filter adapts in the manager [`5541f1b`](https://bitbucket.org/qrvey/qrvey_filters/commits/5541f1bbdb4d4249bff15de4e1b212a6fa7159f2)
11
+ - build: Initial project configuration [`bceeb5c`](https://bitbucket.org/qrvey/qrvey_filters/commits/bceeb5cf5ff682c39c7cd4f06c4c862e09694ec3)
@@ -0,0 +1,97 @@
1
+ import { IDataset, IFUData } from "@qrvey/utils";
2
+ import { IFilterLogic } from "../resources/filter-logic.resources";
3
+ import { IFilterPanelInteractiveTable } from "../resources/filter-panel.interfaces";
4
+ import { IFilterVisual } from "../resources/filter-visual.resources";
5
+ import { IFilter } from "../resources/filters.resources";
6
+ /**
7
+ * Class to adapt the filters
8
+ */
9
+ export declare class FilterAdapter {
10
+ protected filters: IFilter[];
11
+ protected datasets: IDataset[];
12
+ protected interactiveTable?: IFilterPanelInteractiveTable | undefined;
13
+ /**
14
+ * The Logic filters
15
+ */
16
+ private _logic?;
17
+ /**
18
+ * The visual filters
19
+ */
20
+ private _visual?;
21
+ /**
22
+ * The old Filter Data structure
23
+ */
24
+ private _legacyVisual?;
25
+ /**
26
+ * Constructor
27
+ * @param filters the collection of filters
28
+ * @param datasets the collection of datasets info
29
+ * @param interactiveTable table of interaction properties for each section
30
+ */
31
+ constructor(filters?: IFilter[], datasets?: IDataset[], interactiveTable?: IFilterPanelInteractiveTable | undefined);
32
+ /**
33
+ *
34
+ */
35
+ private sync;
36
+ /**
37
+ * Generates a visual filter structure from the filter collection.
38
+ * @returns a visual Filter structure
39
+ */
40
+ private filterToLegacyVisual;
41
+ /**
42
+ * Generates a logic filters structure from the filter collection.
43
+ * @returns the Logic Filters
44
+ */
45
+ private filterToLogic;
46
+ /**
47
+ * Generates a visual filter structure from the filter collection.
48
+ * @returns a visual Filter structure
49
+ */
50
+ private filterToVisual;
51
+ /**
52
+ * Gets the legacy filter visual attribute
53
+ * @returns the legacy visual filter
54
+ */
55
+ get legacyVisual(): IFUData | undefined;
56
+ /**
57
+ * Gets the filter logic attribute
58
+ * @returns the logic filter
59
+ */
60
+ get logic(): IFilterLogic[] | undefined;
61
+ /**
62
+ * Gets the filter visual attribute
63
+ * @returns the visual filter
64
+ */
65
+ get visual(): IFilterVisual | undefined;
66
+ /**
67
+ * Sets the datasets atribute
68
+ * @param datasets the collection of dataset info
69
+ */
70
+ setDatasets(datasets?: IDataset[]): void;
71
+ /**
72
+ * Sets the collection of filters atribute
73
+ * @param filters the filters
74
+ */
75
+ setFilters(filters: IFilter[]): void;
76
+ /**
77
+ * Sets the table of interactive table attribute
78
+ * @param interactiveTable table of interaction properties for each section
79
+ */
80
+ setInteractiveTable(interactiveTable: IFilterPanelInteractiveTable): void;
81
+ /**
82
+ * Sets the filter legacy visual attribute
83
+ * @param legacyVisual the legacy visual filters
84
+ */
85
+ private setLegacyVisual;
86
+ /**
87
+ * Sets the filter logic attribute
88
+ * @param logic the logic filters
89
+ */
90
+ private setLogic;
91
+ /**
92
+ * Sets the filter visual attribute
93
+ * @param visual the visual filters
94
+ */
95
+ private setVisual;
96
+ }
97
+ //# sourceMappingURL=FilterAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FilterAdapter.d.ts","sourceRoot":"","sources":["../../src/classes/FilterAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAMjD,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzD;;GAEG;AACH,qBAAa,aAAa;IAuBtB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE;IAC5B,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE;IAC9B,SAAS,CAAC,gBAAgB,CAAC;IAxB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,CAAiB;IAEhC;;OAEG;IACH,OAAO,CAAC,OAAO,CAAC,CAAgB;IAEhC;;OAEG;IACH,OAAO,CAAC,aAAa,CAAC,CAAU;IAEhC;;;;;OAKG;gBAES,OAAO,GAAE,OAAO,EAAO,EACvB,QAAQ,GAAE,QAAQ,EAAO,EACzB,gBAAgB,CAAC,0CAA8B;IAK3D;;OAEG;IACH,OAAO,CAAC,IAAI;IAMZ;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAIrB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAItB;;;OAGG;IACH,IAAI,YAAY,IAAI,OAAO,GAAG,SAAS,CAEtC;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,YAAY,EAAE,GAAG,SAAS,CAEtC;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,aAAa,GAAG,SAAS,CAEtC;IAED;;;OAGG;IACI,WAAW,CAAC,QAAQ,GAAE,QAAQ,EAAO,GAAG,IAAI;IAKnD;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI;IAK3C;;;OAGG;IACI,mBAAmB,CACxB,gBAAgB,EAAE,4BAA4B,GAC7C,IAAI;IAKP;;;OAGG;IACH,OAAO,CAAC,eAAe;IAIvB;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;OAGG;IACH,OAAO,CAAC,SAAS;CAGlB"}
@@ -0,0 +1,113 @@
1
+ import { filterToLegacyVisual, filterToVisual, } from "../helpers/filter-adapt.helpers";
2
+ /**
3
+ * Class to adapt the filters
4
+ */
5
+ export class FilterAdapter {
6
+ /**
7
+ * Constructor
8
+ * @param filters the collection of filters
9
+ * @param datasets the collection of datasets info
10
+ * @param interactiveTable table of interaction properties for each section
11
+ */
12
+ constructor(filters = [], datasets = [], interactiveTable) {
13
+ this.filters = filters;
14
+ this.datasets = datasets;
15
+ this.interactiveTable = interactiveTable;
16
+ this.sync();
17
+ }
18
+ /**
19
+ *
20
+ */
21
+ sync() {
22
+ this.setVisual(this.filterToVisual());
23
+ this.setLegacyVisual(this.filterToLegacyVisual());
24
+ this.setLogic(this.filterToLogic());
25
+ }
26
+ /**
27
+ * Generates a visual filter structure from the filter collection.
28
+ * @returns a visual Filter structure
29
+ */
30
+ filterToLegacyVisual() {
31
+ return filterToLegacyVisual(this.filters, this.datasets, this.interactiveTable);
32
+ }
33
+ /**
34
+ * Generates a logic filters structure from the filter collection.
35
+ * @returns the Logic Filters
36
+ */
37
+ filterToLogic() {
38
+ return [];
39
+ }
40
+ /**
41
+ * Generates a visual filter structure from the filter collection.
42
+ * @returns a visual Filter structure
43
+ */
44
+ filterToVisual() {
45
+ return filterToVisual(this.filters, this.datasets, this.interactiveTable);
46
+ }
47
+ /**
48
+ * Gets the legacy filter visual attribute
49
+ * @returns the legacy visual filter
50
+ */
51
+ get legacyVisual() {
52
+ return this._legacyVisual;
53
+ }
54
+ /**
55
+ * Gets the filter logic attribute
56
+ * @returns the logic filter
57
+ */
58
+ get logic() {
59
+ return this._logic;
60
+ }
61
+ /**
62
+ * Gets the filter visual attribute
63
+ * @returns the visual filter
64
+ */
65
+ get visual() {
66
+ return this._visual;
67
+ }
68
+ /**
69
+ * Sets the datasets atribute
70
+ * @param datasets the collection of dataset info
71
+ */
72
+ setDatasets(datasets = []) {
73
+ this.datasets = datasets;
74
+ this.sync();
75
+ }
76
+ /**
77
+ * Sets the collection of filters atribute
78
+ * @param filters the filters
79
+ */
80
+ setFilters(filters) {
81
+ this.filters = filters;
82
+ this.sync();
83
+ }
84
+ /**
85
+ * Sets the table of interactive table attribute
86
+ * @param interactiveTable table of interaction properties for each section
87
+ */
88
+ setInteractiveTable(interactiveTable) {
89
+ this.interactiveTable = interactiveTable;
90
+ this.sync();
91
+ }
92
+ /**
93
+ * Sets the filter legacy visual attribute
94
+ * @param legacyVisual the legacy visual filters
95
+ */
96
+ setLegacyVisual(legacyVisual) {
97
+ this._legacyVisual = legacyVisual;
98
+ }
99
+ /**
100
+ * Sets the filter logic attribute
101
+ * @param logic the logic filters
102
+ */
103
+ setLogic(logic) {
104
+ this._logic = logic;
105
+ }
106
+ /**
107
+ * Sets the filter visual attribute
108
+ * @param visual the visual filters
109
+ */
110
+ setVisual(visual) {
111
+ this._visual = visual;
112
+ }
113
+ }
@@ -1,11 +1,11 @@
1
- import { IFilterBuilderAdd, IFilterBuilderAddValue, IFilterBuilderDelete, IFilterBuilderDeleteValue, IFilterBuilderEdit, IFilterBuilderEditValue, IFilterBuilderMultipleReturn, IFilterBuilderSingleReturn } from "../models/filter-builder.models";
2
- import { IFilterBuilderEditSettings } from "../resources/filter-functions.resources";
1
+ import { IFilterBuilderAdd, IFilterBuilderAddValue, IFilterBuilderDelete, IFilterBuilderDeleteValue, IFilterBuilderEdit, IFilterBuilderEditValue, IFilterBuilderMultipleReturn, IFilterBuilderSet, IFilterBuilderSingleReturn } from "../models/filter-builder.models";
2
+ import { IFilterBuilderEditSettings, IFilterParamSettings } from "../resources/filter-functions.resources";
3
3
  import { IFilterValue } from "../resources/filter-values.resources";
4
4
  import { IFilter } from "../resources/filters.resources";
5
5
  /**
6
6
  * Class to build new filters and manipulate ones.
7
7
  */
8
- export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderAddValue, IFilterBuilderDelete, IFilterBuilderDeleteValue, IFilterBuilderEdit, IFilterBuilderEditValue {
8
+ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderAddValue, IFilterBuilderDelete, IFilterBuilderDeleteValue, IFilterBuilderEdit, IFilterBuilderEditValue, IFilterBuilderSet {
9
9
  protected filters: IFilter[];
10
10
  /**
11
11
  * Instance to search filters
@@ -15,7 +15,7 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
15
15
  * Constructor
16
16
  * @param filters the collection of filters
17
17
  */
18
- constructor(filters: IFilter[]);
18
+ constructor(filters?: IFilter[]);
19
19
  /**
20
20
  * Adds one filter into the collection.
21
21
  * Inserts it next to the last similar filter
@@ -46,6 +46,13 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
46
46
  * @returns the new filter collection
47
47
  */
48
48
  addValues(id: string, values: IFilterValue[]): IFilterBuilderMultipleReturn;
49
+ /**
50
+ * Builds an filter structure based on given params
51
+ * @param filter the partial filter params
52
+ * @param automaticId flag to generate a new filter ID based on the filter info
53
+ * @returns the complete filter structure
54
+ */
55
+ createFilter(filter: Partial<IFilter>, automaticId?: boolean): IFilter;
49
56
  /**
50
57
  * Removes one filter from the collection
51
58
  * @param id the ID to search the filter to remove
@@ -58,6 +65,13 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
58
65
  * @returns the new filter collection
59
66
  */
60
67
  deleteMutiple(ids: string[]): IFilterBuilderMultipleReturn;
68
+ /**
69
+ * Removes various filters by params
70
+ * @param params params to search the filters to delete
71
+ * @param settings settings for this function
72
+ * @returns the new collection of filters
73
+ */
74
+ deleteByParams(params: Partial<IFilter>, settings?: IFilterParamSettings): IFilterBuilderMultipleReturn;
61
75
  /**
62
76
  * Removes one value from filter
63
77
  * @param id the ID to search the filter to remove value
@@ -104,9 +118,28 @@ export declare class FilterBuilder implements IFilterBuilderAdd, IFilterBuilderA
104
118
  * @returns the new filter collection
105
119
  */
106
120
  editValues(id: string, values: IFilterValue[], indexes: number[]): IFilterBuilderMultipleReturn;
121
+ /**
122
+ * **************************************************************************************************
123
+ ****************************************** Setters *************************************************
124
+ ****************************************************************************************************
125
+ */
126
+ /**
127
+ * Sets the given filters by param
128
+ * - Remove the filters by the sucesfull conditions and replace the given ones
129
+ * @param filters the filters to set
130
+ * @param params params to search the filters
131
+ * @param settings settings for this function
132
+ * @returns the new collection of filters
133
+ */
134
+ replaceByParams(filters: IFilter[], params: Partial<IFilter>, settings?: IFilterParamSettings): IFilterBuilderMultipleReturn;
107
135
  /**
108
136
  * Method to sync the Filter instances
109
137
  */
110
138
  private sync;
139
+ /**
140
+ * Sets the filters
141
+ * @param filters the new collection of filters to set
142
+ */
143
+ setFilters(filters: IFilter[]): void;
111
144
  }
112
145
  //# sourceMappingURL=FilterBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterBuilder.d.ts","sourceRoot":"","sources":["../../src/classes/FilterBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAA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OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,OAAO,EAAE,EACvC,GAAG,EAAE,MAAM,EAAE,EACb,QAAQ,CAAC,EAAE,0BAA0B,GACpC,4BAA4B;IA2B/B;;;;;;OAMG;IACH,SAAS,CACP,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,GACZ,0BAA0B;IAgB7B;;;;;;OAMG;IACI,UAAU,CACf,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,YAAY,EAAE,EACtB,OAAO,EAAE,MAAM,EAAE,GAChB,4BAA4B;IAqB/B;;OAEG;IACH,OAAO,CAAC,IAAI;CAGb"}
1
+ {"version":3,"file":"FilterBuilder.d.ts","sourceRoot":"","sources":["../../src/classes/FilterBuilder.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,4BAA4B,EAC5B,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAkB,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;GAEG;AACH,qBAAa,aACX,YACE,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB;IAWP,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE;IATxC;;OAEG;IACH,OAAO,CAAC,YAAY,CAAiB;IAErC;;;OAGG;gBACmB,OAAO,GAAE,OAAO,EAAO;IAI7C;;;;;;OAMG;IACI,SAAS,CACd,SAAS,EAAE,OAAO,EAClB,WAAW,UAAO,GACjB,0BAA0B;IAwB7B;;;;;;OAMG;IACI,UAAU,CACf,UAAU,EAA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IAgB7B;;;;;;OAMG;IACI,UAAU,CACf,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,YAAY,EAAE,EACtB,OAAO,EAAE,MAAM,EAAE,GAChB,4BAA4B;IAqB/B;;;;OAIG;IAEH;;;;;;;OAOG;IACH,eAAe,CACb,OAAO,EAAE,OAAO,EAAE,EAClB,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EACxB,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,4BAA4B;IAQ/B;;OAEG;IACH,OAAO,CAAC,IAAI;IAIZ;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI;CAG5C"}
@@ -1,7 +1,8 @@
1
1
  import { getLastIndexFromArray, isEmpty, objectCopy } from "@qrvey/utils";
2
- import { FilterSearch } from "./FilterSearch";
2
+ import { FilterSearcher } from "./FilterSearcher";
3
3
  import { getEditFiltersSettings } from "../helpers/filter-settings.helpers";
4
4
  import { getFilterId } from "../helpers/getFilterId";
5
+ import { DEFAULT_FILTER } from "../resources/filters.resources";
5
6
  /**
6
7
  * Class to build new filters and manipulate ones.
7
8
  */
@@ -10,9 +11,9 @@ export class FilterBuilder {
10
11
  * Constructor
11
12
  * @param filters the collection of filters
12
13
  */
13
- constructor(filters) {
14
+ constructor(filters = []) {
14
15
  this.filters = filters;
15
- this.searchEngine = new FilterSearch(filters);
16
+ this.searchEngine = new FilterSearcher(filters);
16
17
  }
17
18
  /**
18
19
  * Adds one filter into the collection.
@@ -104,6 +105,19 @@ export class FilterBuilder {
104
105
  this.sync();
105
106
  return { resulting: this.filters, affected: affectedFilters };
106
107
  }
108
+ /**
109
+ * Builds an filter structure based on given params
110
+ * @param filter the partial filter params
111
+ * @param automaticId flag to generate a new filter ID based on the filter info
112
+ * @returns the complete filter structure
113
+ */
114
+ createFilter(filter, automaticId = true) {
115
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
116
+ const newFilter = Object.assign(Object.assign({}, DEFAULT_FILTER), { aggregateType: (_a = filter.aggregateType) !== null && _a !== void 0 ? _a : DEFAULT_FILTER.aggregateType, collapsed: (_b = filter.collapsed) !== null && _b !== void 0 ? _b : DEFAULT_FILTER.collapsed, columnId: (_c = filter.columnId) !== null && _c !== void 0 ? _c : DEFAULT_FILTER.columnId, columnType: (_d = filter.columnType) !== null && _d !== void 0 ? _d : DEFAULT_FILTER.columnType, datasetId: (_e = filter.datasetId) !== null && _e !== void 0 ? _e : DEFAULT_FILTER.datasetId, deletable: (_f = filter.deletable) !== null && _f !== void 0 ? _f : DEFAULT_FILTER.deletable, displayed: (_g = filter.displayed) !== null && _g !== void 0 ? _g : DEFAULT_FILTER.displayed, editable: (_h = filter.editable) !== null && _h !== void 0 ? _h : DEFAULT_FILTER.editable, enableable: (_j = filter.enableable) !== null && _j !== void 0 ? _j : DEFAULT_FILTER.enableable, enabled: (_k = filter.enabled) !== null && _k !== void 0 ? _k : DEFAULT_FILTER.enabled, id: "", operator: filter.operator || DEFAULT_FILTER.operator, scope: filter.scope || DEFAULT_FILTER.scope, scopeId: filter.scopeId || DEFAULT_FILTER.scopeId, validator: filter.validator || DEFAULT_FILTER.validator, grouping: filter.grouping || DEFAULT_FILTER.grouping, section: filter.section || DEFAULT_FILTER.section, selectAll: (_l = filter.selectAll) !== null && _l !== void 0 ? _l : DEFAULT_FILTER.selectAll, values: filter.values || DEFAULT_FILTER.values });
117
+ if (automaticId)
118
+ newFilter.id = getFilterId(newFilter);
119
+ return newFilter;
120
+ }
107
121
  /**
108
122
  * Removes one filter from the collection
109
123
  * @param id the ID to search the filter to remove
@@ -141,6 +155,18 @@ export class FilterBuilder {
141
155
  this.sync();
142
156
  return { resulting: this.filters, affected: deletedFilters };
143
157
  }
158
+ /**
159
+ * Removes various filters by params
160
+ * @param params params to search the filters to delete
161
+ * @param settings settings for this function
162
+ * @returns the new collection of filters
163
+ */
164
+ deleteByParams(params, settings) {
165
+ const affected = this.searchEngine.filterByParams(params, settings);
166
+ this.filters = this.searchEngine.excludeByParams(params, settings);
167
+ this.sync();
168
+ return { resulting: this.filters, affected };
169
+ }
144
170
  /**
145
171
  * Removes one value from filter
146
172
  * @param id the ID to search the filter to remove value
@@ -281,10 +307,36 @@ export class FilterBuilder {
281
307
  this.sync();
282
308
  return { resulting: this.filters, affected: affectedFilters };
283
309
  }
310
+ /**
311
+ * **************************************************************************************************
312
+ ****************************************** Setters *************************************************
313
+ ****************************************************************************************************
314
+ */
315
+ /**
316
+ * Sets the given filters by param
317
+ * - Remove the filters by the sucesfull conditions and replace the given ones
318
+ * @param filters the filters to set
319
+ * @param params params to search the filters
320
+ * @param settings settings for this function
321
+ * @returns the new collection of filters
322
+ */
323
+ replaceByParams(filters, params, settings) {
324
+ this.filters = this.searchEngine.excludeByParams(params, settings);
325
+ const resulting = this.addMutiple(filters);
326
+ this.sync();
327
+ return { resulting: this.filters, affected: resulting.affected };
328
+ }
284
329
  /**
285
330
  * Method to sync the Filter instances
286
331
  */
287
332
  sync() {
288
333
  this.searchEngine.setFilters(this.filters);
289
334
  }
335
+ /**
336
+ * Sets the filters
337
+ * @param filters the new collection of filters to set
338
+ */
339
+ setFilters(filters) {
340
+ this.filters = filters;
341
+ }
290
342
  }
@@ -1,30 +1,74 @@
1
+ import { IDataset } from "@qrvey/utils";
2
+ import { FilterAdapter } from "./FilterAdapter";
1
3
  import { FilterBuilder } from "./FilterBuilder";
2
- import { FilterSearch } from "./FilterSearch";
4
+ import { FilterSearcher } from "./FilterSearcher";
5
+ import { IFilterPanelInteractiveTable } from "../resources";
3
6
  import { IFilter } from "../resources/filters.resources";
4
7
  /**
5
- *
8
+ * Class to manage the filters
6
9
  */
7
10
  export declare class FilterManager {
8
11
  protected filters: IFilter[];
12
+ protected datasets: IDataset[];
13
+ protected interactiveTable?: IFilterPanelInteractiveTable | undefined;
9
14
  /**
10
- * Instance to search filters
15
+ * Instance to adapt filters
11
16
  */
12
- private searchEngine;
17
+ private _adapt;
13
18
  /**
14
19
  * Instance to build filters
15
20
  */
16
- private builder;
21
+ private _builder;
17
22
  /**
18
- * Class to get static resources
23
+ * Instance to search filters
19
24
  */
25
+ private _searchEngine;
20
26
  /**
21
27
  * Constructor
22
28
  * @param filters the collection of filters
29
+ * @param datasets the collection of datasets info
30
+ * @param interactiveTable table of interaction properties for each section
31
+ */
32
+ constructor(filters?: IFilter[], datasets?: IDataset[], interactiveTable?: IFilterPanelInteractiveTable | undefined);
33
+ /**
34
+ * **************************************************************************************************
35
+ ****************************************** Getters *************************************************
36
+ ****************************************************************************************************
37
+ */
38
+ /**
39
+ * Gets the builder methods
40
+ * @returns the builder methods
41
+ */
42
+ get builder(): FilterBuilder;
43
+ /**
44
+ * Gets the adapt methods
45
+ * @returns the adapt methods
46
+ */
47
+ get adapt(): FilterAdapter;
48
+ /**
49
+ * Gets the search methods
50
+ * @returns the search methods
51
+ */
52
+ get search(): FilterSearcher;
53
+ /**
54
+ * **************************************************************************************************
55
+ ****************************************** Setters *************************************************
56
+ ****************************************************************************************************
57
+ */
58
+ /**
59
+ * Sets the datasets
60
+ * @param datasets the collection of dataset info
61
+ */
62
+ setDatasets(datasets: IDataset[]): void;
63
+ /**
64
+ * Sets the filters
65
+ * @param filters the new collection of filters to set
66
+ */
67
+ setFilters(filters?: IFilter[]): void;
68
+ /**
69
+ * Sets the table of interactive table
70
+ * @param interactiveTable table of interaction properties for each section
23
71
  */
24
- constructor(filters: IFilter[]);
25
- manager(): {
26
- searchEngine: FilterSearch;
27
- buider: FilterBuilder;
28
- };
72
+ setInteractiveTable(interactiveTable: IFilterPanelInteractiveTable): void;
29
73
  }
30
74
  //# sourceMappingURL=FilterManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FilterManager.d.ts","sourceRoot":"","sources":["../../src/classes/FilterManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,OAA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;;;;OAIG;IAEH;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,IAAI;IAI9C;;;OAGG;IACI,UAAU,CAAC,OAAO,GAAE,OAAO,EAAO,GAAG,IAAI;IAMhD;;;OAGG;IACI,mBAAmB,CACxB,gBAAgB,EAAE,4BAA4B,GAC7C,IAAI;CAGR"}
@@ -1,26 +1,76 @@
1
+ import { FilterAdapter } from "./FilterAdapter";
1
2
  import { FilterBuilder } from "./FilterBuilder";
2
- import { FilterSearch } from "./FilterSearch";
3
+ import { FilterSearcher } from "./FilterSearcher";
3
4
  /**
4
- *
5
+ * Class to manage the filters
5
6
  */
6
7
  export class FilterManager {
7
- /**
8
- * Class to get static resources
9
- */
10
- // private resources: FilterResources;
11
8
  /**
12
9
  * Constructor
13
10
  * @param filters the collection of filters
11
+ * @param datasets the collection of datasets info
12
+ * @param interactiveTable table of interaction properties for each section
14
13
  */
15
- constructor(filters) {
14
+ constructor(filters = [], datasets = [], interactiveTable) {
16
15
  this.filters = filters;
17
- this.searchEngine = new FilterSearch(filters);
18
- this.builder = new FilterBuilder(filters);
16
+ this.datasets = datasets;
17
+ this.interactiveTable = interactiveTable;
18
+ this._searchEngine = new FilterSearcher(filters);
19
+ this._builder = new FilterBuilder(filters);
20
+ this._adapt = new FilterAdapter(filters, datasets, interactiveTable);
21
+ }
22
+ /**
23
+ * **************************************************************************************************
24
+ ****************************************** Getters *************************************************
25
+ ****************************************************************************************************
26
+ */
27
+ /**
28
+ * Gets the builder methods
29
+ * @returns the builder methods
30
+ */
31
+ get builder() {
32
+ return this._builder;
33
+ }
34
+ /**
35
+ * Gets the adapt methods
36
+ * @returns the adapt methods
37
+ */
38
+ get adapt() {
39
+ return this._adapt;
19
40
  }
20
- manager() {
21
- return {
22
- searchEngine: this.searchEngine,
23
- buider: this.builder,
24
- };
41
+ /**
42
+ * Gets the search methods
43
+ * @returns the search methods
44
+ */
45
+ get search() {
46
+ return this._searchEngine;
47
+ }
48
+ /**
49
+ * **************************************************************************************************
50
+ ****************************************** Setters *************************************************
51
+ ****************************************************************************************************
52
+ */
53
+ /**
54
+ * Sets the datasets
55
+ * @param datasets the collection of dataset info
56
+ */
57
+ setDatasets(datasets) {
58
+ this._adapt.setDatasets(datasets);
59
+ }
60
+ /**
61
+ * Sets the filters
62
+ * @param filters the new collection of filters to set
63
+ */
64
+ setFilters(filters = []) {
65
+ this._builder.setFilters(filters);
66
+ this._searchEngine.setFilters(filters);
67
+ this._adapt.setFilters(filters);
68
+ }
69
+ /**
70
+ * Sets the table of interactive table
71
+ * @param interactiveTable table of interaction properties for each section
72
+ */
73
+ setInteractiveTable(interactiveTable) {
74
+ this.interactiveTable = interactiveTable;
25
75
  }
26
76
  }