@sumaris-net/ngx-components 1.20.18 → 1.20.19
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 +528 -6
- 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/doc/changelog.md +3 -0
- package/esm2015/public_api.js +2 -2
- package/esm2015/src/app/core/form/editor.class.js +8 -7
- package/esm2015/src/app/core/form/entity-editor-modal.class.js +417 -0
- package/fesm2015/sumaris-net.ngx-components.js +408 -7
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +1 -1
- package/src/app/core/form/editor.class.d.ts +2 -1
- package/src/app/core/form/entity-editor-modal.class.d.ts +118 -0
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -28421,7 +28421,8 @@
|
|
|
28421
28421
|
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
28422
28422
|
var AppTabEditor = /** @class */ (function (_super_1) {
|
|
28423
28423
|
__extends(AppTabEditor, _super_1);
|
|
28424
|
-
function AppTabEditor(route,
|
|
28424
|
+
function AppTabEditor(route, // Modal editor give 'null'
|
|
28425
|
+
router, alertCtrl, translate, options) {
|
|
28425
28426
|
var _this = _super_1.call(this, route, router, alertCtrl, translate) || this;
|
|
28426
28427
|
_this.route = route;
|
|
28427
28428
|
_this.router = router;
|
|
@@ -28433,6 +28434,7 @@
|
|
|
28433
28434
|
_this.tabCount = options.tabCount;
|
|
28434
28435
|
_this.enableSwipe = options.enableSwipe;
|
|
28435
28436
|
_this.tabGroupAnimationDuration = options.tabGroupAnimationDuration;
|
|
28437
|
+
_this.queryTabIndexParamName = 'tab';
|
|
28436
28438
|
return _this;
|
|
28437
28439
|
}
|
|
28438
28440
|
Object.defineProperty(AppTabEditor.prototype, "selectedTabIndex", {
|
|
@@ -28448,9 +28450,8 @@
|
|
|
28448
28450
|
AppTabEditor.prototype.ngOnInit = function () {
|
|
28449
28451
|
var _this = this;
|
|
28450
28452
|
_super_1.prototype.ngOnInit.call(this);
|
|
28451
|
-
this.queryTabIndexParamName = this.queryTabIndexParamName || 'tab';
|
|
28452
28453
|
// Read the selected tab index, from path query params
|
|
28453
|
-
if (this.tabGroup) {
|
|
28454
|
+
if (this.tabGroup && this.route && this.queryTabIndexParamName) {
|
|
28454
28455
|
this.registerSubscription(this.route.queryParams
|
|
28455
28456
|
.subscribe(function (queryParams) {
|
|
28456
28457
|
_this.queryParams = Object.assign({}, queryParams);
|
|
@@ -28495,8 +28496,8 @@
|
|
|
28495
28496
|
};
|
|
28496
28497
|
AppTabEditor.prototype.onTabChange = function (event, queryTabIndexParamName) {
|
|
28497
28498
|
queryTabIndexParamName = queryTabIndexParamName || this.queryTabIndexParamName;
|
|
28498
|
-
if (!queryTabIndexParamName)
|
|
28499
|
-
return true; // Skip if tab query param not set
|
|
28499
|
+
if (!queryTabIndexParamName || !this.route)
|
|
28500
|
+
return true; // Skip if tab query param not set, or no route
|
|
28500
28501
|
if (!this.queryParams || +this.queryParams[queryTabIndexParamName] !== event.index) {
|
|
28501
28502
|
this.queryParams = this.queryParams || {};
|
|
28502
28503
|
this.queryParams[queryTabIndexParamName] = event.index;
|
|
@@ -28577,7 +28578,7 @@
|
|
|
28577
28578
|
{ type: i0.Directive }
|
|
28578
28579
|
];
|
|
28579
28580
|
AppTabEditor.ctorParameters = function () { return [
|
|
28580
|
-
{ type: i3.ActivatedRoute },
|
|
28581
|
+
{ type: i3.ActivatedRoute, decorators: [{ type: i0.Optional }] },
|
|
28581
28582
|
{ type: i3.Router },
|
|
28582
28583
|
{ type: i1$5.AlertController },
|
|
28583
28584
|
{ type: i1$2.TranslateService },
|
|
@@ -29451,6 +29452,525 @@
|
|
|
29451
29452
|
{ type: AppEditorOptions, decorators: [{ type: i0.Optional }] }
|
|
29452
29453
|
]; };
|
|
29453
29454
|
|
|
29455
|
+
var AppEntityEditorModalOptions = /** @class */ (function (_super_1) {
|
|
29456
|
+
__extends(AppEntityEditorModalOptions, _super_1);
|
|
29457
|
+
function AppEntityEditorModalOptions() {
|
|
29458
|
+
return _super_1 !== null && _super_1.apply(this, arguments) || this;
|
|
29459
|
+
}
|
|
29460
|
+
return AppEntityEditorModalOptions;
|
|
29461
|
+
}(AppTabEditorOptions));
|
|
29462
|
+
// @dynamic
|
|
29463
|
+
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
29464
|
+
var AppEntityEditorModal = /** @class */ (function (_super_1) {
|
|
29465
|
+
__extends(AppEntityEditorModal, _super_1);
|
|
29466
|
+
function AppEntityEditorModal(injector, dataType, options) {
|
|
29467
|
+
var _this = _super_1.call(this, null, injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
|
|
29468
|
+
_this.dataType = dataType;
|
|
29469
|
+
_this.saving = false;
|
|
29470
|
+
_this.$title = new rxjs.Subject();
|
|
29471
|
+
_this.i18nSuffix = null;
|
|
29472
|
+
_this.environement = injector.get(ENVIRONMENT);
|
|
29473
|
+
options = Object.assign({
|
|
29474
|
+
// Default options
|
|
29475
|
+
i18nPrefix: ''
|
|
29476
|
+
}, options);
|
|
29477
|
+
_this.queryTabIndexParamName = undefined; // Important: avoid query parameter changed
|
|
29478
|
+
_this.settings = injector.get(LocalSettingsService);
|
|
29479
|
+
_this.errorTranslator = injector.get(FormErrorTranslator);
|
|
29480
|
+
_this.cd = injector.get(i0.ChangeDetectorRef);
|
|
29481
|
+
_this.dateFormat = injector.get(DateFormatPipe);
|
|
29482
|
+
_this.modalCtrl = injector.get(i1$5.ModalController);
|
|
29483
|
+
_this.i18nContext = {
|
|
29484
|
+
prefix: options.i18nPrefix,
|
|
29485
|
+
suffix: _this.i18nSuffix || ''
|
|
29486
|
+
};
|
|
29487
|
+
return _this;
|
|
29488
|
+
// FOR DEV ONLY ----
|
|
29489
|
+
//this.debug = !environment.production;
|
|
29490
|
+
}
|
|
29491
|
+
Object.defineProperty(AppEntityEditorModal.prototype, "isNewData", {
|
|
29492
|
+
get: function () {
|
|
29493
|
+
var _a;
|
|
29494
|
+
return isNotNil(this._isNewData) ? this._isNewData : isNil((_a = this.data) === null || _a === void 0 ? void 0 : _a.id);
|
|
29495
|
+
},
|
|
29496
|
+
set: function (value) {
|
|
29497
|
+
this._isNewData = value;
|
|
29498
|
+
},
|
|
29499
|
+
enumerable: false,
|
|
29500
|
+
configurable: true
|
|
29501
|
+
});
|
|
29502
|
+
Object.defineProperty(AppEntityEditorModal.prototype, "disabled", {
|
|
29503
|
+
get: function () {
|
|
29504
|
+
return !this._enabled;
|
|
29505
|
+
},
|
|
29506
|
+
set: function (value) {
|
|
29507
|
+
this._enabled = !value;
|
|
29508
|
+
},
|
|
29509
|
+
enumerable: false,
|
|
29510
|
+
configurable: true
|
|
29511
|
+
});
|
|
29512
|
+
Object.defineProperty(AppEntityEditorModal.prototype, "isOnFieldMode", {
|
|
29513
|
+
get: function () {
|
|
29514
|
+
return this.settings.isOnFieldMode(this._usageMode);
|
|
29515
|
+
},
|
|
29516
|
+
enumerable: false,
|
|
29517
|
+
configurable: true
|
|
29518
|
+
});
|
|
29519
|
+
AppEntityEditorModal.prototype.markAsSaving = function (opts) {
|
|
29520
|
+
if (!this.saving) {
|
|
29521
|
+
this.saving = true;
|
|
29522
|
+
if (!opts || opts.emitEvent !== false)
|
|
29523
|
+
this.markForCheck();
|
|
29524
|
+
}
|
|
29525
|
+
};
|
|
29526
|
+
AppEntityEditorModal.prototype.markAsSaved = function (opts) {
|
|
29527
|
+
if (this.saving) {
|
|
29528
|
+
this.saving = false;
|
|
29529
|
+
if (!opts || opts.emitEvent !== false)
|
|
29530
|
+
this.markForCheck();
|
|
29531
|
+
}
|
|
29532
|
+
};
|
|
29533
|
+
AppEntityEditorModal.prototype.ngOnInit = function () {
|
|
29534
|
+
var _super = Object.create(null, {
|
|
29535
|
+
ngOnInit: { get: function () { return _super_1.prototype.ngOnInit; } }
|
|
29536
|
+
});
|
|
29537
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29538
|
+
var _this = this;
|
|
29539
|
+
return __generator(this, function (_b) {
|
|
29540
|
+
// Default values
|
|
29541
|
+
this.mobile = isNotNil(this.mobile) ? this.mobile : this.settings.mobile;
|
|
29542
|
+
_super.ngOnInit.call(this);
|
|
29543
|
+
// Register forms
|
|
29544
|
+
this.registerForms();
|
|
29545
|
+
// Disable
|
|
29546
|
+
if (this.disabled)
|
|
29547
|
+
this.disable();
|
|
29548
|
+
// Update title each time value changes
|
|
29549
|
+
if (!this.isNewData) {
|
|
29550
|
+
this.registerSubscription(this.form.valueChanges
|
|
29551
|
+
.pipe(operators.debounceTime(250))
|
|
29552
|
+
.subscribe(function (json) { return _this.updateTitle(json); }));
|
|
29553
|
+
}
|
|
29554
|
+
return [2 /*return*/];
|
|
29555
|
+
});
|
|
29556
|
+
});
|
|
29557
|
+
};
|
|
29558
|
+
AppEntityEditorModal.prototype.ngAfterViewInit = function () {
|
|
29559
|
+
var _this = this;
|
|
29560
|
+
_super_1.prototype.ngAfterViewInit.call(this);
|
|
29561
|
+
if (this.onAfterModalInit) {
|
|
29562
|
+
Promise.resolve(this.onAfterModalInit(this))
|
|
29563
|
+
.then(function () { return _this.load(); });
|
|
29564
|
+
}
|
|
29565
|
+
else {
|
|
29566
|
+
this.load();
|
|
29567
|
+
}
|
|
29568
|
+
};
|
|
29569
|
+
AppEntityEditorModal.prototype.ngOnDestroy = function () {
|
|
29570
|
+
_super_1.prototype.ngOnDestroy.call(this);
|
|
29571
|
+
this.$title.complete();
|
|
29572
|
+
this.$title.unsubscribe();
|
|
29573
|
+
};
|
|
29574
|
+
AppEntityEditorModal.prototype.waitIdle = function (opts) {
|
|
29575
|
+
var _this = this;
|
|
29576
|
+
// Wait end of saving
|
|
29577
|
+
if (this.saving)
|
|
29578
|
+
return waitFor(function () { return _this.saving !== true; });
|
|
29579
|
+
return _super_1.prototype.waitIdle.call(this, opts);
|
|
29580
|
+
};
|
|
29581
|
+
AppEntityEditorModal.prototype.load = function () {
|
|
29582
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29583
|
+
var err_1;
|
|
29584
|
+
return __generator(this, function (_b) {
|
|
29585
|
+
switch (_b.label) {
|
|
29586
|
+
case 0:
|
|
29587
|
+
this.markAsReady();
|
|
29588
|
+
this.markAsLoading();
|
|
29589
|
+
_b.label = 1;
|
|
29590
|
+
case 1:
|
|
29591
|
+
_b.trys.push([1, 3, 4, 5]);
|
|
29592
|
+
return [4 /*yield*/, this.updateView(this.data)];
|
|
29593
|
+
case 2:
|
|
29594
|
+
_b.sent();
|
|
29595
|
+
return [3 /*break*/, 5];
|
|
29596
|
+
case 3:
|
|
29597
|
+
err_1 = _b.sent();
|
|
29598
|
+
this.setError(err_1);
|
|
29599
|
+
this.selectedTabIndex = 0;
|
|
29600
|
+
return [3 /*break*/, 5];
|
|
29601
|
+
case 4:
|
|
29602
|
+
this.markAsPristine();
|
|
29603
|
+
this.markAsLoaded();
|
|
29604
|
+
return [7 /*endfinally*/];
|
|
29605
|
+
case 5: return [2 /*return*/];
|
|
29606
|
+
}
|
|
29607
|
+
});
|
|
29608
|
+
});
|
|
29609
|
+
};
|
|
29610
|
+
AppEntityEditorModal.prototype.reload = function () {
|
|
29611
|
+
if (this.dirty) {
|
|
29612
|
+
return this.load();
|
|
29613
|
+
}
|
|
29614
|
+
};
|
|
29615
|
+
AppEntityEditorModal.prototype.unload = function (opts) {
|
|
29616
|
+
throw new Error("No implemented on modal");
|
|
29617
|
+
};
|
|
29618
|
+
AppEntityEditorModal.prototype.updateView = function (data, opts) {
|
|
29619
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29620
|
+
return __generator(this, function (_b) {
|
|
29621
|
+
switch (_b.label) {
|
|
29622
|
+
case 0:
|
|
29623
|
+
this.resetError();
|
|
29624
|
+
if (!this.data)
|
|
29625
|
+
throw { code: ErrorCodes.DATA_NOT_FOUND_ERROR, message: 'ERROR.DATA_NO_FOUND' };
|
|
29626
|
+
return [4 /*yield*/, this.setValue(data)];
|
|
29627
|
+
case 1:
|
|
29628
|
+
_b.sent();
|
|
29629
|
+
if (!opts || opts.emitEvent !== false) {
|
|
29630
|
+
this.markAsPristine();
|
|
29631
|
+
this.markAsUntouched();
|
|
29632
|
+
this.updateViewState(data);
|
|
29633
|
+
// Update the title.
|
|
29634
|
+
this.updateTitle(data);
|
|
29635
|
+
}
|
|
29636
|
+
return [2 /*return*/];
|
|
29637
|
+
}
|
|
29638
|
+
});
|
|
29639
|
+
});
|
|
29640
|
+
};
|
|
29641
|
+
/**
|
|
29642
|
+
* Enable or disable state
|
|
29643
|
+
*/
|
|
29644
|
+
AppEntityEditorModal.prototype.updateViewState = function (data, opts) {
|
|
29645
|
+
if (this.isNewData || this.enabled) {
|
|
29646
|
+
this.enable(opts);
|
|
29647
|
+
}
|
|
29648
|
+
else {
|
|
29649
|
+
this.disable(opts);
|
|
29650
|
+
// Allow to sort table
|
|
29651
|
+
this.tables.forEach(function (t) { return t.enableSort(); });
|
|
29652
|
+
}
|
|
29653
|
+
};
|
|
29654
|
+
AppEntityEditorModal.prototype.saveAndClose = function (event) {
|
|
29655
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29656
|
+
var data;
|
|
29657
|
+
return __generator(this, function (_b) {
|
|
29658
|
+
switch (_b.label) {
|
|
29659
|
+
case 0: return [4 /*yield*/, this.saveAndGetDataIfValid()];
|
|
29660
|
+
case 1:
|
|
29661
|
+
data = _b.sent();
|
|
29662
|
+
if (data) {
|
|
29663
|
+
this.modalCtrl.dismiss(data);
|
|
29664
|
+
return [2 /*return*/, true];
|
|
29665
|
+
}
|
|
29666
|
+
return [2 /*return*/, false];
|
|
29667
|
+
}
|
|
29668
|
+
});
|
|
29669
|
+
});
|
|
29670
|
+
};
|
|
29671
|
+
AppEntityEditorModal.prototype.close = function (event) {
|
|
29672
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29673
|
+
var saveBeforeLeave;
|
|
29674
|
+
return __generator(this, function (_b) {
|
|
29675
|
+
switch (_b.label) {
|
|
29676
|
+
case 0:
|
|
29677
|
+
if (!this.dirty) return [3 /*break*/, 3];
|
|
29678
|
+
return [4 /*yield*/, Alerts.askSaveBeforeLeave(this.alertCtrl, this.translate, event)];
|
|
29679
|
+
case 1:
|
|
29680
|
+
saveBeforeLeave = _b.sent();
|
|
29681
|
+
// User cancelled
|
|
29682
|
+
if (isNil(saveBeforeLeave) || event && event.defaultPrevented) {
|
|
29683
|
+
return [2 /*return*/];
|
|
29684
|
+
}
|
|
29685
|
+
if (!(saveBeforeLeave === true)) return [3 /*break*/, 3];
|
|
29686
|
+
return [4 /*yield*/, this.saveAndClose(event)];
|
|
29687
|
+
case 2:
|
|
29688
|
+
_b.sent();
|
|
29689
|
+
return [2 /*return*/];
|
|
29690
|
+
case 3: return [4 /*yield*/, this.modalCtrl.dismiss()];
|
|
29691
|
+
case 4:
|
|
29692
|
+
_b.sent();
|
|
29693
|
+
return [2 /*return*/];
|
|
29694
|
+
}
|
|
29695
|
+
});
|
|
29696
|
+
});
|
|
29697
|
+
};
|
|
29698
|
+
/**
|
|
29699
|
+
* Save the editor, by calling the dataService.save().
|
|
29700
|
+
* Ensure that editor if valid. If not, display an error
|
|
29701
|
+
* @param event
|
|
29702
|
+
* @param opts
|
|
29703
|
+
*/
|
|
29704
|
+
AppEntityEditorModal.prototype.save = function (event, opts) {
|
|
29705
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29706
|
+
var saved, _b, err_2;
|
|
29707
|
+
return __generator(this, function (_c) {
|
|
29708
|
+
switch (_c.label) {
|
|
29709
|
+
case 0:
|
|
29710
|
+
if (this.loading || this.saving || this.disabled) {
|
|
29711
|
+
console.debug(this._logPrefix + 'Skip save: modal is busy (loading or saving)');
|
|
29712
|
+
return [2 /*return*/, false];
|
|
29713
|
+
}
|
|
29714
|
+
if (!this.dirty) {
|
|
29715
|
+
console.debug(this._logPrefix + 'Skip save: modal not dirty');
|
|
29716
|
+
return [2 /*return*/, true];
|
|
29717
|
+
}
|
|
29718
|
+
// Wait end of async validation
|
|
29719
|
+
return [4 /*yield*/, this.waitWhilePending()];
|
|
29720
|
+
case 1:
|
|
29721
|
+
// Wait end of async validation
|
|
29722
|
+
_c.sent();
|
|
29723
|
+
// If invalid
|
|
29724
|
+
if (this.invalid) {
|
|
29725
|
+
this.logFormErrors();
|
|
29726
|
+
this.setError('COMMON.FORM.HAS_ERROR');
|
|
29727
|
+
this.markAllAsTouched();
|
|
29728
|
+
this.openFirstInvalidTab();
|
|
29729
|
+
this.scrollToTop();
|
|
29730
|
+
this.submitted = true;
|
|
29731
|
+
return [2 /*return*/, false];
|
|
29732
|
+
}
|
|
29733
|
+
this.markAsSaving();
|
|
29734
|
+
this.resetError();
|
|
29735
|
+
if (this.debug)
|
|
29736
|
+
console.debug(this._logPrefix + 'Saving data...');
|
|
29737
|
+
_c.label = 2;
|
|
29738
|
+
case 2:
|
|
29739
|
+
_c.trys.push([2, 4, 5, 6]);
|
|
29740
|
+
saved = Promise.all((this.tables || [])
|
|
29741
|
+
.filter(function (c) { return c.dirty; })
|
|
29742
|
+
.map(function (c) { return c.save(); }))
|
|
29743
|
+
.then(function (res) { return res.findIndex(function (r) { return r !== true; }) === -1; });
|
|
29744
|
+
_b = this;
|
|
29745
|
+
return [4 /*yield*/, this.getValue()];
|
|
29746
|
+
case 3:
|
|
29747
|
+
_b.data = _c.sent();
|
|
29748
|
+
this.submitted = true;
|
|
29749
|
+
return [2 /*return*/, saved];
|
|
29750
|
+
case 4:
|
|
29751
|
+
err_2 = _c.sent();
|
|
29752
|
+
this.submitted = true;
|
|
29753
|
+
this.setError(err_2);
|
|
29754
|
+
this.selectedTabIndex = 0;
|
|
29755
|
+
this.scrollToTop(); // Scroll to top (to show error)
|
|
29756
|
+
this.markAsDirty();
|
|
29757
|
+
this.enable();
|
|
29758
|
+
return [2 /*return*/, false];
|
|
29759
|
+
case 5:
|
|
29760
|
+
this.markAsSaved();
|
|
29761
|
+
return [7 /*endfinally*/];
|
|
29762
|
+
case 6: return [2 /*return*/];
|
|
29763
|
+
}
|
|
29764
|
+
});
|
|
29765
|
+
});
|
|
29766
|
+
};
|
|
29767
|
+
/**
|
|
29768
|
+
* Save data (if dirty and valid), and return it. Otherwise, return nil value.
|
|
29769
|
+
*/
|
|
29770
|
+
AppEntityEditorModal.prototype.saveAndGetDataIfValid = function () {
|
|
29771
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29772
|
+
var saved;
|
|
29773
|
+
return __generator(this, function (_b) {
|
|
29774
|
+
switch (_b.label) {
|
|
29775
|
+
case 0:
|
|
29776
|
+
if (!!this.valid) return [3 /*break*/, 2];
|
|
29777
|
+
// Make sure validation is finished
|
|
29778
|
+
return [4 /*yield*/, AppFormUtils.waitWhilePending(this)];
|
|
29779
|
+
case 1:
|
|
29780
|
+
// Make sure validation is finished
|
|
29781
|
+
_b.sent();
|
|
29782
|
+
// If invalid: Open the first tab in error
|
|
29783
|
+
if (this.invalid) {
|
|
29784
|
+
this.openFirstInvalidTab();
|
|
29785
|
+
return [2 /*return*/, undefined];
|
|
29786
|
+
}
|
|
29787
|
+
_b.label = 2;
|
|
29788
|
+
case 2:
|
|
29789
|
+
if (!this.dirty) return [3 /*break*/, 4];
|
|
29790
|
+
return [4 /*yield*/, this.save(new Event('save'))];
|
|
29791
|
+
case 3:
|
|
29792
|
+
saved = _b.sent();
|
|
29793
|
+
if (!saved)
|
|
29794
|
+
return [2 /*return*/, undefined];
|
|
29795
|
+
_b.label = 4;
|
|
29796
|
+
case 4:
|
|
29797
|
+
// Valid and saved data
|
|
29798
|
+
return [2 /*return*/, this.data];
|
|
29799
|
+
}
|
|
29800
|
+
});
|
|
29801
|
+
});
|
|
29802
|
+
};
|
|
29803
|
+
AppEntityEditorModal.prototype.delete = function (event) {
|
|
29804
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29805
|
+
var result, err_3;
|
|
29806
|
+
return __generator(this, function (_b) {
|
|
29807
|
+
switch (_b.label) {
|
|
29808
|
+
case 0:
|
|
29809
|
+
if (this.loading || this.saving)
|
|
29810
|
+
return [2 /*return*/, false];
|
|
29811
|
+
this.markAsSaving();
|
|
29812
|
+
this.resetError();
|
|
29813
|
+
_b.label = 1;
|
|
29814
|
+
case 1:
|
|
29815
|
+
_b.trys.push([1, 8, , 9]);
|
|
29816
|
+
if (!this.onDelete) return [3 /*break*/, 5];
|
|
29817
|
+
return [4 /*yield*/, this.onDelete(event, this.data)];
|
|
29818
|
+
case 2:
|
|
29819
|
+
result = _b.sent();
|
|
29820
|
+
// User cancelled
|
|
29821
|
+
if (isNil(result) || (event && event.defaultPrevented))
|
|
29822
|
+
return [2 /*return*/];
|
|
29823
|
+
if (!result) return [3 /*break*/, 4];
|
|
29824
|
+
return [4 /*yield*/, this.modalCtrl.dismiss(this.data, 'delete')];
|
|
29825
|
+
case 3:
|
|
29826
|
+
_b.sent();
|
|
29827
|
+
_b.label = 4;
|
|
29828
|
+
case 4: return [3 /*break*/, 7];
|
|
29829
|
+
case 5:
|
|
29830
|
+
if (this.isNewData) {
|
|
29831
|
+
console.error(this._logPrefix + "Trying to delete a new data. Make no sense!");
|
|
29832
|
+
}
|
|
29833
|
+
return [4 /*yield*/, this.modalCtrl.dismiss(this.data, 'delete')];
|
|
29834
|
+
case 6:
|
|
29835
|
+
_b.sent();
|
|
29836
|
+
_b.label = 7;
|
|
29837
|
+
case 7: return [3 /*break*/, 9];
|
|
29838
|
+
case 8:
|
|
29839
|
+
err_3 = _b.sent();
|
|
29840
|
+
this.submitted = true;
|
|
29841
|
+
this.setError(err_3);
|
|
29842
|
+
this.selectedTabIndex = 0;
|
|
29843
|
+
this.markAsSaved();
|
|
29844
|
+
if (this.enabled)
|
|
29845
|
+
this.enable();
|
|
29846
|
+
return [2 /*return*/, false];
|
|
29847
|
+
case 9: return [2 /*return*/];
|
|
29848
|
+
}
|
|
29849
|
+
});
|
|
29850
|
+
});
|
|
29851
|
+
};
|
|
29852
|
+
AppEntityEditorModal.prototype.resetError = function (opts) {
|
|
29853
|
+
if (isNotNilOrBlank(this.error)) {
|
|
29854
|
+
this.error = null;
|
|
29855
|
+
if (!opts || opts.emitEvent !== false)
|
|
29856
|
+
this.markForCheck();
|
|
29857
|
+
}
|
|
29858
|
+
};
|
|
29859
|
+
AppEntityEditorModal.prototype.setError = function (err, opts) {
|
|
29860
|
+
if (!err) {
|
|
29861
|
+
this.error = undefined;
|
|
29862
|
+
}
|
|
29863
|
+
else if (typeof err === 'string') {
|
|
29864
|
+
console.error('[entity-editor] Error: ' + (err || ''));
|
|
29865
|
+
this.error = err;
|
|
29866
|
+
}
|
|
29867
|
+
else {
|
|
29868
|
+
console.error('[entity-editor] Error: ' + err.message || '', err);
|
|
29869
|
+
var userMessage = err.message && this.translate.instant(err.message) || err;
|
|
29870
|
+
// Add details error (if any) under the main message
|
|
29871
|
+
var detailMessage = (!err.details || typeof err.details === 'string')
|
|
29872
|
+
? err.details
|
|
29873
|
+
: err.details.message;
|
|
29874
|
+
if (isNotNilOrBlank(detailMessage)) {
|
|
29875
|
+
var cssClass = (opts === null || opts === void 0 ? void 0 : opts.detailsCssClass) || 'hidden-xs hidden-sm';
|
|
29876
|
+
userMessage += "<br/><small class=\"" + cssClass + "\" title=\"" + detailMessage + "\">";
|
|
29877
|
+
userMessage += detailMessage.length < 70 ? detailMessage : detailMessage.substring(0, 67) + '...';
|
|
29878
|
+
userMessage += '</small>';
|
|
29879
|
+
}
|
|
29880
|
+
this.error = userMessage;
|
|
29881
|
+
}
|
|
29882
|
+
if (!opts || opts.emitEvent !== false)
|
|
29883
|
+
this.markForCheck();
|
|
29884
|
+
};
|
|
29885
|
+
/* -- protected methods -- */
|
|
29886
|
+
AppEntityEditorModal.prototype.waitWhilePending = function (opts) {
|
|
29887
|
+
return AppFormUtils.waitWhilePending(this, opts);
|
|
29888
|
+
};
|
|
29889
|
+
AppEntityEditorModal.prototype.getValue = function () {
|
|
29890
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29891
|
+
var json, res;
|
|
29892
|
+
return __generator(this, function (_b) {
|
|
29893
|
+
switch (_b.label) {
|
|
29894
|
+
case 0: return [4 /*yield*/, this.getJsonValueToSave()];
|
|
29895
|
+
case 1:
|
|
29896
|
+
json = _b.sent();
|
|
29897
|
+
res = new this.dataType();
|
|
29898
|
+
res.fromObject(json);
|
|
29899
|
+
return [2 /*return*/, res];
|
|
29900
|
+
}
|
|
29901
|
+
});
|
|
29902
|
+
});
|
|
29903
|
+
};
|
|
29904
|
+
AppEntityEditorModal.prototype.getJsonValueToSave = function () {
|
|
29905
|
+
return Promise.resolve(this.form.value);
|
|
29906
|
+
};
|
|
29907
|
+
/**
|
|
29908
|
+
* Compute the title
|
|
29909
|
+
*
|
|
29910
|
+
* @param data
|
|
29911
|
+
*/
|
|
29912
|
+
AppEntityEditorModal.prototype.updateTitle = function (data) {
|
|
29913
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29914
|
+
var title;
|
|
29915
|
+
return __generator(this, function (_b) {
|
|
29916
|
+
switch (_b.label) {
|
|
29917
|
+
case 0:
|
|
29918
|
+
data = data || this.data;
|
|
29919
|
+
return [4 /*yield*/, this.computeTitle(data)];
|
|
29920
|
+
case 1:
|
|
29921
|
+
title = _b.sent();
|
|
29922
|
+
this.$title.next(title);
|
|
29923
|
+
return [2 /*return*/];
|
|
29924
|
+
}
|
|
29925
|
+
});
|
|
29926
|
+
});
|
|
29927
|
+
};
|
|
29928
|
+
AppEntityEditorModal.prototype.scrollToTop = function (duration) {
|
|
29929
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
29930
|
+
return __generator(this, function (_b) {
|
|
29931
|
+
if (this.content) {
|
|
29932
|
+
return [2 /*return*/, this.content.scrollToTop(duration)];
|
|
29933
|
+
}
|
|
29934
|
+
return [2 /*return*/];
|
|
29935
|
+
});
|
|
29936
|
+
});
|
|
29937
|
+
};
|
|
29938
|
+
AppEntityEditorModal.prototype.markForCheck = function () {
|
|
29939
|
+
var _a;
|
|
29940
|
+
(_a = this.cd) === null || _a === void 0 ? void 0 : _a.markForCheck();
|
|
29941
|
+
};
|
|
29942
|
+
/* -- private functions -- */
|
|
29943
|
+
/**
|
|
29944
|
+
* Open the first tab that is invalid
|
|
29945
|
+
*/
|
|
29946
|
+
AppEntityEditorModal.prototype.openFirstInvalidTab = function () {
|
|
29947
|
+
var invalidTabIndex = this.getFirstInvalidTabIndex();
|
|
29948
|
+
if (invalidTabIndex !== -1 && this.selectedTabIndex !== invalidTabIndex) {
|
|
29949
|
+
this.selectedTabIndex = invalidTabIndex;
|
|
29950
|
+
this.markForCheck();
|
|
29951
|
+
}
|
|
29952
|
+
};
|
|
29953
|
+
return AppEntityEditorModal;
|
|
29954
|
+
}(AppTabEditor));
|
|
29955
|
+
AppEntityEditorModal.decorators = [
|
|
29956
|
+
{ type: i0.Directive }
|
|
29957
|
+
];
|
|
29958
|
+
AppEntityEditorModal.ctorParameters = function () { return [
|
|
29959
|
+
{ type: i0.Injector },
|
|
29960
|
+
{ type: Function },
|
|
29961
|
+
{ type: undefined, decorators: [{ type: i0.Optional }] }
|
|
29962
|
+
]; };
|
|
29963
|
+
AppEntityEditorModal.propDecorators = {
|
|
29964
|
+
data: [{ type: i0.Input }],
|
|
29965
|
+
mobile: [{ type: i0.Input }],
|
|
29966
|
+
usageMode: [{ type: i0.Input }],
|
|
29967
|
+
onAfterModalInit: [{ type: i0.Input }],
|
|
29968
|
+
onDelete: [{ type: i0.Input }],
|
|
29969
|
+
i18nSuffix: [{ type: i0.Input }],
|
|
29970
|
+
isNewData: [{ type: i0.Input }],
|
|
29971
|
+
disabled: [{ type: i0.Input }]
|
|
29972
|
+
};
|
|
29973
|
+
|
|
29454
29974
|
// @dynamic
|
|
29455
29975
|
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
29456
29976
|
var AppInMemoryTable = /** @class */ (function (_super) {
|
|
@@ -32521,6 +33041,8 @@
|
|
|
32521
33041
|
exports.AppEditor = AppEditor;
|
|
32522
33042
|
exports.AppEditorOptions = AppEditorOptions;
|
|
32523
33043
|
exports.AppEntityEditor = AppEntityEditor;
|
|
33044
|
+
exports.AppEntityEditorModal = AppEntityEditorModal;
|
|
33045
|
+
exports.AppEntityEditorModalOptions = AppEntityEditorModalOptions;
|
|
32524
33046
|
exports.AppForm = AppForm;
|
|
32525
33047
|
exports.AppFormField = AppFormField;
|
|
32526
33048
|
exports.AppFormProvider = AppFormProvider;
|