@sumaris-net/ngx-components 0.28.1 → 0.28.2

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.
@@ -19296,6 +19296,8 @@
19296
19296
  console.debug('[form] Updating form (using entity)', data);
19297
19297
  // Convert object to json, then apply it to form (e.g. convert 'undefined' into 'null')
19298
19298
  AppFormUtils.copyEntity2Form(data, this.form, Object.assign({ emitEvent: false, onlySelf: true }, opts));
19299
+ if (this._loading)
19300
+ this.markAsLoaded(Object.assign({ emitEvent: false, onlySelf: true }, opts));
19299
19301
  if (!opts || opts.emitEvent !== true)
19300
19302
  this.markForCheck();
19301
19303
  };
@@ -25516,6 +25518,13 @@
25516
25518
  enumerable: false,
25517
25519
  configurable: true
25518
25520
  });
25521
+ Object.defineProperty(AppEditor.prototype, "forms", {
25522
+ get: function () {
25523
+ return this._children && this._children.filter(function (c) { return c instanceof AppForm; });
25524
+ },
25525
+ enumerable: false,
25526
+ configurable: true
25527
+ });
25519
25528
  Object.defineProperty(AppEditor.prototype, "dirty", {
25520
25529
  get: function () {
25521
25530
  var _a;
@@ -25674,10 +25683,15 @@
25674
25683
  }
25675
25684
  };
25676
25685
  AppEditor.prototype.markAsLoaded = function (opts) {
25686
+ var _a;
25677
25687
  if (this._loading) {
25678
25688
  this._loading = false;
25679
- if (!opts || opts.emitEvent !== false)
25689
+ if (!opts || opts.emitEvent !== false) {
25690
+ // Emit to children forms
25691
+ // Tables should be changed by parent
25692
+ (_a = this.forms) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAsLoaded(opts); });
25680
25693
  this.markForCheck();
25694
+ }
25681
25695
  }
25682
25696
  };
25683
25697
  AppEditor.prototype.markAsReady = function (opts) {
@@ -26298,49 +26312,60 @@
26298
26312
  */
26299
26313
  AppEntityEditor.prototype.load = function (id, opts) {
26300
26314
  return __awaiter(this, void 0, void 0, function () {
26301
- var data, data, err_1;
26315
+ var data, err_1, data, err_2;
26302
26316
  return __generator(this, function (_b) {
26303
26317
  switch (_b.label) {
26304
26318
  case 0:
26305
26319
  if (!this.dataService)
26306
26320
  throw new Error('Cannot load data: missing \'dataService\'!');
26307
26321
  this.error = null;
26308
- if (!isNil(id)) return [3 /*break*/, 3];
26322
+ if (!isNil(id)) return [3 /*break*/, 7];
26323
+ _b.label = 1;
26324
+ case 1:
26325
+ _b.trys.push([1, 4, 5, 6]);
26309
26326
  data = new this.dataType();
26310
26327
  this._usageMode = this.computeUsageMode(data);
26311
26328
  return [4 /*yield*/, this.onNewEntity(data, opts)];
26312
- case 1:
26329
+ case 2:
26313
26330
  _b.sent();
26314
26331
  return [4 /*yield*/, this.updateView(data, Object.assign({ openTabIndex: 0 }, opts))];
26315
- case 2:
26332
+ case 3:
26316
26333
  _b.sent();
26334
+ return [3 /*break*/, 6];
26335
+ case 4:
26336
+ err_1 = _b.sent();
26337
+ this.setError(err_1);
26338
+ this.selectedTabIndex = 0;
26339
+ return [3 /*break*/, 6];
26340
+ case 5:
26317
26341
  this.markAsLoaded();
26318
- return [3 /*break*/, 9];
26319
- case 3:
26320
- _b.trys.push([3, 7, 8, 9]);
26342
+ return [7 /*endfinally*/];
26343
+ case 6: return [3 /*break*/, 13];
26344
+ case 7:
26345
+ _b.trys.push([7, 11, 12, 13]);
26321
26346
  return [4 /*yield*/, this.dataService.load(id, opts)];
26322
- case 4:
26347
+ case 8:
26323
26348
  data = _b.sent();
26324
26349
  if (!data)
26325
26350
  throw { code: ErrorCodes$2.DATA_NOT_FOUND_ERROR, message: 'ERROR.DATA_NO_FOUND' };
26326
26351
  this._usageMode = this.computeUsageMode(data);
26327
26352
  return [4 /*yield*/, this.onEntityLoaded(data, opts)];
26328
- case 5:
26353
+ case 9:
26329
26354
  _b.sent();
26330
26355
  return [4 /*yield*/, this.updateView(data, opts)];
26331
- case 6:
26356
+ case 10:
26332
26357
  _b.sent();
26333
26358
  this.startListenRemoteChanges();
26334
- return [3 /*break*/, 9];
26335
- case 7:
26336
- err_1 = _b.sent();
26337
- this.setError(err_1);
26359
+ return [3 /*break*/, 13];
26360
+ case 11:
26361
+ err_2 = _b.sent();
26362
+ this.setError(err_2);
26338
26363
  this.selectedTabIndex = 0;
26339
- return [3 /*break*/, 9];
26340
- case 8:
26364
+ return [3 /*break*/, 13];
26365
+ case 12:
26341
26366
  this.markAsLoaded();
26342
26367
  return [7 /*endfinally*/];
26343
- case 9: return [2 /*return*/];
26368
+ case 13: return [2 /*return*/];
26344
26369
  }
26345
26370
  });
26346
26371
  });
@@ -26515,7 +26540,7 @@
26515
26540
  */
26516
26541
  AppEntityEditor.prototype.save = function (event, opts) {
26517
26542
  return __awaiter(this, void 0, void 0, function () {
26518
- var data, updatedData, err_2;
26543
+ var data, updatedData, err_3;
26519
26544
  return __generator(this, function (_b) {
26520
26545
  switch (_b.label) {
26521
26546
  case 0:
@@ -26568,15 +26593,15 @@
26568
26593
  this.submitted = false;
26569
26594
  return [2 /*return*/, true];
26570
26595
  case 7:
26571
- err_2 = _b.sent();
26596
+ err_3 = _b.sent();
26572
26597
  this.submitted = true;
26573
- this.setError(err_2);
26598
+ this.setError(err_3);
26574
26599
  this.selectedTabIndex = 0;
26575
26600
  this.scrollToTop(); // Scroll to top (to show error)
26576
26601
  this.markAsDirty();
26577
26602
  this.enable();
26578
26603
  // Concurrent change on pod
26579
- if (err_2.code === ServerErrorCodes.BAD_UPDATE_DATE && isNotNil(this.data.id)) {
26604
+ if (err_3.code === ServerErrorCodes.BAD_UPDATE_DATE && isNotNil(this.data.id)) {
26580
26605
  // Call a data reload (in background), to update the GraphQL cache, and allow to cancel changes
26581
26606
  this.dataService.load(this.data.id, { fetchPolicy: 'network-only' }).then(function () {
26582
26607
  console.debug('[data-editor] Data cache reloaded. User can reload page');
@@ -26629,7 +26654,7 @@
26629
26654
  };
26630
26655
  AppEntityEditor.prototype.delete = function (event) {
26631
26656
  return __awaiter(this, void 0, void 0, function () {
26632
- var confirmation, data, isNew, err_3;
26657
+ var confirmation, data, isNew, err_4;
26633
26658
  var _this = this;
26634
26659
  return __generator(this, function (_b) {
26635
26660
  switch (_b.label) {
@@ -26664,9 +26689,9 @@
26664
26689
  this.removePageHistory();
26665
26690
  return [3 /*break*/, 8];
26666
26691
  case 7:
26667
- err_3 = _b.sent();
26692
+ err_4 = _b.sent();
26668
26693
  this.submitted = true;
26669
- this.setError(err_3);
26694
+ this.setError(err_4);
26670
26695
  this.selectedTabIndex = 0;
26671
26696
  this.markAsSaved();
26672
26697
  this.enable();