@sumaris-net/ngx-components 1.21.1 → 1.21.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.
@@ -17447,13 +17447,13 @@ class AppForm {
17447
17447
  * @deprecated
17448
17448
  */
17449
17449
  set _loading(value) {
17450
- this._$loading.next(value);
17450
+ this.loadingSubject.next(value);
17451
17451
  }
17452
17452
  /**
17453
17453
  * @deprecated
17454
17454
  */
17455
17455
  get _loading() {
17456
- return this._$loading.value;
17456
+ return this.loadingSubject.value;
17457
17457
  }
17458
17458
  /**
17459
17459
  * @deprecated
@@ -22635,9 +22635,15 @@ class AppTable {
22635
22635
  set error(error) {
22636
22636
  this.setError(error);
22637
22637
  }
22638
+ /**
22639
+ * @deprecated
22640
+ */
22638
22641
  get loading$() {
22639
22642
  return this.loadingSubject.asObservable();
22640
22643
  }
22644
+ /**
22645
+ * @deprecated
22646
+ */
22641
22647
  get saving$() {
22642
22648
  return this.savingSubject.asObservable();
22643
22649
  }
@@ -22760,17 +22766,15 @@ class AppTable {
22760
22766
  if (this.savingSubject.value !== true) {
22761
22767
  this.focusColumn = undefined; // unselect focus column
22762
22768
  this.savingSubject.next(true);
22763
- if (!opts || opts.emitEvent !== false) {
22769
+ if (!opts || opts.emitEvent !== false)
22764
22770
  this.markForCheck();
22765
- }
22766
22771
  }
22767
22772
  }
22768
22773
  markAsSaved(opts) {
22769
22774
  if (this.savingSubject.value !== false) {
22770
22775
  this.savingSubject.next(false);
22771
- if (!opts || opts.emitEvent !== false) {
22776
+ if (!opts || opts.emitEvent !== false)
22772
22777
  this.markForCheck();
22773
- }
22774
22778
  }
22775
22779
  }
22776
22780
  markAsLoading(opts) {
@@ -24189,7 +24193,7 @@ class AppEditor {
24189
24193
  * @deprecated
24190
24194
  */
24191
24195
  set _loading(value) {
24192
- this.readySubject.next(value);
24196
+ this.loadingSubject.next(value);
24193
24197
  }
24194
24198
  /**
24195
24199
  * @deprecated
@@ -24645,6 +24649,8 @@ class AppTabEditor extends AppEditor {
24645
24649
  ngOnDestroy() {
24646
24650
  super.ngOnDestroy();
24647
24651
  this.selectedTabIndexChange.complete();
24652
+ this.loadingSubject.unsubscribe();
24653
+ this.errorSubject.unsubscribe();
24648
24654
  }
24649
24655
  setSelectedTabIndex(value, opts) {
24650
24656
  // Fix value
@@ -24740,6 +24746,16 @@ class AppTabEditor extends AppEditor {
24740
24746
  yield _super.unload.call(this, opts);
24741
24747
  });
24742
24748
  }
24749
+ saveDirtyTables() {
24750
+ return __awaiter(this, void 0, void 0, function* () {
24751
+ // Save all dirty tables
24752
+ const results = yield Promise.all((this.tables || [])
24753
+ .filter(c => c.dirty)
24754
+ .map(c => c.save()));
24755
+ const saved = results.findIndex(result => result !== true) === -1;
24756
+ return saved;
24757
+ });
24758
+ }
24743
24759
  }
24744
24760
  AppTabEditor.decorators = [
24745
24761
  { type: Directive }
@@ -24768,7 +24784,7 @@ class AppEntityEditor extends AppTabEditor {
24768
24784
  super(injector.get(ActivatedRoute), injector.get(Router), injector.get(AlertController), injector.get(TranslateService), options);
24769
24785
  this.dataType = dataType;
24770
24786
  this.dataService = dataService;
24771
- this.saving = false;
24787
+ this.savingSubject = new BehaviorSubject(false);
24772
24788
  this.$title = new Subject();
24773
24789
  this.onUpdateView = new EventEmitter();
24774
24790
  this.environement = injector.get(ENVIRONMENT);
@@ -24811,21 +24827,24 @@ class AppEntityEditor extends AppTabEditor {
24811
24827
  return isNil((_a = this.data) === null || _a === void 0 ? void 0 : _a.id);
24812
24828
  }
24813
24829
  get loading() {
24814
- return this._loading;
24830
+ return this.loadingSubject.value;
24831
+ }
24832
+ get saving() {
24833
+ return this.savingSubject.value;
24815
24834
  }
24816
24835
  get service() {
24817
24836
  return this.dataService;
24818
24837
  }
24819
24838
  markAsSaving(opts) {
24820
- if (!this.saving) {
24821
- this.saving = true;
24839
+ if (this.savingSubject.value !== true) {
24840
+ this.savingSubject.next(true);
24822
24841
  if (!opts || opts.emitEvent !== false)
24823
24842
  this.markForCheck();
24824
24843
  }
24825
24844
  }
24826
24845
  markAsSaved(opts) {
24827
- if (this.saving) {
24828
- this.saving = false;
24846
+ if (this.savingSubject.value !== false) {
24847
+ this.savingSubject.next(false);
24829
24848
  if (!opts || opts.emitEvent !== false)
24830
24849
  this.markForCheck();
24831
24850
  }
@@ -24854,11 +24873,12 @@ class AppEntityEditor extends AppTabEditor {
24854
24873
  this.$title.unsubscribe();
24855
24874
  this.onUpdateView.complete();
24856
24875
  this.onUpdateView.unsubscribe();
24876
+ this.savingSubject.unsubscribe();
24857
24877
  }
24858
24878
  waitIdle(opts) {
24859
24879
  // Wait end of saving
24860
24880
  if (this.saving)
24861
- return waitFor(() => this.saving !== true);
24881
+ return waitForFalse(this.savingSubject);
24862
24882
  return super.waitIdle(opts);
24863
24883
  }
24864
24884
  /**
@@ -25103,9 +25123,10 @@ class AppEntityEditor extends AppTabEditor {
25103
25123
  yield this.waitWhilePending();
25104
25124
  // If invalid
25105
25125
  if (this.invalid) {
25106
- this.markAllAsTouched();
25107
25126
  this.logFormErrors();
25108
25127
  this.openFirstInvalidTab();
25128
+ this.scrollToTop();
25129
+ this.markAllAsTouched();
25109
25130
  this.submitted = true;
25110
25131
  return false;
25111
25132
  }
@@ -25116,6 +25137,10 @@ class AppEntityEditor extends AppTabEditor {
25116
25137
  try {
25117
25138
  // Compute next tab index (if enable)
25118
25139
  const nextTabIndex = this._autoOpenNextTab && isNil(this.previousDataId) && this.computeNextTabIndex();
25140
+ // Save all dirty tables
25141
+ const saved = yield this.saveDirtyTables();
25142
+ if (!saved)
25143
+ return false;
25119
25144
  // Get data
25120
25145
  const data = yield this.getValue();
25121
25146
  this.disable();
@@ -25229,7 +25254,7 @@ class AppEntityEditor extends AppTabEditor {
25229
25254
  this.registerForms();
25230
25255
  this._dirty = false;
25231
25256
  this.data = null;
25232
- this.saving = false;
25257
+ this.savingSubject.next(false);
25233
25258
  });
25234
25259
  }
25235
25260
  goBack(event) {
@@ -25439,7 +25464,7 @@ class AppEntityEditorModal extends AppTabEditor {
25439
25464
  constructor(injector, dataType, options) {
25440
25465
  super(null, injector.get(Router), injector.get(AlertController), injector.get(TranslateService), options);
25441
25466
  this.dataType = dataType;
25442
- this.saving = false;
25467
+ this.savingSubject = new BehaviorSubject(false);
25443
25468
  this.$title = new Subject();
25444
25469
  this.i18nSuffix = null;
25445
25470
  this.environement = injector.get(ENVIRONMENT);
@@ -25475,16 +25500,19 @@ class AppEntityEditorModal extends AppTabEditor {
25475
25500
  get isOnFieldMode() {
25476
25501
  return this.settings.isOnFieldMode(this._usageMode);
25477
25502
  }
25503
+ get saving() {
25504
+ return this.savingSubject.value;
25505
+ }
25478
25506
  markAsSaving(opts) {
25479
- if (!this.saving) {
25480
- this.saving = true;
25507
+ if (this.savingSubject.value !== true) {
25508
+ this.savingSubject.next(true);
25481
25509
  if (!opts || opts.emitEvent !== false)
25482
25510
  this.markForCheck();
25483
25511
  }
25484
25512
  }
25485
25513
  markAsSaved(opts) {
25486
- if (this.saving) {
25487
- this.saving = false;
25514
+ if (this.savingSubject.value !== false) {
25515
+ this.savingSubject.next(false);
25488
25516
  if (!opts || opts.emitEvent !== false)
25489
25517
  this.markForCheck();
25490
25518
  }
@@ -25528,11 +25556,12 @@ class AppEntityEditorModal extends AppTabEditor {
25528
25556
  super.ngOnDestroy();
25529
25557
  this.$title.complete();
25530
25558
  this.$title.unsubscribe();
25559
+ this.savingSubject.unsubscribe();
25531
25560
  }
25532
25561
  waitIdle(opts) {
25533
25562
  // Wait end of saving
25534
25563
  if (this.saving)
25535
- return waitFor(() => this.saving !== true);
25564
+ return waitForFalse(this.savingSubject);
25536
25565
  return super.waitIdle(opts);
25537
25566
  }
25538
25567
  load() {
@@ -25638,9 +25667,9 @@ class AppEntityEditorModal extends AppTabEditor {
25638
25667
  if (this.invalid) {
25639
25668
  this.logFormErrors();
25640
25669
  this.setError('COMMON.FORM.HAS_ERROR');
25641
- this.markAllAsTouched();
25642
25670
  this.openFirstInvalidTab();
25643
25671
  this.scrollToTop();
25672
+ this.markAllAsTouched();
25644
25673
  this.submitted = true;
25645
25674
  return false;
25646
25675
  }
@@ -25769,16 +25798,6 @@ class AppEntityEditorModal extends AppTabEditor {
25769
25798
  this.markForCheck();
25770
25799
  }
25771
25800
  /* -- protected methods -- */
25772
- saveDirtyTables() {
25773
- return __awaiter(this, void 0, void 0, function* () {
25774
- // Save all dirty tables
25775
- const results = yield Promise.all((this.tables || [])
25776
- .filter(c => c.dirty)
25777
- .map(c => c.save()));
25778
- const saved = results.findIndex(result => result !== true) === -1;
25779
- return saved;
25780
- });
25781
- }
25782
25801
  waitWhilePending(opts) {
25783
25802
  return AppFormUtils.waitWhilePending(this, opts);
25784
25803
  }