@sumaris-net/ngx-components 1.3.5 → 1.3.9

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.
@@ -1488,7 +1488,7 @@
1488
1488
  }
1489
1489
  }
1490
1490
  })),
1491
- // Merge some observables, with a common distinctUntilChanged() pipe
1491
+ // Merge some observables, with a common distinctUntilChanged() pipe, and NO debounceTime
1492
1492
  rxjs.merge(
1493
1493
  // Focus or click => Load all
1494
1494
  rxjs.merge(this.onFocus, this.onClick)
@@ -1497,7 +1497,11 @@
1497
1497
  this.onDropButtonClick
1498
1498
  .pipe(operators.filter(function (event) { return _this.searchable && (!event || !event.defaultPrevented) && _this.formControl.enabled; }), operators.map(function (_) { return _this.showAllOnFocus ? '*' : _this.formControl.value; })), rxjs.merge(this.$inputItems, this._filter$)
1499
1499
  .pipe(operators.map(function (_) { return _this.searchable && _this.formControl.value; })))
1500
- .pipe(operators.distinctUntilChanged()))
1500
+ .pipe(
1501
+ // If value is a string (and is not = '*'), filter if not enough character
1502
+ operators.filter(function (value) { return !(typeof value === 'string' && value === '*') || value.length >= _this.suggestLengthThreshold; }),
1503
+ // Distinguish changes
1504
+ operators.distinctUntilChanged()))
1501
1505
  .pipe(
1502
1506
  // DEBUG
1503
1507
  //tap(value => console.debug(this.logPrefix + ' Received update event: ', value)),
@@ -19484,12 +19488,11 @@
19484
19488
  console.warn('[form] Trying to set an empty value to form. Skipping');
19485
19489
  return;
19486
19490
  }
19487
- if (this.debug)
19488
- console.debug('[form] Updating form (using entity)', data);
19491
+ // DEBUG
19492
+ //if (this.debug) console.debug('[form] Updating form (using entity)', data);
19489
19493
  // Convert object to json, then apply it to form (e.g. convert 'undefined' into 'null')
19490
- AppFormUtils.copyEntity2Form(data, this.form, opts);
19491
- if (!opts || opts.emitEvent !== false) {
19492
- this.markAsLoaded({ emitEvent: false });
19494
+ AppFormUtils.copyEntity2Form(data, this.form, Object.assign({ emitEvent: false, onlySelf: true }, opts));
19495
+ if (!opts || opts.emitEvent !== true) {
19493
19496
  this.markForCheck();
19494
19497
  }
19495
19498
  };
@@ -20582,37 +20585,41 @@
20582
20585
  case 0:
20583
20586
  if (this.saving)
20584
20587
  return [2 /*return*/];
20588
+ if (!!this.form.valid) return [3 /*break*/, 2];
20585
20589
  return [4 /*yield*/, AppFormUtils.waitWhilePending(this.form)];
20586
20590
  case 1:
20587
20591
  _a.sent();
20588
20592
  if (this.form.invalid) {
20589
20593
  AppFormUtils.logFormErrors(this.form);
20594
+ this.form.markAllAsTouched();
20590
20595
  return [2 /*return*/];
20591
20596
  }
20597
+ _a.label = 2;
20598
+ case 2:
20592
20599
  this.submitted = true;
20593
20600
  this.saving = true;
20594
20601
  this.error = undefined;
20595
20602
  newAccount = exports.Account.fromObject(Object.assign(Object.assign({}, (this.accountService.account.asObject())), (this.form.value)));
20596
20603
  console.debug('[account] Saving account...', newAccount);
20597
- _a.label = 2;
20598
- case 2:
20599
- _a.trys.push([2, 4, 5, 6]);
20604
+ _a.label = 3;
20605
+ case 3:
20606
+ _a.trys.push([3, 5, 6, 7]);
20600
20607
  this.disable();
20601
20608
  return [4 /*yield*/, this.accountService.save(newAccount)];
20602
- case 3:
20609
+ case 4:
20603
20610
  _a.sent();
20604
20611
  this.markAsPristine();
20605
- return [3 /*break*/, 6];
20606
- case 4:
20612
+ return [3 /*break*/, 7];
20613
+ case 5:
20607
20614
  err_2 = _a.sent();
20608
20615
  console.error(err_2);
20609
20616
  this.error = err_2 && err_2.message || err_2;
20610
- return [3 /*break*/, 6];
20611
- case 5:
20617
+ return [3 /*break*/, 7];
20618
+ case 6:
20612
20619
  this.saving = false;
20613
20620
  this.enable();
20614
20621
  return [7 /*endfinally*/];
20615
- case 6: return [2 /*return*/];
20622
+ case 7: return [2 /*return*/];
20616
20623
  }
20617
20624
  });
20618
20625
  });
@@ -21199,25 +21206,33 @@
21199
21206
  event === null || event === void 0 ? void 0 : event.preventDefault();
21200
21207
  // Remove all empty controls
21201
21208
  this.propertiesFormHelper.removeAllEmpty();
21202
- if (this.form.invalid && this.debug) {
21209
+ if (!!this.form.valid) return [3 /*break*/, 2];
21210
+ return [4 /*yield*/, AppFormUtils.waitWhilePending(this.form)];
21211
+ case 1:
21212
+ _a.sent();
21213
+ if (this.form.invalid) {
21203
21214
  AppFormUtils.logFormErrors(this.form);
21215
+ this.form.markAllAsTouched();
21216
+ return [2 /*return*/];
21204
21217
  }
21218
+ _a.label = 2;
21219
+ case 2:
21205
21220
  console.debug('[settings] Saving local settings...');
21206
21221
  this.saving = true;
21207
21222
  this.error = undefined;
21208
21223
  return [4 /*yield*/, this.getValue()];
21209
- case 1:
21224
+ case 3:
21210
21225
  data = _a.sent();
21211
21226
  peerChanged = this.form.get('peerUrl').dirty;
21212
21227
  // Clean page history, when peer changed
21213
21228
  if (peerChanged)
21214
21229
  data.pageHistory = [];
21215
- _a.label = 2;
21216
- case 2:
21217
- _a.trys.push([2, 4, 5, 6]);
21230
+ _a.label = 4;
21231
+ case 4:
21232
+ _a.trys.push([4, 6, 7, 8]);
21218
21233
  this.disable();
21219
21234
  return [4 /*yield*/, this.settings.apply(data)];
21220
- case 3:
21235
+ case 5:
21221
21236
  _a.sent();
21222
21237
  this.data = data;
21223
21238
  this.markAsPristine();
@@ -21227,19 +21242,19 @@
21227
21242
  this.network.peer = exports.Peer.parseUrl(data.peerUrl);
21228
21243
  }
21229
21244
  return [2 /*return*/, true];
21230
- case 4:
21245
+ case 6:
21231
21246
  err_1 = _a.sent();
21232
21247
  console.error(err_1);
21233
21248
  this.error = err_1 && err_1.message || err_1;
21234
21249
  return [2 /*return*/, false];
21235
- case 5:
21250
+ case 7:
21236
21251
  this.enable({ emitEvent: false });
21237
21252
  // Apply inheritance
21238
21253
  this.setAccountInheritance(data.accountInheritance, { emitEvent: false });
21239
21254
  this.saving = false;
21240
21255
  this.markForCheck();
21241
21256
  return [7 /*endfinally*/];
21242
- case 6: return [2 /*return*/];
21257
+ case 8: return [2 /*return*/];
21243
21258
  }
21244
21259
  });
21245
21260
  });
@@ -24915,7 +24930,8 @@
24915
24930
  }
24916
24931
  this.markAsLoading();
24917
24932
  this.openRow(row.currentData.id, row)
24918
- .then(function () { return _this.markAsLoaded(); });
24933
+ .then(function () { return _this.markAsLoaded(); })
24934
+ .catch(function () { return _this.markAsLoaded(); });
24919
24935
  return true;
24920
24936
  }
24921
24937
  // Start editing row