@firestitch/filter 13.0.1 → 13.0.3
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/app/helpers/build-query-params.d.ts +1 -1
- package/app/helpers/create-filter-item.d.ts +1 -1
- package/app/models/items/base-item.d.ts +1 -0
- package/app/services/external-params/query-params-controller.service.d.ts +2 -1
- package/esm2020/app/helpers/build-query-params.mjs +4 -3
- package/esm2020/app/models/items/base-item.mjs +7 -9
- package/esm2020/app/services/external-params/query-params-controller.service.mjs +14 -19
- package/fesm2015/firestitch-filter.mjs +29 -35
- package/fesm2015/firestitch-filter.mjs.map +1 -1
- package/fesm2020/firestitch-filter.mjs +29 -35
- package/fesm2020/firestitch-filter.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -59,16 +59,6 @@ import * as i1$6 from '@angular/cdk/overlay';
|
|
|
59
59
|
import { OverlayConfig } from '@angular/cdk/overlay';
|
|
60
60
|
import * as i1$7 from '@angular/cdk/layout';
|
|
61
61
|
|
|
62
|
-
const QUERY_PARAM_DELIMITER = ':';
|
|
63
|
-
|
|
64
|
-
function filterToQueryParam(value, name) {
|
|
65
|
-
return `${encodeURIComponent(value)}${QUERY_PARAM_DELIMITER}${encodeURIComponent(name)}`;
|
|
66
|
-
}
|
|
67
|
-
function filterFromQueryParam(param) {
|
|
68
|
-
const parts = param.split(QUERY_PARAM_DELIMITER);
|
|
69
|
-
return [decodeURIComponent(parts[0]), decodeURIComponent(parts[1])];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
62
|
function objectsAreEquals(obj1, obj2) {
|
|
73
63
|
const oldKeys = Object.keys(obj1);
|
|
74
64
|
const currKeys = Object.keys(obj2);
|
|
@@ -129,6 +119,7 @@ class BaseItem {
|
|
|
129
119
|
this._filter = _filter;
|
|
130
120
|
this._pendingValues = false;
|
|
131
121
|
this._pendingDefaultValue = false;
|
|
122
|
+
this._initializedValues = false;
|
|
132
123
|
this._loading$ = new BehaviorSubject(false);
|
|
133
124
|
this._value$ = new BehaviorSubject(null);
|
|
134
125
|
this._valueChange$ = new Subject();
|
|
@@ -141,7 +132,6 @@ class BaseItem {
|
|
|
141
132
|
get filter() {
|
|
142
133
|
return this._filter;
|
|
143
134
|
}
|
|
144
|
-
///
|
|
145
135
|
get isTypeAutocomplete() {
|
|
146
136
|
return this.type === ItemType.AutoComplete;
|
|
147
137
|
}
|
|
@@ -175,7 +165,6 @@ class BaseItem {
|
|
|
175
165
|
get isTypeKeyword() {
|
|
176
166
|
return this.type === ItemType.Keyword;
|
|
177
167
|
}
|
|
178
|
-
////
|
|
179
168
|
get isChipVisible() {
|
|
180
169
|
return !!this.model;
|
|
181
170
|
}
|
|
@@ -229,7 +218,7 @@ class BaseItem {
|
|
|
229
218
|
this._loading$.next(value);
|
|
230
219
|
}
|
|
231
220
|
get _initialized() {
|
|
232
|
-
return !this._pendingDefaultValue && !this._pendingValues;
|
|
221
|
+
return !this._pendingDefaultValue && !this._pendingValues && this._initializedValues;
|
|
233
222
|
}
|
|
234
223
|
valueChanged() {
|
|
235
224
|
this._value$.next(this.value);
|
|
@@ -266,7 +255,7 @@ class BaseItem {
|
|
|
266
255
|
}));
|
|
267
256
|
}
|
|
268
257
|
initValues(persistedValue) {
|
|
269
|
-
|
|
258
|
+
this._initializedValues = false;
|
|
270
259
|
this.persistedValue = persistedValue;
|
|
271
260
|
this._initDefaultModel();
|
|
272
261
|
const isAutocomplete = this.type === ItemType.AutoComplete || this.type === ItemType.AutoCompleteChips;
|
|
@@ -277,14 +266,13 @@ class BaseItem {
|
|
|
277
266
|
}
|
|
278
267
|
else {
|
|
279
268
|
this.values = valuesResult;
|
|
280
|
-
// Move to some other place
|
|
281
269
|
this._init();
|
|
282
|
-
|
|
270
|
+
this._initializedValues = true;
|
|
283
271
|
}
|
|
284
272
|
}
|
|
285
273
|
else {
|
|
286
274
|
this._init();
|
|
287
|
-
|
|
275
|
+
this._initializedValues = true;
|
|
288
276
|
}
|
|
289
277
|
}
|
|
290
278
|
loadAsyncValues(reload = true) {
|
|
@@ -298,7 +286,7 @@ class BaseItem {
|
|
|
298
286
|
this.loading = false;
|
|
299
287
|
this._init();
|
|
300
288
|
this._validateModel();
|
|
301
|
-
|
|
289
|
+
this._initializedValues = true;
|
|
302
290
|
});
|
|
303
291
|
}
|
|
304
292
|
}
|
|
@@ -478,8 +466,19 @@ class MultipleSelectItem extends BaseSelectItem {
|
|
|
478
466
|
}
|
|
479
467
|
}
|
|
480
468
|
|
|
469
|
+
const QUERY_PARAM_DELIMITER = ':';
|
|
470
|
+
|
|
471
|
+
function filterToQueryParam(value, name) {
|
|
472
|
+
return `${encodeURIComponent(value)}${QUERY_PARAM_DELIMITER}${encodeURIComponent(name)}`;
|
|
473
|
+
}
|
|
474
|
+
function filterFromQueryParam(param) {
|
|
475
|
+
const parts = param.split(QUERY_PARAM_DELIMITER);
|
|
476
|
+
return [decodeURIComponent(parts[0]), decodeURIComponent(parts[1])];
|
|
477
|
+
}
|
|
478
|
+
|
|
481
479
|
function buildQueryParams(flattenedParams, items) {
|
|
482
|
-
items
|
|
480
|
+
items
|
|
481
|
+
.forEach((filterItem) => {
|
|
483
482
|
if (filterItem instanceof MultipleSelectItem && filterItem.isolate) {
|
|
484
483
|
if (filterItem.multiple && filterItem.value) {
|
|
485
484
|
const isolated = list(filterItem.values, 'value').sort();
|
|
@@ -1913,23 +1912,9 @@ class QueryParamsController {
|
|
|
1913
1912
|
}
|
|
1914
1913
|
}
|
|
1915
1914
|
writeStateToQueryParams(params) {
|
|
1916
|
-
if (
|
|
1917
|
-
|
|
1915
|
+
if (this._enabled) {
|
|
1916
|
+
this._replaceState(params);
|
|
1918
1917
|
}
|
|
1919
|
-
this._location.replaceState(this._router.createUrlTree([], {
|
|
1920
|
-
relativeTo: this._route,
|
|
1921
|
-
queryParams: params,
|
|
1922
|
-
queryParamsHandling: 'merge',
|
|
1923
|
-
preserveFragment: true,
|
|
1924
|
-
}).toString());
|
|
1925
|
-
// Trying replacing the URL without triggering an Angular navigation change
|
|
1926
|
-
// // Update query
|
|
1927
|
-
// this._router.navigate([], {
|
|
1928
|
-
// replaceUrl: true,
|
|
1929
|
-
// relativeTo: this._route,
|
|
1930
|
-
// queryParams: params,
|
|
1931
|
-
// queryParamsHandling: 'merge',
|
|
1932
|
-
// }).then(() => {});
|
|
1933
1918
|
}
|
|
1934
1919
|
/**
|
|
1935
1920
|
* Parse query and update filter values
|
|
@@ -1942,6 +1927,15 @@ class QueryParamsController {
|
|
|
1942
1927
|
].filter((item) => !!item);
|
|
1943
1928
|
this._fetchedParams = restoreItems(this._route.snapshot.queryParams, items, this._paramsCase);
|
|
1944
1929
|
}
|
|
1930
|
+
_replaceState(data) {
|
|
1931
|
+
const url = new URL(window.location.href);
|
|
1932
|
+
Object.keys(data)
|
|
1933
|
+
.filter((name) => data[name] !== undefined && data[name] !== null)
|
|
1934
|
+
.forEach((name) => {
|
|
1935
|
+
url.searchParams.set(name, data[name]);
|
|
1936
|
+
});
|
|
1937
|
+
history.replaceState({}, null, url.search);
|
|
1938
|
+
}
|
|
1945
1939
|
}
|
|
1946
1940
|
QueryParamsController.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: QueryParamsController, deps: [{ token: i1$1.Router }, { token: i1$1.ActivatedRoute }, { token: i3.Location }, { token: FsFilterItemsStore }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1947
1941
|
QueryParamsController.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: QueryParamsController });
|