@sumaris-net/ngx-components 1.19.6-rc1 → 1.19.6
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/bundles/sumaris-net.ngx-components.umd.js +38 -32
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/services/storage/entities-storage.service.js +12 -12
- package/esm2015/src/app/core/services/storage/entity-store.class.js +3 -4
- package/esm2015/src/app/shared/functions.js +2 -2
- package/esm2015/src/app/shared/material/autocomplete/material.autocomplete.js +23 -19
- package/fesm2015/sumaris-net.ngx-components.js +36 -33
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/storage/entities-storage.service.d.ts +6 -2
- package/src/app/core/services/storage/entity-store.class.d.ts +2 -2
|
@@ -511,7 +511,7 @@
|
|
|
511
511
|
if (isNotNilOrBlank(value)) {
|
|
512
512
|
// If wildcard, search using regexp
|
|
513
513
|
if (value.indexOf('*') !== -1) {
|
|
514
|
-
value = value.replace(
|
|
514
|
+
value = value.replace(/[*]+/g, '.*');
|
|
515
515
|
filteredItems = filteredItems.filter(function (v) { return keys.findIndex(function (key) { return matchUpperCase(getPropertyByPathAsString(v, key), value); }) !== -1; });
|
|
516
516
|
}
|
|
517
517
|
// Else (no wildcard), search using startsWith
|
|
@@ -1705,14 +1705,14 @@
|
|
|
1705
1705
|
// Wait a debounce time
|
|
1706
1706
|
operators.debounceTime(this.debounceTime)
|
|
1707
1707
|
// DEBUG
|
|
1708
|
-
|
|
1708
|
+
//,tap((value) => this.debug && console.debug(this.logPrefix + ' Search text changes:', value))
|
|
1709
|
+
),
|
|
1709
1710
|
// Object set: use it (no distinctUntilChanged() pipe need)
|
|
1710
1711
|
this.formControl.valueChanges
|
|
1711
1712
|
.pipe(operators.startWith(this.formControl.value), operators.filter(function (value) { return (isNotNil(value) && typeof value === 'object'); }), operators.tap(function (value) {
|
|
1712
|
-
var _a;
|
|
1713
1713
|
// DEBUG
|
|
1714
|
-
if (
|
|
1715
|
-
|
|
1714
|
+
//if (this.debug) console.debug(this.logPrefix + ' control object changes:', value);
|
|
1715
|
+
var _a;
|
|
1716
1716
|
// Update the display value (if need)
|
|
1717
1717
|
var displayValue = _this.displayWith(value) || '';
|
|
1718
1718
|
if (_this.displayValue !== displayValue) {
|
|
@@ -1728,20 +1728,23 @@
|
|
|
1728
1728
|
// when formControl value changes
|
|
1729
1729
|
operators.filter(function () { return !_this.multiple || _this.loading; }), operators.map(function (value) { return _this.showAllOnFocus && _this.suggestLengthThreshold <= 0 ? '*' : value; })
|
|
1730
1730
|
// DEBUG
|
|
1731
|
-
|
|
1731
|
+
//,tap(value => this.debug && console.debug(this.logPrefix + ' Received an control object value: ', value))
|
|
1732
|
+
),
|
|
1732
1733
|
// Merge some observables, with a common distinctUntilChanged() pipe
|
|
1733
1734
|
rxjs.merge(
|
|
1734
1735
|
// On dropdown button click (no debounceTime)
|
|
1735
1736
|
this.dropButtonClick
|
|
1736
1737
|
.pipe(operators.filter(function (event) { return (!event || !event.defaultPrevented); })),
|
|
1737
1738
|
// Focus or click => Load all (no debounceTime)
|
|
1738
|
-
rxjs.merge(this.focused, this.clicked)
|
|
1739
|
-
|
|
1740
|
-
|
|
1739
|
+
rxjs.merge(this.focused, this.clicked),
|
|
1740
|
+
// DEBUG
|
|
1741
|
+
//.pipe(tap(_ => this.debug && console.debug(this.logPrefix + ' Received focused or clicked event'))),
|
|
1741
1742
|
// Input items or filter changes
|
|
1742
1743
|
rxjs.merge(this.$inputItems, this._$filter)
|
|
1743
1744
|
// DEBUG
|
|
1744
|
-
.pipe(operators.filter(function (_) { return !_this.loading; })
|
|
1745
|
+
.pipe(operators.filter(function (_) { return !_this.loading; })
|
|
1746
|
+
//,tap(_ => this.debug && console.debug(this.logPrefix + ' Received $inputItems or filter event'))
|
|
1747
|
+
))
|
|
1745
1748
|
.pipe(operators.filter(function (_) { return _this.enabled; }), operators.map(function (_) { return _this.showAllOnFocus ? '*' : _this.formControl.value; }),
|
|
1746
1749
|
// Distinguish changes
|
|
1747
1750
|
operators.distinctUntilChanged(function (v1, v2) {
|
|
@@ -1751,12 +1754,13 @@
|
|
|
1751
1754
|
// Make sure there is enough characters
|
|
1752
1755
|
operators.filter(thresholdFilterFn)
|
|
1753
1756
|
// DEBUG
|
|
1754
|
-
|
|
1757
|
+
//,tap(value => this.debug && console.debug(this.logPrefix + ' Received update event from observables: ', value))
|
|
1758
|
+
))
|
|
1755
1759
|
.pipe(
|
|
1756
1760
|
// Suggest values
|
|
1757
1761
|
operators.mergeMap(function (value) { return _this.suggest(value, _this.filter); }),
|
|
1758
1762
|
// DEBUG
|
|
1759
|
-
|
|
1763
|
+
//tap(items => this.debug && console.debug(this.logPrefix + ' Received from suggest: ', items)),
|
|
1760
1764
|
// Store implicit value (will use it onBlur if not other value selected)
|
|
1761
1765
|
operators.tap(function (items) { return !_this.multiple && !_this.mobile && _this.updateImplicitValue(items); }));
|
|
1762
1766
|
// Fetch more events
|
|
@@ -1764,7 +1768,7 @@
|
|
|
1764
1768
|
.pipe(operators.tap(function (event) { return event === null || event === void 0 ? void 0 : event.preventDefault(); }), // Avoid to close the mat-select
|
|
1765
1769
|
operators.filter(function () { return _this.canFetchMore; }), operators.mergeMap(function () { return _this.fetchMore(); }),
|
|
1766
1770
|
// DEBUG
|
|
1767
|
-
|
|
1771
|
+
//tap(moreItems => console.debug(this.logPrefix + ' Received from fetch More: ', moreItems)),
|
|
1768
1772
|
// Concat to existing items
|
|
1769
1773
|
operators.map(function (moreItems) { return (_this.$filteredItems.value || []).concat(moreItems); }));
|
|
1770
1774
|
// Update filtered items
|
|
@@ -1794,9 +1798,10 @@
|
|
|
1794
1798
|
this._subscription.add(this.blurred
|
|
1795
1799
|
.pipe(
|
|
1796
1800
|
// Skip if multiple (no implicit value) or disable
|
|
1797
|
-
operators.filter(function (_) { return !_this.multiple && !_this.mobile && _this.enabled; })
|
|
1801
|
+
operators.filter(function (_) { return !_this.multiple && !_this.mobile && _this.enabled; }),
|
|
1798
1802
|
// DEBUG
|
|
1799
|
-
|
|
1803
|
+
//,tap(_ => this.debug && console.debug(this.logPrefix + ' Received blurred event')),
|
|
1804
|
+
operators.map(function (_) { return _this.formControl.value; }))
|
|
1800
1805
|
.subscribe(function (value) {
|
|
1801
1806
|
// When leave component without object, use implicit value if :
|
|
1802
1807
|
// - an explicit value
|
|
@@ -1830,7 +1835,7 @@
|
|
|
1830
1835
|
event === null || event === void 0 ? void 0 : event.stopPropagation();
|
|
1831
1836
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
1832
1837
|
// DEBUG
|
|
1833
|
-
console.debug(
|
|
1838
|
+
//console.debug(this.logPrefix + " Closing the panel (keydown.escape)");
|
|
1834
1839
|
_this.closePanel();
|
|
1835
1840
|
}
|
|
1836
1841
|
}));
|
|
@@ -1877,8 +1882,7 @@
|
|
|
1877
1882
|
*/
|
|
1878
1883
|
MatAutocompleteField.prototype.reloadItems = function (value) {
|
|
1879
1884
|
// DEBUG
|
|
1880
|
-
if (this.debug)
|
|
1881
|
-
console.debug(this.logPrefix + " Asking to reloadItems()");
|
|
1885
|
+
//if (this.debug) console.debug(this.logPrefix + " Asking to reloadItems()");
|
|
1882
1886
|
// Force a refresh
|
|
1883
1887
|
this._reload$.next(value || (this.showAllOnFocus && this.suggestLengthThreshold <= 0 ? '*' : this.formControl.value));
|
|
1884
1888
|
// Clear the search bar (if hidden)
|
|
@@ -2091,7 +2095,7 @@
|
|
|
2091
2095
|
case 1:
|
|
2092
2096
|
res = _e.sent();
|
|
2093
2097
|
// DEBUG
|
|
2094
|
-
console.debug(this.logPrefix + ' Filtered items by suggestFn:', value, res);
|
|
2098
|
+
//if (this.debug) console.debug(this.logPrefix + ' Filtered items by suggestFn:', value, res);
|
|
2095
2099
|
if (!res) {
|
|
2096
2100
|
this._itemCount = 0;
|
|
2097
2101
|
this._onFetchMoreCallback = undefined;
|
|
@@ -13463,16 +13467,16 @@
|
|
|
13463
13467
|
/**
|
|
13464
13468
|
*
|
|
13465
13469
|
* @param opts
|
|
13466
|
-
* opts.
|
|
13470
|
+
* opts.skipIfPristine = false persist all entities, even if not dirty
|
|
13467
13471
|
*/
|
|
13468
13472
|
EntityStore.prototype.persist = function (opts) {
|
|
13473
|
+
if (opts === void 0) { opts = { skipIfPristine: true }; }
|
|
13469
13474
|
return __awaiter(this, void 0, void 0, function () {
|
|
13470
13475
|
var dirtyIndexes, entities;
|
|
13471
13476
|
var _this = this;
|
|
13472
13477
|
return __generator(this, function (_b) {
|
|
13473
13478
|
switch (_b.label) {
|
|
13474
13479
|
case 0:
|
|
13475
|
-
opts = Object.assign({ skipIfPristine: this.policy.skipNonLocalEntities }, opts);
|
|
13476
13480
|
// Skip is not dirty
|
|
13477
13481
|
if (opts.skipIfPristine && !this._dirty) {
|
|
13478
13482
|
console.debug("[entity-storage] Persisting " + this.name + " not need. Skip");
|
|
@@ -14212,11 +14216,12 @@
|
|
|
14212
14216
|
});
|
|
14213
14217
|
});
|
|
14214
14218
|
};
|
|
14215
|
-
EntitiesStorage.prototype.persist = function () {
|
|
14216
|
-
if (
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14219
|
+
EntitiesStorage.prototype.persist = function (opts) {
|
|
14220
|
+
if (opts === void 0) { opts = { skipIfPristine: true }; }
|
|
14221
|
+
// Skip if pristine
|
|
14222
|
+
if (opts.skipIfPristine && !this._dirty)
|
|
14223
|
+
return Promise.resolve();
|
|
14224
|
+
return this.storeLocally(opts);
|
|
14220
14225
|
};
|
|
14221
14226
|
EntitiesStorage.prototype.ngOnStart = function () {
|
|
14222
14227
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -14307,12 +14312,13 @@
|
|
|
14307
14312
|
});
|
|
14308
14313
|
});
|
|
14309
14314
|
};
|
|
14310
|
-
EntitiesStorage.prototype.storeLocally = function () {
|
|
14315
|
+
EntitiesStorage.prototype.storeLocally = function (opts) {
|
|
14316
|
+
if (opts === void 0) { opts = { skipIfPristine: true }; }
|
|
14311
14317
|
return __awaiter(this, void 0, void 0, function () {
|
|
14312
14318
|
var entityNames, now, currentEntityName;
|
|
14313
14319
|
var _this = this;
|
|
14314
14320
|
return __generator(this, function (_a) {
|
|
14315
|
-
if (!this.dirty)
|
|
14321
|
+
if (opts.skipIfPristine && !this.dirty)
|
|
14316
14322
|
return [2 /*return*/]; // skip
|
|
14317
14323
|
// Saving progress: report this save later
|
|
14318
14324
|
if (this._saving) {
|
|
@@ -14335,11 +14341,11 @@
|
|
|
14335
14341
|
console.warn("[entities-storage] Persisting " + entityName + ": store not found!");
|
|
14336
14342
|
return;
|
|
14337
14343
|
}
|
|
14338
|
-
// SKip store if
|
|
14339
|
-
if (!entityStore.dirty)
|
|
14340
|
-
return Promise.resolve();
|
|
14344
|
+
// SKip store if pristine
|
|
14345
|
+
if (opts.skipIfPristine && !entityStore.dirty)
|
|
14346
|
+
return Promise.resolve();
|
|
14341
14347
|
// Persist store
|
|
14342
|
-
return
|
|
14348
|
+
return entityStore.persist(opts)
|
|
14343
14349
|
.then(function (count) {
|
|
14344
14350
|
// If no entity found, remove from the entity names array
|
|
14345
14351
|
if (!count) {
|