@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.
@@ -251,7 +251,7 @@ function suggestFromArray(items, value, opts) {
251
251
  if (isNotNilOrBlank(value)) {
252
252
  // If wildcard, search using regexp
253
253
  if (value.indexOf('*') !== -1) {
254
- value = value.replace('*', '.*');
254
+ value = value.replace(/[*]+/g, '.*');
255
255
  filteredItems = filteredItems.filter(v => keys.findIndex(key => matchUpperCase(getPropertyByPathAsString(v, key), value)) !== -1);
256
256
  }
257
257
  // Else (no wildcard), search using startsWith
@@ -1368,14 +1368,14 @@ class MatAutocompleteField {
1368
1368
  // Wait a debounce time
1369
1369
  debounceTime(this.debounceTime)
1370
1370
  // DEBUG
1371
- , tap((value) => this.debug && console.debug(this.logPrefix + ' Search text changes:', value))),
1371
+ //,tap((value) => this.debug && console.debug(this.logPrefix + ' Search text changes:', value))
1372
+ ),
1372
1373
  // Object set: use it (no distinctUntilChanged() pipe need)
1373
1374
  this.formControl.valueChanges
1374
1375
  .pipe(startWith(this.formControl.value), filter(value => (isNotNil(value) && typeof value === 'object')), tap(value => {
1375
- var _a;
1376
1376
  // DEBUG
1377
- if (this.debug)
1378
- console.debug(this.logPrefix + ' control object changes:', value);
1377
+ //if (this.debug) console.debug(this.logPrefix + ' control object changes:', value);
1378
+ var _a;
1379
1379
  // Update the display value (if need)
1380
1380
  const displayValue = this.displayWith(value) || '';
1381
1381
  if (this.displayValue !== displayValue) {
@@ -1391,20 +1391,23 @@ class MatAutocompleteField {
1391
1391
  // when formControl value changes
1392
1392
  filter(() => !this.multiple || this.loading), map(value => this.showAllOnFocus && this.suggestLengthThreshold <= 0 ? '*' : value)
1393
1393
  // DEBUG
1394
- , tap(value => this.debug && console.debug(this.logPrefix + ' Received an control object value: ', value))),
1394
+ //,tap(value => this.debug && console.debug(this.logPrefix + ' Received an control object value: ', value))
1395
+ ),
1395
1396
  // Merge some observables, with a common distinctUntilChanged() pipe
1396
1397
  merge(
1397
1398
  // On dropdown button click (no debounceTime)
1398
1399
  this.dropButtonClick
1399
1400
  .pipe(filter(event => (!event || !event.defaultPrevented))),
1400
1401
  // Focus or click => Load all (no debounceTime)
1401
- merge(this.focused, this.clicked)
1402
- // DEBUG
1403
- .pipe(tap(_ => this.debug && console.debug(this.logPrefix + ' Received focused or clicked event'))),
1402
+ merge(this.focused, this.clicked),
1403
+ // DEBUG
1404
+ //.pipe(tap(_ => this.debug && console.debug(this.logPrefix + ' Received focused or clicked event'))),
1404
1405
  // Input items or filter changes
1405
1406
  merge(this.$inputItems, this._$filter)
1406
1407
  // DEBUG
1407
- .pipe(filter(_ => !this.loading), tap(_ => this.debug && console.debug(this.logPrefix + ' Received $inputItems or filter event'))))
1408
+ .pipe(filter(_ => !this.loading)
1409
+ //,tap(_ => this.debug && console.debug(this.logPrefix + ' Received $inputItems or filter event'))
1410
+ ))
1408
1411
  .pipe(filter(_ => this.enabled), map(_ => this.showAllOnFocus ? '*' : this.formControl.value),
1409
1412
  // Distinguish changes
1410
1413
  distinctUntilChanged((v1, v2) =>
@@ -1413,12 +1416,13 @@ class MatAutocompleteField {
1413
1416
  // Make sure there is enough characters
1414
1417
  filter(thresholdFilterFn)
1415
1418
  // DEBUG
1416
- , tap(value => this.debug && console.debug(this.logPrefix + ' Received update event from observables: ', value))))
1419
+ //,tap(value => this.debug && console.debug(this.logPrefix + ' Received update event from observables: ', value))
1420
+ ))
1417
1421
  .pipe(
1418
1422
  // Suggest values
1419
1423
  mergeMap(value => this.suggest(value, this.filter)),
1420
1424
  // DEBUG
1421
- tap(items => this.debug && console.debug(this.logPrefix + ' Received from suggest: ', items)),
1425
+ //tap(items => this.debug && console.debug(this.logPrefix + ' Received from suggest: ', items)),
1422
1426
  // Store implicit value (will use it onBlur if not other value selected)
1423
1427
  tap(items => !this.multiple && !this.mobile && this.updateImplicitValue(items)));
1424
1428
  // Fetch more events
@@ -1426,7 +1430,7 @@ class MatAutocompleteField {
1426
1430
  .pipe(tap(event => event === null || event === void 0 ? void 0 : event.preventDefault()), // Avoid to close the mat-select
1427
1431
  filter(() => this.canFetchMore), mergeMap(() => this.fetchMore()),
1428
1432
  // DEBUG
1429
- tap(moreItems => console.debug(this.logPrefix + ' Received from fetch More: ', moreItems)),
1433
+ //tap(moreItems => console.debug(this.logPrefix + ' Received from fetch More: ', moreItems)),
1430
1434
  // Concat to existing items
1431
1435
  map(moreItems => (this.$filteredItems.value || []).concat(moreItems)));
1432
1436
  // Update filtered items
@@ -1456,9 +1460,10 @@ class MatAutocompleteField {
1456
1460
  this._subscription.add(this.blurred
1457
1461
  .pipe(
1458
1462
  // Skip if multiple (no implicit value) or disable
1459
- filter(_ => !this.multiple && !this.mobile && this.enabled)
1463
+ filter(_ => !this.multiple && !this.mobile && this.enabled),
1460
1464
  // DEBUG
1461
- , tap(_ => this.debug && console.debug(this.logPrefix + ' Received blurred event')), map(_ => this.formControl.value))
1465
+ //,tap(_ => this.debug && console.debug(this.logPrefix + ' Received blurred event')),
1466
+ map(_ => this.formControl.value))
1462
1467
  .subscribe(value => {
1463
1468
  // When leave component without object, use implicit value if :
1464
1469
  // - an explicit value
@@ -1492,7 +1497,7 @@ class MatAutocompleteField {
1492
1497
  event === null || event === void 0 ? void 0 : event.stopPropagation();
1493
1498
  event === null || event === void 0 ? void 0 : event.preventDefault();
1494
1499
  // DEBUG
1495
- console.debug(this.logPrefix + " Closing the panel (keydown.escape)");
1500
+ //console.debug(this.logPrefix + " Closing the panel (keydown.escape)");
1496
1501
  this.closePanel();
1497
1502
  }
1498
1503
  }));
@@ -1539,8 +1544,7 @@ class MatAutocompleteField {
1539
1544
  */
1540
1545
  reloadItems(value) {
1541
1546
  // DEBUG
1542
- if (this.debug)
1543
- console.debug(this.logPrefix + " Asking to reloadItems()");
1547
+ //if (this.debug) console.debug(this.logPrefix + " Asking to reloadItems()");
1544
1548
  // Force a refresh
1545
1549
  this._reload$.next(value || (this.showAllOnFocus && this.suggestLengthThreshold <= 0 ? '*' : this.formControl.value));
1546
1550
  // Clear the search bar (if hidden)
@@ -1743,7 +1747,7 @@ class MatAutocompleteField {
1743
1747
  // Call suggestion function
1744
1748
  let res = yield this.suggestFn(value, filter);
1745
1749
  // DEBUG
1746
- console.debug(this.logPrefix + ' Filtered items by suggestFn:', value, res);
1750
+ //if (this.debug) console.debug(this.logPrefix + ' Filtered items by suggestFn:', value, res);
1747
1751
  if (!res) {
1748
1752
  this._itemCount = 0;
1749
1753
  this._onFetchMoreCallback = undefined;
@@ -11870,11 +11874,10 @@ class EntityStore {
11870
11874
  /**
11871
11875
  *
11872
11876
  * @param opts
11873
- * opts.force : force all entities to be persist, and not only if dirty
11877
+ * opts.skipIfPristine = false persist all entities, even if not dirty
11874
11878
  */
11875
- persist(opts) {
11879
+ persist(opts = { skipIfPristine: true }) {
11876
11880
  return __awaiter(this, void 0, void 0, function* () {
11877
- opts = Object.assign({ skipIfPristine: this.policy.skipNonLocalEntities }, opts);
11878
11881
  // Skip is not dirty
11879
11882
  if (opts.skipIfPristine && !this._dirty) {
11880
11883
  console.debug(`[entity-storage] Persisting ${this.name} not need. Skip`);
@@ -12422,11 +12425,11 @@ class EntitiesStorage extends StartableService {
12422
12425
  this._$save.emit();
12423
12426
  });
12424
12427
  }
12425
- persist() {
12426
- if (this._dirty) {
12427
- return this.storeLocally();
12428
- }
12429
- return Promise.resolve();
12428
+ persist(opts = { skipIfPristine: true }) {
12429
+ // Skip if pristine
12430
+ if (opts.skipIfPristine && !this._dirty)
12431
+ return Promise.resolve();
12432
+ return this.storeLocally(opts);
12430
12433
  }
12431
12434
  ngOnStart() {
12432
12435
  return __awaiter(this, void 0, void 0, function* () {
@@ -12488,9 +12491,9 @@ class EntitiesStorage extends StartableService {
12488
12491
  console.debug(`[entities-storage] Restoring entities [OK] ${entitiesCount} entities found in ${Date.now() - now}ms`);
12489
12492
  });
12490
12493
  }
12491
- storeLocally() {
12494
+ storeLocally(opts = { skipIfPristine: true }) {
12492
12495
  return __awaiter(this, void 0, void 0, function* () {
12493
- if (!this.dirty)
12496
+ if (opts.skipIfPristine && !this.dirty)
12494
12497
  return; // skip
12495
12498
  // Saving progress: report this save later
12496
12499
  if (this._saving) {
@@ -12514,11 +12517,11 @@ class EntitiesStorage extends StartableService {
12514
12517
  console.warn(`[entities-storage] Persisting ${entityName}: store not found!`);
12515
12518
  return;
12516
12519
  }
12517
- // SKip store if not dirty
12518
- if (!entityStore.dirty)
12519
- return Promise.resolve(); // Skip
12520
+ // SKip store if pristine
12521
+ if (opts.skipIfPristine && !entityStore.dirty)
12522
+ return Promise.resolve();
12520
12523
  // Persist store
12521
- return (entityStore.dirty ? entityStore.persist() : Promise.resolve(entityStore.length))
12524
+ return entityStore.persist(opts)
12522
12525
  .then(count => {
12523
12526
  // If no entity found, remove from the entity names array
12524
12527
  if (!count) {