@sumaris-net/ngx-components 1.4.2 → 1.4.7
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 +78 -58
- 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/local-settings.service.js +6 -4
- package/esm2015/src/app/core/services/storage/entities-storage.service.js +9 -3
- package/esm2015/src/app/core/services/storage/entity-store.class.js +5 -1
- package/esm2015/src/app/core/table/table.class.js +1 -1
- package/esm2015/src/app/shared/functions.js +2 -4
- package/esm2015/src/app/shared/material/autocomplete/material.autocomplete.js +20 -14
- package/fesm2015/sumaris-net.ngx-components.js +37 -21
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/services/storage/entity-store.class.d.ts +1 -0
- package/src/app/core/table/table.class.d.ts +1 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -511,9 +511,7 @@
|
|
|
511
511
|
return value.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
|
|
512
512
|
}
|
|
513
513
|
function removeDiacritics(text) {
|
|
514
|
-
return text.normalize('NFD')
|
|
515
|
-
//
|
|
516
|
-
.replace(/[\u0300-\u036f]/g, '');
|
|
514
|
+
return text.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
|
517
515
|
}
|
|
518
516
|
function suggestFromArray(items, value, opts) {
|
|
519
517
|
var _this = this;
|
|
@@ -1368,14 +1366,14 @@
|
|
|
1368
1366
|
});
|
|
1369
1367
|
Object.defineProperty(MatAutocompleteField.prototype, "disabled", {
|
|
1370
1368
|
get: function () {
|
|
1371
|
-
return this.
|
|
1369
|
+
return this._readonly || this.formControl.disabled;
|
|
1372
1370
|
},
|
|
1373
1371
|
enumerable: false,
|
|
1374
1372
|
configurable: true
|
|
1375
1373
|
});
|
|
1376
1374
|
Object.defineProperty(MatAutocompleteField.prototype, "enabled", {
|
|
1377
1375
|
get: function () {
|
|
1378
|
-
return !this.
|
|
1376
|
+
return !this._readonly && this.formControl.enabled;
|
|
1379
1377
|
},
|
|
1380
1378
|
enumerable: false,
|
|
1381
1379
|
configurable: true
|
|
@@ -1476,7 +1474,7 @@
|
|
|
1476
1474
|
this._reload$,
|
|
1477
1475
|
// Search text (no distinctUntilChanged() because of the debounceTime() pipe)
|
|
1478
1476
|
this.formControl.valueChanges
|
|
1479
|
-
.pipe(operators.filter(function (value) { return _this.searchable && isNotNilString(value); }),
|
|
1477
|
+
.pipe(operators.filter(function (value) { return _this.enabled && _this.searchable && isNotNilString(value); }),
|
|
1480
1478
|
// Mark as loading (to show loading spinner) - earlier as possible, so before the debounce time
|
|
1481
1479
|
operators.tap(function (value) {
|
|
1482
1480
|
if (_this.showLoadingSpinner) {
|
|
@@ -1486,10 +1484,13 @@
|
|
|
1486
1484
|
// Filter if not enough character
|
|
1487
1485
|
operators.filter(function (value) { return value.length >= _this.suggestLengthThreshold; }),
|
|
1488
1486
|
// Wait a debounce time
|
|
1489
|
-
operators.debounceTime(this.debounceTime)
|
|
1487
|
+
operators.debounceTime(this.debounceTime)
|
|
1488
|
+
// DEBUG
|
|
1489
|
+
//tap((value) => console.debug(this.logPrefix + ' Search text changes:', value)),
|
|
1490
|
+
),
|
|
1490
1491
|
// Object set: use it (no distinctUntilChanged() pipe need)
|
|
1491
1492
|
this.formControl.valueChanges
|
|
1492
|
-
.pipe(operators.startWith(this.formControl.value), operators.filter(function (value) { return _this.searchable && (typeof value === 'object'); }), operators.tap(function (value) {
|
|
1493
|
+
.pipe(operators.startWith(this.formControl.value), operators.filter(function (value) { return (_this.searchable && isNotNil(value) && typeof value === 'object'); }), operators.tap(function (value) {
|
|
1493
1494
|
// DEBUG
|
|
1494
1495
|
//console.debug(this.logPrefix + ' object changes:', value)
|
|
1495
1496
|
// Update the display value (if need)
|
|
@@ -1501,24 +1502,25 @@
|
|
|
1501
1502
|
_this.matInputText.nativeElement.value = _this.displayValue;
|
|
1502
1503
|
}
|
|
1503
1504
|
}
|
|
1504
|
-
})
|
|
1505
|
+
})
|
|
1506
|
+
// DEBUG
|
|
1507
|
+
//tap(value => console.debug(this.logPrefix + ' Received an object value: ', value))
|
|
1508
|
+
),
|
|
1505
1509
|
// Merge some observables, with a common distinctUntilChanged() pipe, and NO debounceTime
|
|
1506
1510
|
rxjs.merge(
|
|
1507
1511
|
// Focus or click => Load all
|
|
1508
1512
|
rxjs.merge(this.onFocus, this.onClick)
|
|
1509
|
-
.pipe(operators.filter(function (_) { return _this.
|
|
1513
|
+
.pipe(operators.filter(function (_) { return _this.enabled && _this.searchable; }), operators.map(function (_) { return _this.showAllOnFocus ? '*' : _this.formControl.value; })),
|
|
1510
1514
|
// On dropdown button click
|
|
1511
1515
|
this.onDropButtonClick
|
|
1512
|
-
.pipe(operators.filter(function (event) { return _this.searchable && (!event || !event.defaultPrevented)
|
|
1513
|
-
.pipe(operators.
|
|
1516
|
+
.pipe(operators.filter(function (event) { return _this.enabled && _this.searchable && (!event || !event.defaultPrevented); }), operators.map(function (_) { return _this.showAllOnFocus ? '*' : _this.formControl.value; })), rxjs.merge(this.$inputItems, this._filter$)
|
|
1517
|
+
.pipe(operators.filter(function (event) { return _this.enabled && _this.searchable; }), operators.map(function (_) { return _this.formControl.value; })))
|
|
1514
1518
|
.pipe(
|
|
1515
1519
|
// If value is a string (and is not = '*'), filter if not enough character
|
|
1516
1520
|
operators.filter(function (value) { return value === '*' || !(typeof value === 'string') || value.length >= _this.suggestLengthThreshold; }),
|
|
1517
1521
|
// Distinguish changes
|
|
1518
1522
|
operators.distinctUntilChanged()))
|
|
1519
1523
|
.pipe(
|
|
1520
|
-
// DEBUG
|
|
1521
|
-
//tap(value => console.debug(this.logPrefix + ' Received update event: ', value)),
|
|
1522
1524
|
// Suggest values
|
|
1523
1525
|
operators.mergeMap(function (value) { return _this.suggest(value, _this.filter); }),
|
|
1524
1526
|
// DEBUG
|
|
@@ -1577,7 +1579,9 @@
|
|
|
1577
1579
|
}));
|
|
1578
1580
|
// Listen form control status change
|
|
1579
1581
|
this._subscription.add(this.formControl.statusChanges
|
|
1580
|
-
.pipe(
|
|
1582
|
+
.pipe(
|
|
1583
|
+
//filter(() => this.enabled),
|
|
1584
|
+
operators.distinctUntilChanged())
|
|
1581
1585
|
// Update component state
|
|
1582
1586
|
.subscribe(function () { return _this.checkIfTouched(); }));
|
|
1583
1587
|
this._subscription.add(this.onKeydownEscape.subscribe(function (event) {
|
|
@@ -1679,7 +1683,7 @@
|
|
|
1679
1683
|
// If combo is empty, or if has content but should force to show panel on focus
|
|
1680
1684
|
if (!hasContent || (this.showPanelOnFocus && this.showAllOnFocus)) {
|
|
1681
1685
|
// DEBUG
|
|
1682
|
-
console.debug(this.logPrefix + ' Emit focus event');
|
|
1686
|
+
//console.debug(this.logPrefix + ' Emit focus event');
|
|
1683
1687
|
this.onFocus.emit(event);
|
|
1684
1688
|
return true;
|
|
1685
1689
|
}
|
|
@@ -10867,7 +10871,7 @@
|
|
|
10867
10871
|
});
|
|
10868
10872
|
};
|
|
10869
10873
|
LocalSettingsService.prototype.setProperty = function (keyOrDef, value) {
|
|
10870
|
-
if (!this._data)
|
|
10874
|
+
if (!this._data || !keyOrDef)
|
|
10871
10875
|
return;
|
|
10872
10876
|
if (typeof keyOrDef === 'object') {
|
|
10873
10877
|
this.setProperty(keyOrDef.key, value);
|
|
@@ -10990,8 +10994,9 @@
|
|
|
10990
10994
|
var feature = this._data.offlineFeatures.find(function (f) {
|
|
10991
10995
|
if (typeof f === 'string')
|
|
10992
10996
|
return f.toLowerCase().startsWith(featurePrefix);
|
|
10993
|
-
if (typeof f === 'object' && f.name)
|
|
10997
|
+
if (f && typeof f === 'object' && f.name)
|
|
10994
10998
|
return f.name === featureName;
|
|
10999
|
+
return false;
|
|
10995
11000
|
});
|
|
10996
11001
|
if (!feature)
|
|
10997
11002
|
return; // Not found
|
|
@@ -11022,8 +11027,9 @@
|
|
|
11022
11027
|
var existingIndex = this._data.offlineFeatures.findIndex(function (f) {
|
|
11023
11028
|
if (typeof f === 'string')
|
|
11024
11029
|
return f.toLowerCase().startsWith(featurePrefix);
|
|
11025
|
-
if (typeof f === 'object' && f.name)
|
|
11030
|
+
if (f && typeof f === 'object' && f.name)
|
|
11026
11031
|
return f.name === feature.name;
|
|
11032
|
+
return false;
|
|
11027
11033
|
});
|
|
11028
11034
|
if (existingIndex !== -1) {
|
|
11029
11035
|
this._data.offlineFeatures[existingIndex] = feature;
|
|
@@ -12140,6 +12146,14 @@
|
|
|
12140
12146
|
this._storageKey = ENTITIES_STORAGE_KEY_PREFIX + '#' + name;
|
|
12141
12147
|
this._mapToLightEntity = this.createLightEntityMapFn(this.policy);
|
|
12142
12148
|
}
|
|
12149
|
+
Object.defineProperty(EntityStore.prototype, "length", {
|
|
12150
|
+
get: function () {
|
|
12151
|
+
var _a;
|
|
12152
|
+
return ((_a = this._cache) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
12153
|
+
},
|
|
12154
|
+
enumerable: false,
|
|
12155
|
+
configurable: true
|
|
12156
|
+
});
|
|
12143
12157
|
Object.defineProperty(EntityStore.prototype, "cache", {
|
|
12144
12158
|
get: function () {
|
|
12145
12159
|
return this._cache;
|
|
@@ -12178,12 +12192,12 @@
|
|
|
12178
12192
|
};
|
|
12179
12193
|
EntityStore.prototype.load = function (id, opts) {
|
|
12180
12194
|
return __awaiter(this, void 0, void 0, function () {
|
|
12181
|
-
return __generator(this, function (
|
|
12182
|
-
switch (
|
|
12195
|
+
return __generator(this, function (_b) {
|
|
12196
|
+
switch (_b.label) {
|
|
12183
12197
|
case 0:
|
|
12184
12198
|
if (!(this._mapToLightEntity && (!opts || opts.fullLoad !== false))) return [3 /*break*/, 2];
|
|
12185
12199
|
return [4 /*yield*/, this.loadFullEntity(id, opts)];
|
|
12186
|
-
case 1: return [2 /*return*/,
|
|
12200
|
+
case 1: return [2 /*return*/, _b.sent()];
|
|
12187
12201
|
case 2: return [2 /*return*/, this.loadCachedEntity(id, opts)];
|
|
12188
12202
|
}
|
|
12189
12203
|
});
|
|
@@ -12223,20 +12237,20 @@
|
|
|
12223
12237
|
*/
|
|
12224
12238
|
EntityStore.prototype.loadAll = function (variables, opts) {
|
|
12225
12239
|
return __awaiter(this, void 0, void 0, function () {
|
|
12226
|
-
var res,
|
|
12240
|
+
var res, _b;
|
|
12227
12241
|
var _this = this;
|
|
12228
|
-
return __generator(this, function (
|
|
12229
|
-
switch (
|
|
12242
|
+
return __generator(this, function (_c) {
|
|
12243
|
+
switch (_c.label) {
|
|
12230
12244
|
case 0:
|
|
12231
12245
|
res = this.reduceAndSort(this._cache, variables);
|
|
12232
12246
|
if (!(this._mapToLightEntity && isNotEmptyArray(res.data) && (opts && opts.fullLoad === true))) return [3 /*break*/, 2];
|
|
12233
12247
|
// Load full entities, one by one
|
|
12234
|
-
|
|
12248
|
+
_b = res;
|
|
12235
12249
|
return [4 /*yield*/, chainPromises((res.data || []).map(function (e) { return function () { return _this.load(e.id); }; }))];
|
|
12236
12250
|
case 1:
|
|
12237
12251
|
// Load full entities, one by one
|
|
12238
|
-
|
|
12239
|
-
|
|
12252
|
+
_b.data = _c.sent();
|
|
12253
|
+
_c.label = 2;
|
|
12240
12254
|
case 2: return [2 /*return*/, res];
|
|
12241
12255
|
}
|
|
12242
12256
|
});
|
|
@@ -12353,8 +12367,8 @@
|
|
|
12353
12367
|
return __awaiter(this, void 0, void 0, function () {
|
|
12354
12368
|
var dirtyIndexes, entities;
|
|
12355
12369
|
var _this = this;
|
|
12356
|
-
return __generator(this, function (
|
|
12357
|
-
switch (
|
|
12370
|
+
return __generator(this, function (_b) {
|
|
12371
|
+
switch (_b.label) {
|
|
12358
12372
|
case 0:
|
|
12359
12373
|
opts = Object.assign({ skipIfPristine: this.policy.skipNonLocalEntities }, opts);
|
|
12360
12374
|
// Skip is not dirty
|
|
@@ -12378,7 +12392,7 @@
|
|
|
12378
12392
|
return [4 /*yield*/, this.storage.remove(this._storageKey)];
|
|
12379
12393
|
case 1:
|
|
12380
12394
|
// Clean the local storage
|
|
12381
|
-
|
|
12395
|
+
_b.sent();
|
|
12382
12396
|
return [3 /*break*/, 7];
|
|
12383
12397
|
case 2:
|
|
12384
12398
|
if (!this.isByIdMode) return [3 /*break*/, 5];
|
|
@@ -12386,7 +12400,7 @@
|
|
|
12386
12400
|
return [4 /*yield*/, this.storage.set(this.storageKeyById, entities.filter(isNotNil).map(function (e) { return e.id; }))];
|
|
12387
12401
|
case 3:
|
|
12388
12402
|
// Save ids
|
|
12389
|
-
|
|
12403
|
+
_b.sent();
|
|
12390
12404
|
// Saved dirty entities
|
|
12391
12405
|
return [4 /*yield*/, Promise.all(dirtyIndexes
|
|
12392
12406
|
.map(function (index) {
|
|
@@ -12396,15 +12410,15 @@
|
|
|
12396
12410
|
}))];
|
|
12397
12411
|
case 4:
|
|
12398
12412
|
// Saved dirty entities
|
|
12399
|
-
|
|
12413
|
+
_b.sent();
|
|
12400
12414
|
console.info("[entity-storage] Persisting " + dirtyIndexes.length + "/" + entities.length + " " + this.name + "(s)...");
|
|
12401
12415
|
return [3 /*break*/, 7];
|
|
12402
12416
|
case 5:
|
|
12403
12417
|
console.info("[entity-storage] Persisting " + entities.length + " " + this.name + "(s)...");
|
|
12404
12418
|
return [4 /*yield*/, this.storage.set(this._storageKey, entities)];
|
|
12405
12419
|
case 6:
|
|
12406
|
-
|
|
12407
|
-
|
|
12420
|
+
_b.sent();
|
|
12421
|
+
_b.label = 7;
|
|
12408
12422
|
case 7: return [2 /*return*/, entities.length];
|
|
12409
12423
|
}
|
|
12410
12424
|
});
|
|
@@ -12414,14 +12428,14 @@
|
|
|
12414
12428
|
return __awaiter(this, void 0, void 0, function () {
|
|
12415
12429
|
var entities, res, values, ids, migration, oldKeysToClean, storageKeys, storageKeys, err_1;
|
|
12416
12430
|
var _this = this;
|
|
12417
|
-
return __generator(this, function (
|
|
12418
|
-
switch (
|
|
12431
|
+
return __generator(this, function (_b) {
|
|
12432
|
+
switch (_b.label) {
|
|
12419
12433
|
case 0: return [4 /*yield*/, Promise.all([
|
|
12420
12434
|
this.storage.get(this._storageKey),
|
|
12421
12435
|
this.storage.get(this.storageKeyById)
|
|
12422
12436
|
])];
|
|
12423
12437
|
case 1:
|
|
12424
|
-
res =
|
|
12438
|
+
res = _b.sent();
|
|
12425
12439
|
values = res[0] && Array.isArray(res[0]) ? res[0] : null;
|
|
12426
12440
|
ids = res[1] && Array.isArray(res[1]) ? res[1] : null;
|
|
12427
12441
|
migration = false;
|
|
@@ -12430,7 +12444,7 @@
|
|
|
12430
12444
|
storageKeys = ids.map(function (id) { return _this._storageKey + '#' + id; });
|
|
12431
12445
|
return [4 /*yield*/, chainPromises(storageKeys.map(function (key) { return function () { return _this.storage.get(key); }; }))];
|
|
12432
12446
|
case 2:
|
|
12433
|
-
entities =
|
|
12447
|
+
entities = _b.sent();
|
|
12434
12448
|
return [3 /*break*/, 4];
|
|
12435
12449
|
case 3:
|
|
12436
12450
|
if (isNotNil(values)) {
|
|
@@ -12438,7 +12452,7 @@
|
|
|
12438
12452
|
migration = true;
|
|
12439
12453
|
oldKeysToClean = [this._storageKey];
|
|
12440
12454
|
}
|
|
12441
|
-
|
|
12455
|
+
_b.label = 4;
|
|
12442
12456
|
case 4: return [3 /*break*/, 8];
|
|
12443
12457
|
case 5:
|
|
12444
12458
|
if (!isNotNil(values)) return [3 /*break*/, 6];
|
|
@@ -12450,10 +12464,10 @@
|
|
|
12450
12464
|
return [4 /*yield*/, chainPromises(storageKeys.map(function (key) { return function () { return _this.storage.get(key); }; }))];
|
|
12451
12465
|
case 7:
|
|
12452
12466
|
// Load entity by id (one by one)
|
|
12453
|
-
entities =
|
|
12467
|
+
entities = _b.sent();
|
|
12454
12468
|
migration = true;
|
|
12455
12469
|
oldKeysToClean = __spread(storageKeys, [this.storageKeyById]);
|
|
12456
|
-
|
|
12470
|
+
_b.label = 8;
|
|
12457
12471
|
case 8:
|
|
12458
12472
|
// OK, there is something in storage...
|
|
12459
12473
|
if (isNotEmptyArray(entities)) {
|
|
@@ -12468,23 +12482,23 @@
|
|
|
12468
12482
|
this.setEntities(entities || [], Object.assign(Object.assign({}, opts), { emitEvent: false }));
|
|
12469
12483
|
this._dirty = false;
|
|
12470
12484
|
if (!migration) return [3 /*break*/, 14];
|
|
12471
|
-
|
|
12485
|
+
_b.label = 9;
|
|
12472
12486
|
case 9:
|
|
12473
|
-
|
|
12487
|
+
_b.trys.push([9, 13, , 14]);
|
|
12474
12488
|
console.warn("[entity-storage] - Migrate " + this.name + " into {mode: '" + this.policy.mode + "'}...");
|
|
12475
12489
|
// Force to persist, using the new mode
|
|
12476
12490
|
return [4 /*yield*/, this.persist({ skipIfPristine: false /* force persist using the new mode */ })];
|
|
12477
12491
|
case 10:
|
|
12478
12492
|
// Force to persist, using the new mode
|
|
12479
|
-
|
|
12493
|
+
_b.sent();
|
|
12480
12494
|
if (!isNotEmptyArray(oldKeysToClean)) return [3 /*break*/, 12];
|
|
12481
12495
|
return [4 /*yield*/, chainPromises(oldKeysToClean.map(function (key) { return function () { return _this.storage.remove(key); }; }))];
|
|
12482
12496
|
case 11:
|
|
12483
|
-
|
|
12484
|
-
|
|
12497
|
+
_b.sent();
|
|
12498
|
+
_b.label = 12;
|
|
12485
12499
|
case 12: return [3 /*break*/, 14];
|
|
12486
12500
|
case 13:
|
|
12487
|
-
err_1 =
|
|
12501
|
+
err_1 = _b.sent();
|
|
12488
12502
|
console.error(err_1);
|
|
12489
12503
|
throw { code: ErrorCodes$2.ENTITY_STORAGE_MIGRATION_FAILED, message: 'ERROR.ENTITY_STORAGE_MIGRATION_FAILED', details: err_1 };
|
|
12490
12504
|
case 14:
|
|
@@ -12505,10 +12519,10 @@
|
|
|
12505
12519
|
}
|
|
12506
12520
|
};
|
|
12507
12521
|
EntityStore.prototype.markAsPristine = function (opts) {
|
|
12508
|
-
var e_1,
|
|
12522
|
+
var e_1, _b;
|
|
12509
12523
|
try {
|
|
12510
|
-
for (var
|
|
12511
|
-
var s =
|
|
12524
|
+
for (var _c = __values(this._statusById.values()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
12525
|
+
var s = _d.value;
|
|
12512
12526
|
if (isNotNil(s)) {
|
|
12513
12527
|
s.dirty = false;
|
|
12514
12528
|
}
|
|
@@ -12517,7 +12531,7 @@
|
|
|
12517
12531
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
12518
12532
|
finally {
|
|
12519
12533
|
try {
|
|
12520
|
-
if (
|
|
12534
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
12521
12535
|
}
|
|
12522
12536
|
finally { if (e_1) throw e_1.error; }
|
|
12523
12537
|
}
|
|
@@ -12538,8 +12552,8 @@
|
|
|
12538
12552
|
EntityStore.prototype.loadFullEntity = function (id, opts) {
|
|
12539
12553
|
return __awaiter(this, void 0, void 0, function () {
|
|
12540
12554
|
var status, index, fullData;
|
|
12541
|
-
return __generator(this, function (
|
|
12542
|
-
switch (
|
|
12555
|
+
return __generator(this, function (_b) {
|
|
12556
|
+
switch (_b.label) {
|
|
12543
12557
|
case 0:
|
|
12544
12558
|
status = this._statusById.get(id);
|
|
12545
12559
|
index = status && status.index;
|
|
@@ -12549,10 +12563,10 @@
|
|
|
12549
12563
|
console.debug("[entity-storage] Full reloading " + this.name + "#" + id + "...");
|
|
12550
12564
|
return [4 /*yield*/, this.storage.get(this._storageKey + '#' + id)];
|
|
12551
12565
|
case 1:
|
|
12552
|
-
fullData =
|
|
12566
|
+
fullData = _b.sent();
|
|
12553
12567
|
if (fullData)
|
|
12554
12568
|
return [2 /*return*/, fullData];
|
|
12555
|
-
|
|
12569
|
+
_b.label = 2;
|
|
12556
12570
|
case 2:
|
|
12557
12571
|
// Load from the cache, if dirty OR if storage is not splited by id
|
|
12558
12572
|
return [2 /*return*/, this._cache[index]];
|
|
@@ -13219,11 +13233,17 @@
|
|
|
13219
13233
|
console.warn("[entities-storage] Persisting " + entityName + ": store not found!");
|
|
13220
13234
|
return;
|
|
13221
13235
|
}
|
|
13222
|
-
|
|
13236
|
+
// SKip store if not dirty
|
|
13237
|
+
if (!entityStore.dirty)
|
|
13238
|
+
return Promise.resolve(); // Skip
|
|
13239
|
+
// Persist store
|
|
13240
|
+
return (entityStore.dirty ? entityStore.persist() : Promise.resolve(entityStore.length))
|
|
13223
13241
|
.then(function (count) {
|
|
13224
13242
|
// If no entity found, remove from the entity names array
|
|
13225
13243
|
if (!count) {
|
|
13226
|
-
entityNames.
|
|
13244
|
+
var entityNameIndex = entityNames.findIndex(function (e) { return e === entityName; });
|
|
13245
|
+
if (entityNameIndex !== -1)
|
|
13246
|
+
entityNames.splice(entityNameIndex, 1);
|
|
13227
13247
|
}
|
|
13228
13248
|
});
|
|
13229
13249
|
}; }))
|