@geosdi/ngx-utility-service 1.2.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,44 +8,14 @@ import _ from 'lodash';
|
|
|
8
8
|
*/
|
|
9
9
|
class NgxFiltersCacheService {
|
|
10
10
|
constructor() {
|
|
11
|
-
this._bindingValuesMap = new Map();
|
|
12
11
|
this._filtersValuesMap = new Map();
|
|
13
12
|
}
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
get bindingValuesMap() {
|
|
18
|
-
return this._bindingValuesMap;
|
|
19
|
-
}
|
|
20
13
|
/**
|
|
21
14
|
*
|
|
22
15
|
*/
|
|
23
16
|
get filtersValuesMap() {
|
|
24
17
|
return this._filtersValuesMap;
|
|
25
18
|
}
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @param key
|
|
29
|
-
*/
|
|
30
|
-
bindValue(key) {
|
|
31
|
-
return this._bindingValuesMap.get(key);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
*
|
|
35
|
-
* @param key
|
|
36
|
-
*/
|
|
37
|
-
addValue(key, value) {
|
|
38
|
-
this._bindingValuesMap.set(key, value);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @param key
|
|
43
|
-
*/
|
|
44
|
-
getValue(key) {
|
|
45
|
-
return this._bindingValuesMap.has(key)
|
|
46
|
-
? this._bindingValuesMap.get(key)
|
|
47
|
-
: null;
|
|
48
|
-
}
|
|
49
19
|
/**
|
|
50
20
|
*
|
|
51
21
|
* @param key
|
|
@@ -59,21 +29,30 @@ class NgxFiltersCacheService {
|
|
|
59
29
|
*
|
|
60
30
|
* @param key
|
|
61
31
|
*/
|
|
62
|
-
|
|
63
|
-
return this.
|
|
32
|
+
hasFilter(key) {
|
|
33
|
+
return this._filtersValuesMap.has(key);
|
|
64
34
|
}
|
|
65
35
|
/**
|
|
66
36
|
*
|
|
67
37
|
* @param key
|
|
68
38
|
* @param value
|
|
39
|
+
* @param type
|
|
69
40
|
*/
|
|
70
|
-
saveFilter(key, value) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
41
|
+
saveFilter(key, value, type = false) {
|
|
42
|
+
if (_.isNil(key)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const items = _.isArray(value)
|
|
46
|
+
? value
|
|
47
|
+
: _.isNil(value)
|
|
48
|
+
? []
|
|
49
|
+
: [value];
|
|
50
|
+
const cleaned = items.filter((item) => !_.isNil(_.has(item, "value") ? item.value : item));
|
|
51
|
+
if (cleaned.length === 0) {
|
|
52
|
+
this._filtersValuesMap.delete(key);
|
|
53
|
+
return;
|
|
76
54
|
}
|
|
55
|
+
this._filtersValuesMap.set(key, cleaned);
|
|
77
56
|
}
|
|
78
57
|
/**
|
|
79
58
|
*
|
|
@@ -83,9 +62,6 @@ class NgxFiltersCacheService {
|
|
|
83
62
|
if (this._filtersValuesMap.has(key)) {
|
|
84
63
|
this._filtersValuesMap.delete(key);
|
|
85
64
|
}
|
|
86
|
-
if (this._bindingValuesMap.has(key)) {
|
|
87
|
-
this._bindingValuesMap.delete(key);
|
|
88
|
-
}
|
|
89
65
|
}
|
|
90
66
|
/**
|
|
91
67
|
*
|
|
@@ -98,7 +74,17 @@ class NgxFiltersCacheService {
|
|
|
98
74
|
*/
|
|
99
75
|
clearFilters() {
|
|
100
76
|
this._filtersValuesMap.clear();
|
|
101
|
-
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @param item
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
toCanonical(item) {
|
|
84
|
+
if (_.has(item, "value")) {
|
|
85
|
+
return { name: item.name ?? item.value, value: item.value };
|
|
86
|
+
}
|
|
87
|
+
return { name: item, value: item };
|
|
102
88
|
}
|
|
103
89
|
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: NgxFiltersCacheService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
104
90
|
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: NgxFiltersCacheService, providedIn: "root" }); }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geosdi-ngx-utility-service.mjs","sources":["../../../../projects/geosdi/support/ngx-utility-service/src/lib/ngx-filters-cache.service.ts","../../../../projects/geosdi/support/ngx-utility-service/src/index.ts","../../../../projects/geosdi/support/ngx-utility-service/src/geosdi-ngx-utility-service.ts"],"sourcesContent":["import { Injectable } from \"@angular/core\";\nimport _ from \"lodash\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\n@Injectable({\n providedIn: \"root\",\n})\nexport class NgxFiltersCacheService {\n private
|
|
1
|
+
{"version":3,"file":"geosdi-ngx-utility-service.mjs","sources":["../../../../projects/geosdi/support/ngx-utility-service/src/lib/ngx-filters-cache.service.ts","../../../../projects/geosdi/support/ngx-utility-service/src/index.ts","../../../../projects/geosdi/support/ngx-utility-service/src/geosdi-ngx-utility-service.ts"],"sourcesContent":["import { Injectable } from \"@angular/core\";\nimport _ from \"lodash\";\n\n/**\n * @author Vito Salvia - CNR IMAA geoSDI Group\n * @email vito.salvia@gmail.com\n */\n@Injectable({\n providedIn: \"root\",\n})\nexport class NgxFiltersCacheService {\n private _filtersValuesMap: Map<string, any> = new Map<string, any>();\n\n /**\n *\n */\n get filtersValuesMap(): Map<string, any> {\n return this._filtersValuesMap;\n }\n\n /**\n *\n * @param key\n */\n getFilter(key: string): any {\n return this._filtersValuesMap.has(key)\n ? this._filtersValuesMap.get(key)\n : null;\n }\n\n /**\n *\n * @param key\n */\n hasFilter(key: string): boolean {\n return this._filtersValuesMap.has(key);\n }\n\n /**\n *\n * @param key\n * @param value\n * @param type\n */\n saveFilter(key: string, value: any, type: boolean = false) {\n if (_.isNil(key)) {\n return;\n }\n const items: any[] = _.isArray(value)\n ? value\n : _.isNil(value)\n ? []\n : [value];\n const cleaned: any[] = items.filter(\n (item: any) => !_.isNil(_.has(item, \"value\") ? item.value : item),\n );\n if (cleaned.length === 0) {\n this._filtersValuesMap.delete(key);\n return;\n }\n this._filtersValuesMap.set(key, cleaned);\n }\n\n /**\n *\n * @param key\n */\n removeFilter(key: string) {\n if (this._filtersValuesMap.has(key)) {\n this._filtersValuesMap.delete(key);\n }\n }\n\n /**\n *\n */\n filtersSize(): number {\n return this._filtersValuesMap.size;\n }\n\n /**\n *\n */\n clearFilters() {\n this._filtersValuesMap.clear();\n }\n\n /**\n *\n * @param item\n * @private\n */\n private toCanonical(item: any): { name: any; value: any } {\n if (_.has(item, \"value\")) {\n return { name: item.name ?? item.value, value: item.value };\n }\n return { name: item, value: item };\n }\n}\n","/*\n * Public API Surface of ngx-utility-service\n */\nexport * from \"./lib/ngx-filters-cache.service\";\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAGA;;;AAGG;MAIU,sBAAsB,CAAA;AAHnC,IAAA,WAAA,GAAA;AAIY,QAAA,IAAA,CAAA,iBAAiB,GAAqB,IAAI,GAAG,EAAe;AAuFvE,IAAA;AArFG;;AAEG;AACH,IAAA,IAAI,gBAAgB,GAAA;QAChB,OAAO,IAAI,CAAC,iBAAiB;IACjC;AAEA;;;AAGG;AACH,IAAA,SAAS,CAAC,GAAW,EAAA;AACjB,QAAA,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG;cAC/B,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG;cAC9B,IAAI;IACd;AAEA;;;AAGG;AACH,IAAA,SAAS,CAAC,GAAW,EAAA;QACjB,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CA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AE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE;QAC/D;QACA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;IACtC;kIAvFS,sBAAsB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAtB,uBAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,sBAAsB,cAFnB,MAAM,EAAA,CAAA,CAAA;;4FAET,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAHlC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE,MAAM;AACrB,iBAAA;;;ACTD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -5,31 +5,11 @@ import * as i0 from '@angular/core';
|
|
|
5
5
|
* @email vito.salvia@gmail.com
|
|
6
6
|
*/
|
|
7
7
|
declare class NgxFiltersCacheService {
|
|
8
|
-
private _bindingValuesMap;
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
get bindingValuesMap(): Map<string, any>;
|
|
13
8
|
private _filtersValuesMap;
|
|
14
9
|
/**
|
|
15
10
|
*
|
|
16
11
|
*/
|
|
17
12
|
get filtersValuesMap(): Map<string, any>;
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param key
|
|
21
|
-
*/
|
|
22
|
-
bindValue(key: string): any;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @param key
|
|
26
|
-
*/
|
|
27
|
-
addValue(key: string, value: any): void;
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param key
|
|
31
|
-
*/
|
|
32
|
-
getValue(key: string): any;
|
|
33
13
|
/**
|
|
34
14
|
*
|
|
35
15
|
* @param key
|
|
@@ -39,13 +19,14 @@ declare class NgxFiltersCacheService {
|
|
|
39
19
|
*
|
|
40
20
|
* @param key
|
|
41
21
|
*/
|
|
42
|
-
|
|
22
|
+
hasFilter(key: string): boolean;
|
|
43
23
|
/**
|
|
44
24
|
*
|
|
45
25
|
* @param key
|
|
46
26
|
* @param value
|
|
27
|
+
* @param type
|
|
47
28
|
*/
|
|
48
|
-
saveFilter(key: string, value: any): void;
|
|
29
|
+
saveFilter(key: string, value: any, type?: boolean): void;
|
|
49
30
|
/**
|
|
50
31
|
*
|
|
51
32
|
* @param key
|
|
@@ -59,6 +40,12 @@ declare class NgxFiltersCacheService {
|
|
|
59
40
|
*
|
|
60
41
|
*/
|
|
61
42
|
clearFilters(): void;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param item
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
private toCanonical;
|
|
62
49
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgxFiltersCacheService, never>;
|
|
63
50
|
static ɵprov: i0.ɵɵInjectableDeclaration<NgxFiltersCacheService>;
|
|
64
51
|
}
|