@sumaris-net/ngx-components 1.23.23 → 1.23.25

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.
@@ -21026,17 +21026,21 @@
21026
21026
  this.stop();
21027
21027
  };
21028
21028
  InMemoryEntitiesService.prototype.setValue = function (data) {
21029
- if (this.dataSubject.value !== data) {
21030
- // If service already started, then update data
21031
- if (this.started) {
21029
+ // If service already started
21030
+ if (this.started) {
21031
+ // Update the data, if changed
21032
+ if (this.dataSubject.value !== data) {
21032
21033
  this._hiddenData = [];
21033
21034
  this.dataSubject.next(data);
21034
- this.markAsPristine();
21035
- }
21036
- // if service not started yet, then start it, using given data
21037
- else {
21038
- this.start(data);
21039
21035
  }
21036
+ // Reset dirty and saving state
21037
+ // (Fix ObsBio issue on samples table : still dirty after setting the same value again)
21038
+ this.markAsSaved();
21039
+ this.markAsPristine();
21040
+ }
21041
+ // If service not started yet, then start it, using given data
21042
+ else {
21043
+ this.start(data);
21040
21044
  }
21041
21045
  };
21042
21046
  InMemoryEntitiesService.prototype.loadAll = function (offset, size, sortBy, sortDirection, filter, opts) {
@@ -21286,6 +21290,16 @@
21286
21290
  });
21287
21291
  });
21288
21292
  };
21293
+ InMemoryEntitiesService.prototype.markAsDirty = function () {
21294
+ if (!this.dirtySubject.value) {
21295
+ this.dirtySubject.next(true);
21296
+ }
21297
+ };
21298
+ InMemoryEntitiesService.prototype.markAsPristine = function () {
21299
+ if (this.dirtySubject.value) {
21300
+ this.dirtySubject.next(false);
21301
+ }
21302
+ };
21289
21303
  /* -- protected methods -- */
21290
21304
  InMemoryEntitiesService.prototype.filter = function (data, _filter, hiddenData) {
21291
21305
  // if filter is DataFilter instance, use its test function
@@ -21330,16 +21344,6 @@
21330
21344
  this.savingSubject.next(false);
21331
21345
  }
21332
21346
  };
21333
- InMemoryEntitiesService.prototype.markAsDirty = function () {
21334
- if (!this.dirtySubject.value) {
21335
- this.dirtySubject.next(true);
21336
- }
21337
- };
21338
- InMemoryEntitiesService.prototype.markAsPristine = function () {
21339
- if (this.dirtySubject.value) {
21340
- this.dirtySubject.next(false);
21341
- }
21342
- };
21343
21347
  return InMemoryEntitiesService;
21344
21348
  }(StartableObservableService));
21345
21349
  InMemoryEntitiesService.decorators = [
@@ -28426,11 +28430,12 @@
28426
28430
  this.translate = translate;
28427
28431
  this._subscription = new rxjs.Subscription();
28428
28432
  this._enabled = false;
28429
- this._dirty = false;
28430
28433
  this.destroySubject = new rxjs.Subject();
28431
28434
  this.readySubject = new rxjs.BehaviorSubject(false);
28435
+ this.dirtySubject = new rxjs.BehaviorSubject(false);
28432
28436
  this.loadingSubject = new rxjs.BehaviorSubject(true);
28433
28437
  this.errorSubject = new rxjs.BehaviorSubject(undefined);
28438
+ this.savingSubject = new rxjs.BehaviorSubject(false);
28434
28439
  this.debug = false;
28435
28440
  this.submitted = false;
28436
28441
  this.toolbar = null;
@@ -28482,6 +28487,14 @@
28482
28487
  enumerable: false,
28483
28488
  configurable: true
28484
28489
  });
28490
+ Object.defineProperty(AppEditor.prototype, "saving", {
28491
+ get: function () {
28492
+ var _a;
28493
+ return this.savingSubject.value || ((_a = this.editors) === null || _a === void 0 ? void 0 : _a.some(function (e) { return e.saving; }));
28494
+ },
28495
+ enumerable: false,
28496
+ configurable: true
28497
+ });
28485
28498
  Object.defineProperty(AppEditor.prototype, "tables", {
28486
28499
  get: function () {
28487
28500
  return this._children && this._children.filter(function (c) { return c instanceof AppTable; });
@@ -28505,7 +28518,7 @@
28505
28518
  });
28506
28519
  Object.defineProperty(AppEditor.prototype, "dirty", {
28507
28520
  get: function () {
28508
- return this._dirty || (this._children && this._children.findIndex(function (c) { return c.enabled && c.dirty; }) !== -1) || false;
28521
+ return this.dirtySubject.value || (this._children && this._children.findIndex(function (c) { return c.enabled && c.dirty; }) !== -1) || false;
28509
28522
  },
28510
28523
  enumerable: false,
28511
28524
  configurable: true
@@ -28565,7 +28578,7 @@
28565
28578
  });
28566
28579
  Object.defineProperty(AppEditor.prototype, "empty", {
28567
28580
  get: function () {
28568
- return this._enabled;
28581
+ return !this._enabled;
28569
28582
  },
28570
28583
  enumerable: false,
28571
28584
  configurable: true
@@ -28630,7 +28643,9 @@
28630
28643
  var _a;
28631
28644
  this.error = null;
28632
28645
  this.submitted = false;
28633
- this._dirty = false;
28646
+ if (this.dirtySubject.value !== false) {
28647
+ this.dirtySubject.next(false);
28648
+ }
28634
28649
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAsPristine(opts); });
28635
28650
  if (!this.loading && (!opts || opts.emitEvent !== false))
28636
28651
  this.markForCheck();
@@ -28658,9 +28673,11 @@
28658
28673
  this.markForCheck();
28659
28674
  };
28660
28675
  AppEditor.prototype.markAsDirty = function (opts) {
28661
- this._dirty = true;
28662
- if (!this.loading && (!opts || opts.emitEvent !== false))
28663
- this.markForCheck();
28676
+ if (!this.dirtySubject.value) {
28677
+ this.dirtySubject.next(true);
28678
+ if (!this.loading && (!opts || opts.emitEvent !== false))
28679
+ this.markForCheck();
28680
+ }
28664
28681
  };
28665
28682
  AppEditor.prototype.markAsLoading = function (opts) {
28666
28683
  if (!this.loadingSubject.value) {
@@ -28699,6 +28716,20 @@
28699
28716
  return Promise.resolve();
28700
28717
  return waitForFalse(this.loadingSubject, opts);
28701
28718
  };
28719
+ AppEditor.prototype.markAsSaving = function (opts) {
28720
+ if (this.savingSubject.value !== true) {
28721
+ this.savingSubject.next(true);
28722
+ if (!opts || opts.emitEvent !== false)
28723
+ this.markForCheck();
28724
+ }
28725
+ };
28726
+ AppEditor.prototype.markAsSaved = function (opts) {
28727
+ if (this.savingSubject.value !== false) {
28728
+ this.savingSubject.next(false);
28729
+ if (!opts || opts.emitEvent !== false)
28730
+ this.markForCheck();
28731
+ }
28732
+ };
28702
28733
  AppEditor.prototype.cancel = function (event) {
28703
28734
  return __awaiter(this, void 0, void 0, function () {
28704
28735
  return __generator(this, function (_c) {
@@ -28729,7 +28760,7 @@
28729
28760
  var _a;
28730
28761
  return __awaiter(this, void 0, void 0, function () {
28731
28762
  return __generator(this, function (_c) {
28732
- console.debug('[tab-page] Unloading data...');
28763
+ console.debug('[editor] Unloading data...');
28733
28764
  this.markAsLoading();
28734
28765
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
28735
28766
  if (f instanceof AppForm) {
@@ -28738,7 +28769,12 @@
28738
28769
  else if (f instanceof AppTable) {
28739
28770
  f.dataSource.disconnect();
28740
28771
  }
28772
+ else if (f instanceof AppEditor) {
28773
+ f.unload(opts);
28774
+ }
28741
28775
  });
28776
+ this.markAsPristine(opts);
28777
+ this.markAsSaved(opts);
28742
28778
  return [2 /*return*/];
28743
28779
  });
28744
28780
  });
@@ -28807,12 +28843,12 @@
28807
28843
  });
28808
28844
  });
28809
28845
  };
28810
- AppEditor.prototype.logFormErrors = function () {
28846
+ AppEditor.prototype.logFormErrors = function (prefix) {
28811
28847
  var _this = this;
28812
28848
  var _a;
28813
28849
  if (this.debug)
28814
- console.debug('[app-tab-editor] Page not valid. Checking where (forms, tables)...');
28815
- (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return _this.logChildrenFormErrors(c); });
28850
+ console.debug('[editor] Editor not valid. Checking where (forms, tables)...');
28851
+ (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return _this.logChildrenErrors(c, prefix); });
28816
28852
  };
28817
28853
  /* -- protected methods -- */
28818
28854
  AppEditor.prototype.scrollToTop = function (duration) {
@@ -28914,7 +28950,7 @@
28914
28950
  });
28915
28951
  });
28916
28952
  };
28917
- AppEditor.prototype.logChildrenFormErrors = function (c, prefix, path) {
28953
+ AppEditor.prototype.logChildrenErrors = function (c, prefix, path) {
28918
28954
  var _this = this;
28919
28955
  prefix = prefix || '[app-tab-editor] ';
28920
28956
  // If editor
@@ -28928,7 +28964,7 @@
28928
28964
  // If form provider: get delegate
28929
28965
  else if (c instanceof AppFormProvider) {
28930
28966
  if (!c.empty && !c.valid) {
28931
- c.waitDelegate({ timeout: 1000 }).then(function (delegate) { return _this.logChildrenFormErrors(delegate, prefix, 'provider'); });
28967
+ c.waitDelegate({ timeout: 1000 }).then(function (delegate) { return _this.logChildrenErrors(delegate, prefix, 'provider'); });
28932
28968
  }
28933
28969
  }
28934
28970
  // If table
@@ -28938,20 +28974,34 @@
28938
28974
  AppFormUtils.logFormErrors(c.editedRow.validator, prefix, path_1);
28939
28975
  }
28940
28976
  }
28941
- // If IAppForm
28977
+ // If form
28942
28978
  else if (c instanceof AppForm) {
28943
28979
  if (!c.empty && !c.valid) {
28944
28980
  if (c.pending) {
28945
28981
  var path_2 = c.constructor.name.toLowerCase();
28946
28982
  console.warn(prefix + " -> " + path_2 + ": waiting while pending...");
28947
28983
  AppFormUtils.waitWhilePending(c, { timeout: 1000 })
28948
- .then(function () { return _this.logChildrenFormErrors(c.form, prefix, path_2); });
28984
+ .then(function () { return _this.logChildrenErrors(c.form, prefix, path_2); });
28949
28985
  }
28950
28986
  else {
28951
28987
  AppFormUtils.logFormErrors(c.form, prefix);
28952
28988
  }
28953
28989
  }
28954
28990
  }
28991
+ // If editor
28992
+ else if (c instanceof AppEditor) {
28993
+ if (!c.empty && !c.valid) {
28994
+ if (c.pending) {
28995
+ var path_3 = c.constructor.name.toLowerCase();
28996
+ console.warn(prefix + " -> " + path_3 + ": waiting while pending...");
28997
+ AppFormUtils.waitWhilePending(c, { timeout: 1000 })
28998
+ .then(function () { return c.logFormErrors(prefix); });
28999
+ }
29000
+ else {
29001
+ c.logFormErrors(prefix);
29002
+ }
29003
+ }
29004
+ }
28955
29005
  else {
28956
29006
  console.warn(prefix + " Unknown children sub-form: ", c);
28957
29007
  }
@@ -29178,24 +29228,23 @@
29178
29228
  tabGroup: [{ type: i0.ViewChild, args: ['tabGroup', { static: true },] }]
29179
29229
  };
29180
29230
 
29181
- var AppEditorOptions = /** @class */ (function (_super) {
29182
- __extends(AppEditorOptions, _super);
29231
+ var AppEditorOptions = /** @class */ (function (_super_1) {
29232
+ __extends(AppEditorOptions, _super_1);
29183
29233
  function AppEditorOptions() {
29184
- return _super !== null && _super.apply(this, arguments) || this;
29234
+ return _super_1 !== null && _super_1.apply(this, arguments) || this;
29185
29235
  }
29186
29236
  return AppEditorOptions;
29187
29237
  }(AppTabEditorOptions));
29188
29238
  // @dynamic
29189
29239
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
29190
- var AppEntityEditor = /** @class */ (function (_super) {
29191
- __extends(AppEntityEditor, _super);
29240
+ var AppEntityEditor = /** @class */ (function (_super_1) {
29241
+ __extends(AppEntityEditor, _super_1);
29192
29242
  function AppEntityEditor(injector, dataType, dataService, options) {
29193
29243
  var _this = this;
29194
29244
  var _a, _b;
29195
- _this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
29245
+ _this = _super_1.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
29196
29246
  _this.dataType = dataType;
29197
29247
  _this.dataService = dataService;
29198
- _this.savingSubject = new rxjs.BehaviorSubject(false);
29199
29248
  _this.$title = new rxjs.Subject();
29200
29249
  _this.onUpdateView = new i0.EventEmitter();
29201
29250
  _this.environment = injector.get(ENVIRONMENT);
@@ -29251,20 +29300,6 @@
29251
29300
  enumerable: false,
29252
29301
  configurable: true
29253
29302
  });
29254
- Object.defineProperty(AppEntityEditor.prototype, "loading", {
29255
- get: function () {
29256
- return this.loadingSubject.value;
29257
- },
29258
- enumerable: false,
29259
- configurable: true
29260
- });
29261
- Object.defineProperty(AppEntityEditor.prototype, "saving", {
29262
- get: function () {
29263
- return this.savingSubject.value;
29264
- },
29265
- enumerable: false,
29266
- configurable: true
29267
- });
29268
29303
  Object.defineProperty(AppEntityEditor.prototype, "service", {
29269
29304
  get: function () {
29270
29305
  return this.dataService;
@@ -29272,22 +29307,8 @@
29272
29307
  enumerable: false,
29273
29308
  configurable: true
29274
29309
  });
29275
- AppEntityEditor.prototype.markAsSaving = function (opts) {
29276
- if (this.savingSubject.value !== true) {
29277
- this.savingSubject.next(true);
29278
- if (!opts || opts.emitEvent !== false)
29279
- this.markForCheck();
29280
- }
29281
- };
29282
- AppEntityEditor.prototype.markAsSaved = function (opts) {
29283
- if (this.savingSubject.value !== false) {
29284
- this.savingSubject.next(false);
29285
- if (!opts || opts.emitEvent !== false)
29286
- this.markForCheck();
29287
- }
29288
- };
29289
29310
  AppEntityEditor.prototype.ngOnInit = function () {
29290
- _super.prototype.ngOnInit.call(this);
29311
+ _super_1.prototype.ngOnInit.call(this);
29291
29312
  // Defaults
29292
29313
  this._autoOpenNextTab = toBoolean(this._autoOpenNextTab, !this.isOnFieldMode);
29293
29314
  this.historyIcon = this.historyIcon || { icon: 'list' };
@@ -29298,14 +29319,14 @@
29298
29319
  };
29299
29320
  AppEntityEditor.prototype.ngAfterViewInit = function () {
29300
29321
  var _this = this;
29301
- _super.prototype.ngAfterViewInit.call(this);
29322
+ _super_1.prototype.ngAfterViewInit.call(this);
29302
29323
  // Load data
29303
29324
  if (this._autoLoad) {
29304
29325
  setTimeout(function () { return _this.loadFromRoute(); }, this._autoLoadDelay);
29305
29326
  }
29306
29327
  };
29307
29328
  AppEntityEditor.prototype.ngOnDestroy = function () {
29308
- _super.prototype.ngOnDestroy.call(this);
29329
+ _super_1.prototype.ngOnDestroy.call(this);
29309
29330
  this._listenChangesSubscription = null; // already unsubscribe in the super function
29310
29331
  this.$title.complete();
29311
29332
  this.$title.unsubscribe();
@@ -29317,7 +29338,7 @@
29317
29338
  // Wait end of saving
29318
29339
  if (this.saving)
29319
29340
  return waitForFalse(this.savingSubject);
29320
- return _super.prototype.waitIdle.call(this, opts);
29341
+ return _super_1.prototype.waitIdle.call(this, opts);
29321
29342
  };
29322
29343
  /**
29323
29344
  * Load data from the snapshot route
@@ -29452,7 +29473,7 @@
29452
29473
  };
29453
29474
  AppEntityEditor.prototype.updateView = function (data, opts) {
29454
29475
  return __awaiter(this, void 0, void 0, function () {
29455
- var idChanged, promiseOrVoid;
29476
+ var idChanged;
29456
29477
  var _this = this;
29457
29478
  return __generator(this, function (_c) {
29458
29479
  switch (_c.label) {
@@ -29466,13 +29487,9 @@
29466
29487
  return [4 /*yield*/, this.ready()];
29467
29488
  case 1:
29468
29489
  _c.sent();
29469
- promiseOrVoid = this.setValue(data);
29470
- if (!promiseOrVoid) return [3 /*break*/, 3];
29471
- return [4 /*yield*/, promiseOrVoid];
29490
+ return [4 /*yield*/, this.setValue(data)];
29472
29491
  case 2:
29473
29492
  _c.sent();
29474
- _c.label = 3;
29475
- case 3:
29476
29493
  if (!opts || opts.emitEvent !== false) {
29477
29494
  this.markAsPristine();
29478
29495
  this.markAsUntouched();
@@ -29796,16 +29813,22 @@
29796
29813
  });
29797
29814
  });
29798
29815
  };
29799
- AppEntityEditor.prototype.unload = function () {
29816
+ AppEntityEditor.prototype.unload = function (opts) {
29817
+ var _super = Object.create(null, {
29818
+ unload: { get: function () { return _super_1.prototype.unload; } }
29819
+ });
29800
29820
  return __awaiter(this, void 0, void 0, function () {
29801
29821
  return __generator(this, function (_c) {
29802
- this.stopListenRemoteChanges();
29803
- this.form.reset();
29804
- this.registerForms();
29805
- this._dirty = false;
29806
- this.data = null;
29807
- this.savingSubject.next(false);
29808
- return [2 /*return*/];
29822
+ switch (_c.label) {
29823
+ case 0: return [4 /*yield*/, _super.unload.call(this, opts)];
29824
+ case 1:
29825
+ _c.sent();
29826
+ this.stopListenRemoteChanges();
29827
+ this.form.reset();
29828
+ this.registerForms();
29829
+ this.data = null;
29830
+ return [2 /*return*/];
29831
+ }
29809
29832
  });
29810
29833
  });
29811
29834
  };
@@ -29829,15 +29852,15 @@
29829
29852
  });
29830
29853
  };
29831
29854
  AppEntityEditor.prototype.resetError = function (opts) {
29832
- _super.prototype.resetError.call(this, opts);
29855
+ _super_1.prototype.resetError.call(this, opts);
29833
29856
  };
29834
29857
  AppEntityEditor.prototype.setError = function (err, opts) {
29835
29858
  if (!err) {
29836
- _super.prototype.setError.call(this, undefined, opts);
29859
+ _super_1.prototype.setError.call(this, undefined, opts);
29837
29860
  }
29838
29861
  else if (typeof err === 'string') {
29839
29862
  console.error('[entity-editor] Error: ' + (err || ''));
29840
- _super.prototype.setError.call(this, err, opts);
29863
+ _super_1.prototype.setError.call(this, err, opts);
29841
29864
  }
29842
29865
  else {
29843
29866
  console.error('[entity-editor] Error: ' + err.message || '', err);
@@ -29852,7 +29875,7 @@
29852
29875
  userMessage += detailMessage.length < 70 ? detailMessage : detailMessage.substring(0, 67) + '...';
29853
29876
  userMessage += '</small>';
29854
29877
  }
29855
- _super.prototype.setError.call(this, userMessage, opts);
29878
+ _super_1.prototype.setError.call(this, userMessage, opts);
29856
29879
  }
29857
29880
  };
29858
29881
  /* -- protected methods -- */