@sumaris-net/ngx-components 1.21.1 → 1.21.4
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.
- package/bundles/sumaris-net.ngx-components.umd.js +87 -67
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/esm2015/src/app/core/form/editor.class.js +18 -4
- package/esm2015/src/app/core/form/entity-editor-modal.class.js +17 -25
- package/esm2015/src/app/core/form/entity-editor.class.js +25 -22
- package/esm2015/src/app/core/form/form.class.js +3 -3
- package/esm2015/src/app/core/table/table.class.js +9 -5
- package/fesm2015/sumaris-net.ngx-components.js +63 -50
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/src/app/core/form/editor.class.d.ts +5 -1
- package/src/app/core/form/entity-editor-modal.class.d.ts +4 -4
- package/src/app/core/form/entity-editor.class.d.ts +4 -3
- package/src/app/core/table/table.class.d.ts +6 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -19962,13 +19962,13 @@
|
|
|
19962
19962
|
* @deprecated
|
|
19963
19963
|
*/
|
|
19964
19964
|
get: function () {
|
|
19965
|
-
return this.
|
|
19965
|
+
return this.loadingSubject.value;
|
|
19966
19966
|
},
|
|
19967
19967
|
/**
|
|
19968
19968
|
* @deprecated
|
|
19969
19969
|
*/
|
|
19970
19970
|
set: function (value) {
|
|
19971
|
-
this.
|
|
19971
|
+
this.loadingSubject.next(value);
|
|
19972
19972
|
},
|
|
19973
19973
|
enumerable: false,
|
|
19974
19974
|
configurable: true
|
|
@@ -26157,6 +26157,9 @@
|
|
|
26157
26157
|
configurable: true
|
|
26158
26158
|
});
|
|
26159
26159
|
Object.defineProperty(AppTable.prototype, "loading$", {
|
|
26160
|
+
/**
|
|
26161
|
+
* @deprecated
|
|
26162
|
+
*/
|
|
26160
26163
|
get: function () {
|
|
26161
26164
|
return this.loadingSubject.asObservable();
|
|
26162
26165
|
},
|
|
@@ -26164,6 +26167,9 @@
|
|
|
26164
26167
|
configurable: true
|
|
26165
26168
|
});
|
|
26166
26169
|
Object.defineProperty(AppTable.prototype, "saving$", {
|
|
26170
|
+
/**
|
|
26171
|
+
* @deprecated
|
|
26172
|
+
*/
|
|
26167
26173
|
get: function () {
|
|
26168
26174
|
return this.savingSubject.asObservable();
|
|
26169
26175
|
},
|
|
@@ -26333,17 +26339,15 @@
|
|
|
26333
26339
|
if (this.savingSubject.value !== true) {
|
|
26334
26340
|
this.focusColumn = undefined; // unselect focus column
|
|
26335
26341
|
this.savingSubject.next(true);
|
|
26336
|
-
if (!opts || opts.emitEvent !== false)
|
|
26342
|
+
if (!opts || opts.emitEvent !== false)
|
|
26337
26343
|
this.markForCheck();
|
|
26338
|
-
}
|
|
26339
26344
|
}
|
|
26340
26345
|
};
|
|
26341
26346
|
AppTable.prototype.markAsSaved = function (opts) {
|
|
26342
26347
|
if (this.savingSubject.value !== false) {
|
|
26343
26348
|
this.savingSubject.next(false);
|
|
26344
|
-
if (!opts || opts.emitEvent !== false)
|
|
26349
|
+
if (!opts || opts.emitEvent !== false)
|
|
26345
26350
|
this.markForCheck();
|
|
26346
|
-
}
|
|
26347
26351
|
}
|
|
26348
26352
|
};
|
|
26349
26353
|
AppTable.prototype.markAsLoading = function (opts) {
|
|
@@ -28000,7 +28004,7 @@
|
|
|
28000
28004
|
* @deprecated
|
|
28001
28005
|
*/
|
|
28002
28006
|
set: function (value) {
|
|
28003
|
-
this.
|
|
28007
|
+
this.loadingSubject.next(value);
|
|
28004
28008
|
},
|
|
28005
28009
|
enumerable: false,
|
|
28006
28010
|
configurable: true
|
|
@@ -28495,11 +28499,13 @@
|
|
|
28495
28499
|
AppEditor.prototype.setError = function (value, opts) {
|
|
28496
28500
|
if (this.errorSubject.value !== value) {
|
|
28497
28501
|
this.errorSubject.next(value);
|
|
28498
|
-
if (!opts || opts.emitEvent !== false)
|
|
28502
|
+
if (!opts || opts.emitEvent !== false)
|
|
28499
28503
|
this.markForCheck();
|
|
28500
|
-
}
|
|
28501
28504
|
}
|
|
28502
28505
|
};
|
|
28506
|
+
AppEditor.prototype.resetError = function (opts) {
|
|
28507
|
+
this.setError(undefined, opts);
|
|
28508
|
+
};
|
|
28503
28509
|
AppEditor.prototype.markForCheck = function () {
|
|
28504
28510
|
// Should be override by subclasses, if change detection is Push
|
|
28505
28511
|
};
|
|
@@ -28572,6 +28578,8 @@
|
|
|
28572
28578
|
AppTabEditor.prototype.ngOnDestroy = function () {
|
|
28573
28579
|
_super_1.prototype.ngOnDestroy.call(this);
|
|
28574
28580
|
this.selectedTabIndexChange.complete();
|
|
28581
|
+
this.loadingSubject.unsubscribe();
|
|
28582
|
+
this.errorSubject.unsubscribe();
|
|
28575
28583
|
};
|
|
28576
28584
|
AppTabEditor.prototype.setSelectedTabIndex = function (value, opts) {
|
|
28577
28585
|
var _this = this;
|
|
@@ -28677,6 +28685,22 @@
|
|
|
28677
28685
|
});
|
|
28678
28686
|
});
|
|
28679
28687
|
};
|
|
28688
|
+
AppTabEditor.prototype.saveDirtyTables = function () {
|
|
28689
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
28690
|
+
var results, saved;
|
|
28691
|
+
return __generator(this, function (_b) {
|
|
28692
|
+
switch (_b.label) {
|
|
28693
|
+
case 0: return [4 /*yield*/, Promise.all((this.tables || [])
|
|
28694
|
+
.filter(function (c) { return c.dirty; })
|
|
28695
|
+
.map(function (c) { return c.save(); }))];
|
|
28696
|
+
case 1:
|
|
28697
|
+
results = _b.sent();
|
|
28698
|
+
saved = results.findIndex(function (result) { return result !== true; }) === -1;
|
|
28699
|
+
return [2 /*return*/, saved];
|
|
28700
|
+
}
|
|
28701
|
+
});
|
|
28702
|
+
});
|
|
28703
|
+
};
|
|
28680
28704
|
return AppTabEditor;
|
|
28681
28705
|
}(AppEditor));
|
|
28682
28706
|
AppTabEditor.decorators = [
|
|
@@ -28713,7 +28737,7 @@
|
|
|
28713
28737
|
_this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
|
|
28714
28738
|
_this.dataType = dataType;
|
|
28715
28739
|
_this.dataService = dataService;
|
|
28716
|
-
_this.
|
|
28740
|
+
_this.savingSubject = new rxjs.BehaviorSubject(false);
|
|
28717
28741
|
_this.$title = new rxjs.Subject();
|
|
28718
28742
|
_this.onUpdateView = new i0.EventEmitter();
|
|
28719
28743
|
_this.environement = injector.get(ENVIRONMENT);
|
|
@@ -28771,7 +28795,14 @@
|
|
|
28771
28795
|
});
|
|
28772
28796
|
Object.defineProperty(AppEntityEditor.prototype, "loading", {
|
|
28773
28797
|
get: function () {
|
|
28774
|
-
return this.
|
|
28798
|
+
return this.loadingSubject.value;
|
|
28799
|
+
},
|
|
28800
|
+
enumerable: false,
|
|
28801
|
+
configurable: true
|
|
28802
|
+
});
|
|
28803
|
+
Object.defineProperty(AppEntityEditor.prototype, "saving", {
|
|
28804
|
+
get: function () {
|
|
28805
|
+
return this.savingSubject.value;
|
|
28775
28806
|
},
|
|
28776
28807
|
enumerable: false,
|
|
28777
28808
|
configurable: true
|
|
@@ -28784,15 +28815,15 @@
|
|
|
28784
28815
|
configurable: true
|
|
28785
28816
|
});
|
|
28786
28817
|
AppEntityEditor.prototype.markAsSaving = function (opts) {
|
|
28787
|
-
if (
|
|
28788
|
-
this.
|
|
28818
|
+
if (this.savingSubject.value !== true) {
|
|
28819
|
+
this.savingSubject.next(true);
|
|
28789
28820
|
if (!opts || opts.emitEvent !== false)
|
|
28790
28821
|
this.markForCheck();
|
|
28791
28822
|
}
|
|
28792
28823
|
};
|
|
28793
28824
|
AppEntityEditor.prototype.markAsSaved = function (opts) {
|
|
28794
|
-
if (this.
|
|
28795
|
-
this.
|
|
28825
|
+
if (this.savingSubject.value !== false) {
|
|
28826
|
+
this.savingSubject.next(false);
|
|
28796
28827
|
if (!opts || opts.emitEvent !== false)
|
|
28797
28828
|
this.markForCheck();
|
|
28798
28829
|
}
|
|
@@ -28822,12 +28853,12 @@
|
|
|
28822
28853
|
this.$title.unsubscribe();
|
|
28823
28854
|
this.onUpdateView.complete();
|
|
28824
28855
|
this.onUpdateView.unsubscribe();
|
|
28856
|
+
this.savingSubject.unsubscribe();
|
|
28825
28857
|
};
|
|
28826
28858
|
AppEntityEditor.prototype.waitIdle = function (opts) {
|
|
28827
|
-
var _this = this;
|
|
28828
28859
|
// Wait end of saving
|
|
28829
28860
|
if (this.saving)
|
|
28830
|
-
return
|
|
28861
|
+
return waitForFalse(this.savingSubject);
|
|
28831
28862
|
return _super.prototype.waitIdle.call(this, opts);
|
|
28832
28863
|
};
|
|
28833
28864
|
/**
|
|
@@ -29114,7 +29145,7 @@
|
|
|
29114
29145
|
*/
|
|
29115
29146
|
AppEntityEditor.prototype.save = function (event, opts) {
|
|
29116
29147
|
return __awaiter(this, void 0, void 0, function () {
|
|
29117
|
-
var nextTabIndex, data, updatedData, err_3;
|
|
29148
|
+
var nextTabIndex, saved, data, updatedData, err_3;
|
|
29118
29149
|
return __generator(this, function (_c) {
|
|
29119
29150
|
switch (_c.label) {
|
|
29120
29151
|
case 0:
|
|
@@ -29133,9 +29164,10 @@
|
|
|
29133
29164
|
_c.sent();
|
|
29134
29165
|
// If invalid
|
|
29135
29166
|
if (this.invalid) {
|
|
29136
|
-
this.markAllAsTouched();
|
|
29137
29167
|
this.logFormErrors();
|
|
29138
29168
|
this.openFirstInvalidTab();
|
|
29169
|
+
this.scrollToTop();
|
|
29170
|
+
this.markAllAsTouched();
|
|
29139
29171
|
this.submitted = true;
|
|
29140
29172
|
return [2 /*return*/, false];
|
|
29141
29173
|
}
|
|
@@ -29145,24 +29177,29 @@
|
|
|
29145
29177
|
console.debug('[data-editor] Saving data...');
|
|
29146
29178
|
_c.label = 2;
|
|
29147
29179
|
case 2:
|
|
29148
|
-
_c.trys.push([2,
|
|
29180
|
+
_c.trys.push([2, 8, 9, 10]);
|
|
29149
29181
|
nextTabIndex = this._autoOpenNextTab && isNil(this.previousDataId) && this.computeNextTabIndex();
|
|
29150
|
-
return [4 /*yield*/, this.
|
|
29182
|
+
return [4 /*yield*/, this.saveDirtyTables()];
|
|
29151
29183
|
case 3:
|
|
29184
|
+
saved = _c.sent();
|
|
29185
|
+
if (!saved)
|
|
29186
|
+
return [2 /*return*/, false];
|
|
29187
|
+
return [4 /*yield*/, this.getValue()];
|
|
29188
|
+
case 4:
|
|
29152
29189
|
data = _c.sent();
|
|
29153
29190
|
this.disable();
|
|
29154
29191
|
return [4 /*yield*/, this.dataService.save(data, opts)];
|
|
29155
|
-
case
|
|
29192
|
+
case 5:
|
|
29156
29193
|
updatedData = _c.sent();
|
|
29157
29194
|
return [4 /*yield*/, this.onEntitySaved(updatedData)];
|
|
29158
|
-
case
|
|
29195
|
+
case 6:
|
|
29159
29196
|
_c.sent();
|
|
29160
29197
|
// Update the view (e.g metadata)
|
|
29161
29198
|
return [4 /*yield*/, this.updateView(updatedData, Object.assign({
|
|
29162
29199
|
// Open next tab only if user has not changed it
|
|
29163
29200
|
openTabIndex: nextTabIndex > this._selectedTabIndex ? nextTabIndex : undefined
|
|
29164
29201
|
}, opts))];
|
|
29165
|
-
case
|
|
29202
|
+
case 7:
|
|
29166
29203
|
// Update the view (e.g metadata)
|
|
29167
29204
|
_c.sent();
|
|
29168
29205
|
// Subscribe to remote changes
|
|
@@ -29170,7 +29207,7 @@
|
|
|
29170
29207
|
this.startListenRemoteChanges();
|
|
29171
29208
|
this.submitted = false;
|
|
29172
29209
|
return [2 /*return*/, true];
|
|
29173
|
-
case
|
|
29210
|
+
case 8:
|
|
29174
29211
|
err_3 = _c.sent();
|
|
29175
29212
|
this.submitted = true;
|
|
29176
29213
|
this.setError(err_3);
|
|
@@ -29186,10 +29223,10 @@
|
|
|
29186
29223
|
});
|
|
29187
29224
|
}
|
|
29188
29225
|
return [2 /*return*/, false];
|
|
29189
|
-
case
|
|
29226
|
+
case 9:
|
|
29190
29227
|
this.markAsSaved();
|
|
29191
29228
|
return [7 /*endfinally*/];
|
|
29192
|
-
case
|
|
29229
|
+
case 10: return [2 /*return*/];
|
|
29193
29230
|
}
|
|
29194
29231
|
});
|
|
29195
29232
|
});
|
|
@@ -29308,7 +29345,7 @@
|
|
|
29308
29345
|
this.registerForms();
|
|
29309
29346
|
this._dirty = false;
|
|
29310
29347
|
this.data = null;
|
|
29311
|
-
this.
|
|
29348
|
+
this.savingSubject.next(false);
|
|
29312
29349
|
return [2 /*return*/];
|
|
29313
29350
|
});
|
|
29314
29351
|
});
|
|
@@ -29333,19 +29370,15 @@
|
|
|
29333
29370
|
});
|
|
29334
29371
|
};
|
|
29335
29372
|
AppEntityEditor.prototype.resetError = function (opts) {
|
|
29336
|
-
|
|
29337
|
-
this.error = null;
|
|
29338
|
-
if (!opts || opts.emitEvent !== false)
|
|
29339
|
-
this.markForCheck();
|
|
29340
|
-
}
|
|
29373
|
+
_super.prototype.resetError.call(this, opts);
|
|
29341
29374
|
};
|
|
29342
29375
|
AppEntityEditor.prototype.setError = function (err, opts) {
|
|
29343
29376
|
if (!err) {
|
|
29344
|
-
this
|
|
29377
|
+
_super.prototype.setError.call(this, undefined, opts);
|
|
29345
29378
|
}
|
|
29346
29379
|
else if (typeof err === 'string') {
|
|
29347
29380
|
console.error('[entity-editor] Error: ' + (err || ''));
|
|
29348
|
-
this
|
|
29381
|
+
_super.prototype.setError.call(this, err, opts);
|
|
29349
29382
|
}
|
|
29350
29383
|
else {
|
|
29351
29384
|
console.error('[entity-editor] Error: ' + err.message || '', err);
|
|
@@ -29360,10 +29393,8 @@
|
|
|
29360
29393
|
userMessage += detailMessage.length < 70 ? detailMessage : detailMessage.substring(0, 67) + '...';
|
|
29361
29394
|
userMessage += '</small>';
|
|
29362
29395
|
}
|
|
29363
|
-
this
|
|
29396
|
+
_super.prototype.setError.call(this, userMessage, opts);
|
|
29364
29397
|
}
|
|
29365
|
-
if (!opts || opts.emitEvent !== false)
|
|
29366
|
-
this.markForCheck();
|
|
29367
29398
|
};
|
|
29368
29399
|
/* -- protected methods -- */
|
|
29369
29400
|
/**
|
|
@@ -29571,7 +29602,7 @@
|
|
|
29571
29602
|
function AppEntityEditorModal(injector, dataType, options) {
|
|
29572
29603
|
var _this = _super_1.call(this, null, injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
|
|
29573
29604
|
_this.dataType = dataType;
|
|
29574
|
-
_this.
|
|
29605
|
+
_this.savingSubject = new rxjs.BehaviorSubject(false);
|
|
29575
29606
|
_this.$title = new rxjs.Subject();
|
|
29576
29607
|
_this.i18nSuffix = null;
|
|
29577
29608
|
_this.environement = injector.get(ENVIRONMENT);
|
|
@@ -29621,16 +29652,23 @@
|
|
|
29621
29652
|
enumerable: false,
|
|
29622
29653
|
configurable: true
|
|
29623
29654
|
});
|
|
29655
|
+
Object.defineProperty(AppEntityEditorModal.prototype, "saving", {
|
|
29656
|
+
get: function () {
|
|
29657
|
+
return this.savingSubject.value;
|
|
29658
|
+
},
|
|
29659
|
+
enumerable: false,
|
|
29660
|
+
configurable: true
|
|
29661
|
+
});
|
|
29624
29662
|
AppEntityEditorModal.prototype.markAsSaving = function (opts) {
|
|
29625
|
-
if (
|
|
29626
|
-
this.
|
|
29663
|
+
if (this.savingSubject.value !== true) {
|
|
29664
|
+
this.savingSubject.next(true);
|
|
29627
29665
|
if (!opts || opts.emitEvent !== false)
|
|
29628
29666
|
this.markForCheck();
|
|
29629
29667
|
}
|
|
29630
29668
|
};
|
|
29631
29669
|
AppEntityEditorModal.prototype.markAsSaved = function (opts) {
|
|
29632
|
-
if (this.
|
|
29633
|
-
this.
|
|
29670
|
+
if (this.savingSubject.value !== false) {
|
|
29671
|
+
this.savingSubject.next(false);
|
|
29634
29672
|
if (!opts || opts.emitEvent !== false)
|
|
29635
29673
|
this.markForCheck();
|
|
29636
29674
|
}
|
|
@@ -29679,12 +29717,12 @@
|
|
|
29679
29717
|
_super_1.prototype.ngOnDestroy.call(this);
|
|
29680
29718
|
this.$title.complete();
|
|
29681
29719
|
this.$title.unsubscribe();
|
|
29720
|
+
this.savingSubject.unsubscribe();
|
|
29682
29721
|
};
|
|
29683
29722
|
AppEntityEditorModal.prototype.waitIdle = function (opts) {
|
|
29684
|
-
var _this = this;
|
|
29685
29723
|
// Wait end of saving
|
|
29686
29724
|
if (this.saving)
|
|
29687
|
-
return
|
|
29725
|
+
return waitForFalse(this.savingSubject);
|
|
29688
29726
|
return _super_1.prototype.waitIdle.call(this, opts);
|
|
29689
29727
|
};
|
|
29690
29728
|
AppEntityEditorModal.prototype.load = function () {
|
|
@@ -29834,9 +29872,9 @@
|
|
|
29834
29872
|
if (this.invalid) {
|
|
29835
29873
|
this.logFormErrors();
|
|
29836
29874
|
this.setError('COMMON.FORM.HAS_ERROR');
|
|
29837
|
-
this.markAllAsTouched();
|
|
29838
29875
|
this.openFirstInvalidTab();
|
|
29839
29876
|
this.scrollToTop();
|
|
29877
|
+
this.markAllAsTouched();
|
|
29840
29878
|
this.submitted = true;
|
|
29841
29879
|
return [2 /*return*/, false];
|
|
29842
29880
|
}
|
|
@@ -29972,11 +30010,11 @@
|
|
|
29972
30010
|
};
|
|
29973
30011
|
AppEntityEditorModal.prototype.setError = function (err, opts) {
|
|
29974
30012
|
if (!err) {
|
|
29975
|
-
this
|
|
30013
|
+
_super_1.prototype.setError.call(this, undefined, opts);
|
|
29976
30014
|
}
|
|
29977
30015
|
else if (typeof err === 'string') {
|
|
29978
30016
|
console.error('[entity-editor] Error: ' + (err || ''));
|
|
29979
|
-
this
|
|
30017
|
+
_super_1.prototype.setError.call(this, err, opts);
|
|
29980
30018
|
}
|
|
29981
30019
|
else {
|
|
29982
30020
|
console.error('[entity-editor] Error: ' + err.message || '', err);
|
|
@@ -29991,28 +30029,10 @@
|
|
|
29991
30029
|
userMessage += detailMessage.length < 70 ? detailMessage : detailMessage.substring(0, 67) + '...';
|
|
29992
30030
|
userMessage += '</small>';
|
|
29993
30031
|
}
|
|
29994
|
-
this
|
|
30032
|
+
_super_1.prototype.setError.call(this, userMessage, opts);
|
|
29995
30033
|
}
|
|
29996
|
-
if (!opts || opts.emitEvent !== false)
|
|
29997
|
-
this.markForCheck();
|
|
29998
30034
|
};
|
|
29999
30035
|
/* -- protected methods -- */
|
|
30000
|
-
AppEntityEditorModal.prototype.saveDirtyTables = function () {
|
|
30001
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
30002
|
-
var results, saved;
|
|
30003
|
-
return __generator(this, function (_b) {
|
|
30004
|
-
switch (_b.label) {
|
|
30005
|
-
case 0: return [4 /*yield*/, Promise.all((this.tables || [])
|
|
30006
|
-
.filter(function (c) { return c.dirty; })
|
|
30007
|
-
.map(function (c) { return c.save(); }))];
|
|
30008
|
-
case 1:
|
|
30009
|
-
results = _b.sent();
|
|
30010
|
-
saved = results.findIndex(function (result) { return result !== true; }) === -1;
|
|
30011
|
-
return [2 /*return*/, saved];
|
|
30012
|
-
}
|
|
30013
|
-
});
|
|
30014
|
-
});
|
|
30015
|
-
};
|
|
30016
30036
|
AppEntityEditorModal.prototype.waitWhilePending = function (opts) {
|
|
30017
30037
|
return AppFormUtils.waitWhilePending(this, opts);
|
|
30018
30038
|
};
|