@sumaris-net/ngx-components 1.20.16 → 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 +634 -9
- package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
- package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
- package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
- package/doc/changelog.md +12 -0
- package/esm2015/public_api.js +5 -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/esm2015/src/app/core/services/platform.service.js +5 -5
- package/esm2015/src/app/shared/directives/resizable/resizable.component.js +54 -0
- package/esm2015/src/app/shared/directives/resizable/resizable.directive.js +34 -0
- package/esm2015/src/app/shared/directives/resizable/resizable.module.js +12 -0
- package/esm2015/src/app/shared/material/chips/testing/chips.test.js +1 -1
- package/fesm2015/sumaris-net.ngx-components.js +505 -13
- package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
- package/package.json +1 -1
- package/public_api.d.ts +4 -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/src/app/shared/directives/resizable/resizable.component.d.ts +18 -0
- package/src/app/shared/directives/resizable/resizable.directive.d.ts +9 -0
- package/src/app/shared/directives/resizable/resizable.module.d.ts +2 -0
- package/src/app/shared/material/chips/testing/chips.test.d.ts +2 -1
- package/sumaris-net.ngx-components.metadata.json +1 -1
|
@@ -18682,11 +18682,11 @@
|
|
|
18682
18682
|
throw err;
|
|
18683
18683
|
}));
|
|
18684
18684
|
}
|
|
18685
|
-
// Fallback (if not Android and Cordova): opening the URI
|
|
18685
|
+
// Fallback (if not Android and Cordova): opening the URI
|
|
18686
18686
|
// TODO: find a way to download under iOS (see https://www.c-sharpcorner.com/article/how-to-download-a-file-using-file-transfer-plugin-in-ionic-3/)
|
|
18687
18687
|
else {
|
|
18688
|
-
|
|
18689
|
-
this.open(request.uri, '_system', 'location=no', true);
|
|
18688
|
+
FilesUtils.downloadUri(request.uri, request.filename);
|
|
18689
|
+
//this.open(request.uri, '_system', 'location=no', true);
|
|
18690
18690
|
return rxjs.of();
|
|
18691
18691
|
}
|
|
18692
18692
|
};
|
|
@@ -20470,6 +20470,106 @@
|
|
|
20470
20470
|
autofocus: [{ type: i0.Input }]
|
|
20471
20471
|
};
|
|
20472
20472
|
|
|
20473
|
+
var ResizableDirective = /** @class */ (function () {
|
|
20474
|
+
function ResizableDirective(document, elementRef) {
|
|
20475
|
+
var _this = this;
|
|
20476
|
+
this.document = document;
|
|
20477
|
+
this.elementRef = elementRef;
|
|
20478
|
+
// resize: mousedown -> mousemove -> mouseup
|
|
20479
|
+
this.resizable = rxjs.fromEvent(this.elementRef.nativeElement, 'mousedown').pipe(operators.tap(function (e) {
|
|
20480
|
+
e.preventDefault();
|
|
20481
|
+
e.stopPropagation();
|
|
20482
|
+
}), operators.switchMap(function () {
|
|
20483
|
+
var _a = _this.elementRef.nativeElement.closest('th').getBoundingClientRect(), width = _a.width, right = _a.right;
|
|
20484
|
+
return rxjs.fromEvent(_this.document, 'mousemove').pipe(operators.map(function (_a) {
|
|
20485
|
+
var clientX = _a.clientX;
|
|
20486
|
+
return width + clientX - right;
|
|
20487
|
+
}), operators.distinctUntilChanged(), operators.takeUntil(rxjs.fromEvent(_this.document, 'mouseup')));
|
|
20488
|
+
}));
|
|
20489
|
+
// fit: doubleclick
|
|
20490
|
+
this.fit = rxjs.fromEvent(this.elementRef.nativeElement, 'click').pipe(operators.bufferWhen(function () { return rxjs.interval(500); }), operators.filter(function (ar) { return ar.length === 2; }));
|
|
20491
|
+
}
|
|
20492
|
+
return ResizableDirective;
|
|
20493
|
+
}());
|
|
20494
|
+
ResizableDirective.decorators = [
|
|
20495
|
+
{ type: i0.Directive, args: [{
|
|
20496
|
+
selector: '[resizable]',
|
|
20497
|
+
},] }
|
|
20498
|
+
];
|
|
20499
|
+
ResizableDirective.ctorParameters = function () { return [
|
|
20500
|
+
{ type: undefined, decorators: [{ type: i0.Inject, args: [i1$4.DOCUMENT,] }] },
|
|
20501
|
+
{ type: i0.ElementRef, decorators: [{ type: i0.Inject, args: [i0.ElementRef,] }] }
|
|
20502
|
+
]; };
|
|
20503
|
+
ResizableDirective.propDecorators = {
|
|
20504
|
+
resizable: [{ type: i0.Output }],
|
|
20505
|
+
fit: [{ type: i0.Output }]
|
|
20506
|
+
};
|
|
20507
|
+
|
|
20508
|
+
var ResizableComponent = /** @class */ (function () {
|
|
20509
|
+
function ResizableComponent(columnDef) {
|
|
20510
|
+
this.columnDef = columnDef;
|
|
20511
|
+
this.sizeChanged = new i0.EventEmitter();
|
|
20512
|
+
this.width = null;
|
|
20513
|
+
this.minWidth = null;
|
|
20514
|
+
this.maxWidth = null;
|
|
20515
|
+
this.debug = false;
|
|
20516
|
+
}
|
|
20517
|
+
ResizableComponent.prototype.onResize = function (width, opts) {
|
|
20518
|
+
if (!this.resizable)
|
|
20519
|
+
return;
|
|
20520
|
+
if (this.debug)
|
|
20521
|
+
console.info("resize:" + width);
|
|
20522
|
+
this.minWidth = width + 'px';
|
|
20523
|
+
this.maxWidth = width + 'px';
|
|
20524
|
+
if (!opts || opts.emitEvent) {
|
|
20525
|
+
this.sizeChanged.emit(width);
|
|
20526
|
+
}
|
|
20527
|
+
};
|
|
20528
|
+
ResizableComponent.prototype.onFit = function (opts) {
|
|
20529
|
+
if (!this.resizable)
|
|
20530
|
+
return;
|
|
20531
|
+
if (this.debug)
|
|
20532
|
+
console.info('fit');
|
|
20533
|
+
this.width = 'auto';
|
|
20534
|
+
this.minWidth = null;
|
|
20535
|
+
this.maxWidth = null;
|
|
20536
|
+
if (!opts || opts.emitEvent) {
|
|
20537
|
+
this.sizeChanged.emit(undefined);
|
|
20538
|
+
}
|
|
20539
|
+
};
|
|
20540
|
+
return ResizableComponent;
|
|
20541
|
+
}());
|
|
20542
|
+
ResizableComponent.decorators = [
|
|
20543
|
+
{ type: i0.Component, args: [{
|
|
20544
|
+
// eslint-disable-next-line @angular-eslint/component-selector
|
|
20545
|
+
selector: 'th[resizable]',
|
|
20546
|
+
template: "<div class=\"wrapper\">\n <div class=\"content\">\n <ng-content></ng-content>\n </div>\n <div class=\"bar\" [class.cdk-visually-hidden]=\"!resizable\" (resizable)=\"onResize($event)\" (fit)=\"onFit()\"></div>\n</div>\n",
|
|
20547
|
+
styles: [":host:last-child .bar{display:none}.wrapper{display:flex;justify-content:flex-end;align-items:center}.content{flex:1}.bar{height:var(--app-table-header-height,55px);width:10px;justify-self:flex-end;border-left:4px solid transparent;border-right:4px solid transparent;background:var(--ion-color-secondary);background-clip:content-box;cursor:ew-resize;opacity:0;transition:opacity .3s}.bar:active,.bar:hover{opacity:1}:host-context(.mat-table-sticky) .bar{width:12px!important}"]
|
|
20548
|
+
},] }
|
|
20549
|
+
];
|
|
20550
|
+
ResizableComponent.ctorParameters = function () { return [
|
|
20551
|
+
{ type: table.MatColumnDef, decorators: [{ type: i0.Optional }] }
|
|
20552
|
+
]; };
|
|
20553
|
+
ResizableComponent.propDecorators = {
|
|
20554
|
+
resizable: [{ type: i0.Input }],
|
|
20555
|
+
sizeChanged: [{ type: i0.Output }],
|
|
20556
|
+
width: [{ type: i0.HostBinding, args: ['style.width',] }],
|
|
20557
|
+
minWidth: [{ type: i0.HostBinding, args: ['style.min-width',] }],
|
|
20558
|
+
maxWidth: [{ type: i0.HostBinding, args: ['style.max-width',] }]
|
|
20559
|
+
};
|
|
20560
|
+
|
|
20561
|
+
var ResizableModule = /** @class */ (function () {
|
|
20562
|
+
function ResizableModule() {
|
|
20563
|
+
}
|
|
20564
|
+
return ResizableModule;
|
|
20565
|
+
}());
|
|
20566
|
+
ResizableModule.decorators = [
|
|
20567
|
+
{ type: i0.NgModule, args: [{
|
|
20568
|
+
declarations: [ResizableComponent, ResizableDirective],
|
|
20569
|
+
exports: [ResizableComponent, ResizableDirective],
|
|
20570
|
+
},] }
|
|
20571
|
+
];
|
|
20572
|
+
|
|
20473
20573
|
function mergeLoadResult(res1, res2) {
|
|
20474
20574
|
var _c;
|
|
20475
20575
|
var _a, _b;
|
|
@@ -28321,7 +28421,8 @@
|
|
|
28321
28421
|
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
28322
28422
|
var AppTabEditor = /** @class */ (function (_super_1) {
|
|
28323
28423
|
__extends(AppTabEditor, _super_1);
|
|
28324
|
-
function AppTabEditor(route,
|
|
28424
|
+
function AppTabEditor(route, // Modal editor give 'null'
|
|
28425
|
+
router, alertCtrl, translate, options) {
|
|
28325
28426
|
var _this = _super_1.call(this, route, router, alertCtrl, translate) || this;
|
|
28326
28427
|
_this.route = route;
|
|
28327
28428
|
_this.router = router;
|
|
@@ -28333,6 +28434,7 @@
|
|
|
28333
28434
|
_this.tabCount = options.tabCount;
|
|
28334
28435
|
_this.enableSwipe = options.enableSwipe;
|
|
28335
28436
|
_this.tabGroupAnimationDuration = options.tabGroupAnimationDuration;
|
|
28437
|
+
_this.queryTabIndexParamName = 'tab';
|
|
28336
28438
|
return _this;
|
|
28337
28439
|
}
|
|
28338
28440
|
Object.defineProperty(AppTabEditor.prototype, "selectedTabIndex", {
|
|
@@ -28348,9 +28450,8 @@
|
|
|
28348
28450
|
AppTabEditor.prototype.ngOnInit = function () {
|
|
28349
28451
|
var _this = this;
|
|
28350
28452
|
_super_1.prototype.ngOnInit.call(this);
|
|
28351
|
-
this.queryTabIndexParamName = this.queryTabIndexParamName || 'tab';
|
|
28352
28453
|
// Read the selected tab index, from path query params
|
|
28353
|
-
if (this.tabGroup) {
|
|
28454
|
+
if (this.tabGroup && this.route && this.queryTabIndexParamName) {
|
|
28354
28455
|
this.registerSubscription(this.route.queryParams
|
|
28355
28456
|
.subscribe(function (queryParams) {
|
|
28356
28457
|
_this.queryParams = Object.assign({}, queryParams);
|
|
@@ -28395,8 +28496,8 @@
|
|
|
28395
28496
|
};
|
|
28396
28497
|
AppTabEditor.prototype.onTabChange = function (event, queryTabIndexParamName) {
|
|
28397
28498
|
queryTabIndexParamName = queryTabIndexParamName || this.queryTabIndexParamName;
|
|
28398
|
-
if (!queryTabIndexParamName)
|
|
28399
|
-
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
|
|
28400
28501
|
if (!this.queryParams || +this.queryParams[queryTabIndexParamName] !== event.index) {
|
|
28401
28502
|
this.queryParams = this.queryParams || {};
|
|
28402
28503
|
this.queryParams[queryTabIndexParamName] = event.index;
|
|
@@ -28477,7 +28578,7 @@
|
|
|
28477
28578
|
{ type: i0.Directive }
|
|
28478
28579
|
];
|
|
28479
28580
|
AppTabEditor.ctorParameters = function () { return [
|
|
28480
|
-
{ type: i3.ActivatedRoute },
|
|
28581
|
+
{ type: i3.ActivatedRoute, decorators: [{ type: i0.Optional }] },
|
|
28481
28582
|
{ type: i3.Router },
|
|
28482
28583
|
{ type: i1$5.AlertController },
|
|
28483
28584
|
{ type: i1$2.TranslateService },
|
|
@@ -29351,6 +29452,525 @@
|
|
|
29351
29452
|
{ type: AppEditorOptions, decorators: [{ type: i0.Optional }] }
|
|
29352
29453
|
]; };
|
|
29353
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
|
+
|
|
29354
29974
|
// @dynamic
|
|
29355
29975
|
// eslint-disable-next-line @angular-eslint/directive-class-suffix
|
|
29356
29976
|
var AppInMemoryTable = /** @class */ (function (_super) {
|
|
@@ -32421,6 +33041,8 @@
|
|
|
32421
33041
|
exports.AppEditor = AppEditor;
|
|
32422
33042
|
exports.AppEditorOptions = AppEditorOptions;
|
|
32423
33043
|
exports.AppEntityEditor = AppEntityEditor;
|
|
33044
|
+
exports.AppEntityEditorModal = AppEntityEditorModal;
|
|
33045
|
+
exports.AppEntityEditorModalOptions = AppEntityEditorModalOptions;
|
|
32424
33046
|
exports.AppForm = AppForm;
|
|
32425
33047
|
exports.AppFormField = AppFormField;
|
|
32426
33048
|
exports.AppFormProvider = AppFormProvider;
|
|
@@ -32600,6 +33222,9 @@
|
|
|
32600
33222
|
exports.ReferentialUtils = ReferentialUtils;
|
|
32601
33223
|
exports.ReferentialValidatorService = ReferentialValidatorService;
|
|
32602
33224
|
exports.RegisterConfirmPage = RegisterConfirmPage;
|
|
33225
|
+
exports.ResizableComponent = ResizableComponent;
|
|
33226
|
+
exports.ResizableDirective = ResizableDirective;
|
|
33227
|
+
exports.ResizableModule = ResizableModule;
|
|
32603
33228
|
exports.SETTINGS_DISPLAY_COLUMNS = SETTINGS_DISPLAY_COLUMNS;
|
|
32604
33229
|
exports.SETTINGS_FILTER = SETTINGS_FILTER;
|
|
32605
33230
|
exports.SETTINGS_PAGE_SIZE = SETTINGS_PAGE_SIZE;
|