@sumaris-net/ngx-components 0.27.1 → 0.27.5

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.
@@ -2280,11 +2280,11 @@
2280
2280
  var NumberFormatPipe = /** @class */ (function () {
2281
2281
  function NumberFormatPipe() {
2282
2282
  }
2283
- NumberFormatPipe.prototype.transform = function (val) {
2283
+ NumberFormatPipe.prototype.transform = function (val, numberFormatOptions) {
2284
2284
  // Format the output to display any way you want here.
2285
2285
  // For instance:
2286
2286
  if (val !== undefined && val !== null) {
2287
- return val.toLocaleString( /*arguments you need*/);
2287
+ return val.toLocaleString(undefined, numberFormatOptions);
2288
2288
  }
2289
2289
  else {
2290
2290
  return '';
@@ -3376,6 +3376,13 @@
3376
3376
  AppNullForm.prototype.markAsDirty = function (opts) { };
3377
3377
  AppNullForm.prototype.markAsLoading = function (opts) { };
3378
3378
  AppNullForm.prototype.markAsLoaded = function (opts) { };
3379
+ AppNullForm.prototype.markAsReady = function (opts) { };
3380
+ AppNullForm.prototype.waitIdle = function (opts) {
3381
+ return Promise.reject(false);
3382
+ };
3383
+ AppNullForm.prototype.ready = function () {
3384
+ return Promise.reject(true);
3385
+ };
3379
3386
  return AppNullForm;
3380
3387
  }());
3381
3388
  var AppFormProvider = /** @class */ (function () {
@@ -3461,6 +3468,9 @@
3461
3468
  enumerable: false,
3462
3469
  configurable: true
3463
3470
  });
3471
+ AppFormProvider.prototype.ready = function () {
3472
+ return this.delegate.ready();
3473
+ };
3464
3474
  AppFormProvider.prototype.disable = function (opts) {
3465
3475
  return this.delegate.disable(opts);
3466
3476
  };
@@ -3488,6 +3498,9 @@
3488
3498
  AppFormProvider.prototype.markAsLoaded = function (opts) {
3489
3499
  return this.delegate.markAsLoaded(opts);
3490
3500
  };
3501
+ AppFormProvider.prototype.markAsReady = function (opts) {
3502
+ return this.delegate.markAsReady(opts);
3503
+ };
3491
3504
  return AppFormProvider;
3492
3505
  }());
3493
3506
  AppFormProvider.NULL_FORM = new AppNullForm();
@@ -19022,6 +19035,7 @@
19022
19035
  this._loading = true;
19023
19036
  this.i18nFieldPrefix = null;
19024
19037
  this._subscription = new rxjs.Subscription();
19038
+ this._$ready = new rxjs.BehaviorSubject(true);
19025
19039
  this.debug = false;
19026
19040
  this.onCancel = new i0.EventEmitter();
19027
19041
  this.onSubmit = new i0.EventEmitter();
@@ -19140,6 +19154,7 @@
19140
19154
  this.onCancel.unsubscribe();
19141
19155
  this.onSubmit.complete();
19142
19156
  this.onSubmit.unsubscribe();
19157
+ this._$ready.complete();
19143
19158
  };
19144
19159
  AppForm.prototype.cancel = function () {
19145
19160
  this.onCancel.emit();
@@ -19230,6 +19245,22 @@
19230
19245
  this.markForCheck();
19231
19246
  }
19232
19247
  };
19248
+ AppForm.prototype.markAsReady = function (opts) {
19249
+ if (!this._$ready.value) {
19250
+ this._$ready.next(true);
19251
+ // If subclasses implements OnReady
19252
+ if (typeof this['nngOnReady'] === 'function') {
19253
+ this.ngOnReady();
19254
+ }
19255
+ }
19256
+ };
19257
+ /**
19258
+ * Wait form is ready
19259
+ * @param opts
19260
+ */
19261
+ AppForm.prototype.ready = function (opts) {
19262
+ return firstTruePromise(this._$ready);
19263
+ };
19233
19264
  /**
19234
19265
  * Wait form is idle (not loading)
19235
19266
  * @param opts
@@ -23494,6 +23525,7 @@
23494
23525
  this.allowRowDetail = true;
23495
23526
  this.excludesColumns = [];
23496
23527
  this.totalRowCount = null;
23528
+ this.readySubject = new rxjs.BehaviorSubject(false);
23497
23529
  this.loadingSubject = new rxjs.BehaviorSubject(true);
23498
23530
  this.savingSubject = new rxjs.BehaviorSubject(false);
23499
23531
  this.dirtySubject = new rxjs.BehaviorSubject(false);
@@ -23757,6 +23789,14 @@
23757
23789
  (_a = row.validator) === null || _a === void 0 ? void 0 : _a.markAsDirty(opts);
23758
23790
  this.markAsDirty(opts);
23759
23791
  };
23792
+ AppTable.prototype.markAsReady = function (opts) {
23793
+ if (this.readySubject.value !== false) {
23794
+ this.readySubject.next(false);
23795
+ if (!opts || opts.emitEvent !== false) {
23796
+ this.markForCheck();
23797
+ }
23798
+ }
23799
+ };
23760
23800
  Object.defineProperty(AppTable.prototype, "loading", {
23761
23801
  get: function () {
23762
23802
  return this.loadingSubject.value;
@@ -24471,6 +24511,9 @@
24471
24511
  AppTable.prototype.moveRow = function (id, direction) {
24472
24512
  this.dataSource.move(id, direction);
24473
24513
  };
24514
+ AppTable.prototype.ready = function () {
24515
+ return firstTruePromise(this.readySubject);
24516
+ };
24474
24517
  AppTable.prototype.waitIdle = function () {
24475
24518
  return firstFalsePromise(this.loadingSubject);
24476
24519
  };
@@ -25266,8 +25309,8 @@
25266
25309
  return AppTabEditorOptions;
25267
25310
  }());
25268
25311
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
25269
- var AppTabEditor = /** @class */ (function () {
25270
- function AppTabEditor(route, router, alertCtrl, translate, options) {
25312
+ var AppEditor = /** @class */ (function () {
25313
+ function AppEditor(route, router, alertCtrl, translate) {
25271
25314
  this.route = route;
25272
25315
  this.router = router;
25273
25316
  this.alertCtrl = alertCtrl;
@@ -25276,25 +25319,20 @@
25276
25319
  this._enabled = false;
25277
25320
  this._dirty = false;
25278
25321
  this._loading = true;
25279
- this._selectedTabIndex = 0;
25322
+ this._$ready = new rxjs.BehaviorSubject(false);
25280
25323
  this.debug = false;
25281
25324
  this.submitted = false;
25282
25325
  this.toolbar = null;
25283
25326
  this.formButtonsBar = null;
25284
- this.selectedTabIndexChange = new i0.EventEmitter();
25285
- options = Object.assign({ tabCount: 1, enableSwipe: true, tabGroupAnimationDuration: '200ms' }, options);
25286
- this.tabCount = options.tabCount;
25287
- this.enableSwipe = options.enableSwipe;
25288
- this.tabGroupAnimationDuration = options.tabGroupAnimationDuration;
25289
25327
  }
25290
- Object.defineProperty(AppTabEditor.prototype, "tables", {
25328
+ Object.defineProperty(AppEditor.prototype, "tables", {
25291
25329
  get: function () {
25292
25330
  return this._children && this._children.filter(function (c) { return c instanceof AppTable; });
25293
25331
  },
25294
25332
  enumerable: false,
25295
25333
  configurable: true
25296
25334
  });
25297
- Object.defineProperty(AppTabEditor.prototype, "dirty", {
25335
+ Object.defineProperty(AppEditor.prototype, "dirty", {
25298
25336
  get: function () {
25299
25337
  var _a;
25300
25338
  return this._dirty || (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.dirty; })) !== -1) || false;
@@ -25302,7 +25340,7 @@
25302
25340
  enumerable: false,
25303
25341
  configurable: true
25304
25342
  });
25305
- Object.defineProperty(AppTabEditor.prototype, "valid", {
25343
+ Object.defineProperty(AppEditor.prototype, "valid", {
25306
25344
  /**
25307
25345
  * Is valid (tables and forms)
25308
25346
  */
@@ -25313,7 +25351,7 @@
25313
25351
  enumerable: false,
25314
25352
  configurable: true
25315
25353
  });
25316
- Object.defineProperty(AppTabEditor.prototype, "invalid", {
25354
+ Object.defineProperty(AppEditor.prototype, "invalid", {
25317
25355
  get: function () {
25318
25356
  var _a;
25319
25357
  return (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.invalid; })) !== -1) || false;
@@ -25321,7 +25359,7 @@
25321
25359
  enumerable: false,
25322
25360
  configurable: true
25323
25361
  });
25324
- Object.defineProperty(AppTabEditor.prototype, "pending", {
25362
+ Object.defineProperty(AppEditor.prototype, "pending", {
25325
25363
  get: function () {
25326
25364
  var _a;
25327
25365
  return (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.pending; })) !== -1) || false;
@@ -25329,7 +25367,7 @@
25329
25367
  enumerable: false,
25330
25368
  configurable: true
25331
25369
  });
25332
- Object.defineProperty(AppTabEditor.prototype, "loading", {
25370
+ Object.defineProperty(AppEditor.prototype, "loading", {
25333
25371
  get: function () {
25334
25372
  var _a;
25335
25373
  return this._loading || (((_a = this._children) === null || _a === void 0 ? void 0 : _a.findIndex(function (c) { return c.enabled && c.loading; })) !== -1) || false;
@@ -25337,76 +25375,47 @@
25337
25375
  enumerable: false,
25338
25376
  configurable: true
25339
25377
  });
25340
- Object.defineProperty(AppTabEditor.prototype, "enabled", {
25378
+ Object.defineProperty(AppEditor.prototype, "enabled", {
25341
25379
  get: function () {
25342
25380
  return this._enabled;
25343
25381
  },
25344
25382
  enumerable: false,
25345
25383
  configurable: true
25346
25384
  });
25347
- Object.defineProperty(AppTabEditor.prototype, "disabled", {
25385
+ Object.defineProperty(AppEditor.prototype, "disabled", {
25348
25386
  get: function () {
25349
25387
  return !this._enabled;
25350
25388
  },
25351
25389
  enumerable: false,
25352
25390
  configurable: true
25353
25391
  });
25354
- Object.defineProperty(AppTabEditor.prototype, "children", {
25392
+ Object.defineProperty(AppEditor.prototype, "children", {
25355
25393
  get: function () {
25356
25394
  return this._children;
25357
25395
  },
25358
25396
  enumerable: false,
25359
25397
  configurable: true
25360
25398
  });
25361
- Object.defineProperty(AppTabEditor.prototype, "empty", {
25399
+ Object.defineProperty(AppEditor.prototype, "empty", {
25362
25400
  get: function () {
25363
25401
  return this._enabled;
25364
25402
  },
25365
25403
  enumerable: false,
25366
25404
  configurable: true
25367
25405
  });
25368
- Object.defineProperty(AppTabEditor.prototype, "selectedTabIndex", {
25369
- get: function () {
25370
- return this._selectedTabIndex;
25371
- },
25372
- set: function (value) {
25373
- this.setSelectedTabIndex(value);
25374
- },
25375
- enumerable: false,
25376
- configurable: true
25377
- });
25378
- AppTabEditor.prototype.ngOnInit = function () {
25406
+ AppEditor.prototype.ngOnInit = function () {
25379
25407
  var _this = this;
25380
- this.queryTabIndexParamName = this.queryTabIndexParamName || 'tab';
25381
- // Read the selected tab index, from path query params
25382
- if (this.tabGroup) {
25383
- this.registerSubscription(this.route.queryParams
25384
- .subscribe(function (queryParams) {
25385
- _this.queryParams = Object.assign({}, queryParams);
25386
- // Parse tab param
25387
- if (_this.tabCount > 1 && _this.queryTabIndexParamName) {
25388
- var tabIndex = queryParams[_this.queryTabIndexParamName];
25389
- _this.queryParams[_this.queryTabIndexParamName] = tabIndex && parseInt(tabIndex) || undefined;
25390
- if (isNotNil(_this.queryParams[_this.queryTabIndexParamName])) {
25391
- _this.selectedTabIndex = _this.queryParams[_this.queryTabIndexParamName];
25392
- }
25393
- }
25394
- // Realign tab, after a delay because the tab can be disabled when component is created
25395
- setTimeout(function () { return _this.tabGroup.realignInkBar(); }, 500);
25396
- }));
25397
- }
25398
25408
  if (this.formButtonsBar) {
25399
25409
  this.registerSubscription(this.formButtonsBar.onBack.subscribe(function (event) { return _this.goBack(event); }));
25400
25410
  }
25401
25411
  };
25402
- AppTabEditor.prototype.ngAfterViewInit = function () {
25412
+ AppEditor.prototype.ngAfterViewInit = function () {
25403
25413
  // Can be override by subclasses
25404
25414
  };
25405
- AppTabEditor.prototype.ngOnDestroy = function () {
25415
+ AppEditor.prototype.ngOnDestroy = function () {
25406
25416
  this._subscription.unsubscribe();
25407
- this.selectedTabIndexChange.complete();
25408
25417
  };
25409
- AppTabEditor.prototype.addChildForm = function (form) {
25418
+ AppEditor.prototype.addChildForm = function (form) {
25410
25419
  if (!form)
25411
25420
  throw new Error('Trying to register an undefined child form');
25412
25421
  this._children = this._children || [];
@@ -25418,26 +25427,26 @@
25418
25427
  }
25419
25428
  return this;
25420
25429
  };
25421
- AppTabEditor.prototype.addChildForms = function (forms) {
25430
+ AppEditor.prototype.addChildForms = function (forms) {
25422
25431
  var _this = this;
25423
25432
  (forms || []).forEach(function (form) { return _this.addChildForm(form); });
25424
25433
  return this;
25425
25434
  };
25426
- AppTabEditor.prototype.disable = function (opts) {
25435
+ AppEditor.prototype.disable = function (opts) {
25427
25436
  var _a;
25428
25437
  this._enabled = false;
25429
25438
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.disable(opts); });
25430
25439
  if (!this.loading && (!opts || opts.emitEvent !== false))
25431
25440
  this.markForCheck();
25432
25441
  };
25433
- AppTabEditor.prototype.enable = function (opts) {
25442
+ AppEditor.prototype.enable = function (opts) {
25434
25443
  var _a;
25435
25444
  this._enabled = true;
25436
25445
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.enable(opts); });
25437
25446
  if (!this.loading && (!opts || opts.emitEvent !== false))
25438
25447
  this.markForCheck();
25439
25448
  };
25440
- AppTabEditor.prototype.markAsPristine = function (opts) {
25449
+ AppEditor.prototype.markAsPristine = function (opts) {
25441
25450
  var _a;
25442
25451
  this.error = null;
25443
25452
  this.submitted = false;
@@ -25446,7 +25455,7 @@
25446
25455
  if (!this.loading && (!opts || opts.emitEvent !== false))
25447
25456
  this.markForCheck();
25448
25457
  };
25449
- AppTabEditor.prototype.markAsUntouched = function (opts) {
25458
+ AppEditor.prototype.markAsUntouched = function (opts) {
25450
25459
  var _a;
25451
25460
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAsUntouched(); });
25452
25461
  if (!this.loading && (!opts || opts.emitEvent !== false))
@@ -25456,99 +25465,49 @@
25456
25465
  * @deprecated prefer to use markAllAsTouched()
25457
25466
  * @param opts
25458
25467
  */
25459
- AppTabEditor.prototype.markAsTouched = function (opts) {
25468
+ AppEditor.prototype.markAsTouched = function (opts) {
25460
25469
  var _a;
25461
25470
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAsTouched(opts); });
25462
25471
  if (!this.loading && (!opts || opts.emitEvent !== false))
25463
25472
  this.markForCheck();
25464
25473
  };
25465
- AppTabEditor.prototype.markAllAsTouched = function (opts) {
25474
+ AppEditor.prototype.markAllAsTouched = function (opts) {
25466
25475
  var _a;
25467
25476
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAllAsTouched(opts); });
25468
25477
  if (!this.loading && (!opts || opts.emitEvent !== false))
25469
25478
  this.markForCheck();
25470
25479
  };
25471
- AppTabEditor.prototype.markAsDirty = function (opts) {
25480
+ AppEditor.prototype.markAsDirty = function (opts) {
25472
25481
  this._dirty = true;
25473
25482
  if (!this.loading && (!opts || opts.emitEvent !== false))
25474
25483
  this.markForCheck();
25475
25484
  };
25476
- AppTabEditor.prototype.markAsLoading = function (opts) {
25485
+ AppEditor.prototype.markAsLoading = function (opts) {
25477
25486
  if (!this._loading) {
25478
25487
  this._loading = true;
25479
25488
  if (!opts || opts.emitEvent !== false)
25480
25489
  this.markForCheck();
25481
25490
  }
25482
25491
  };
25483
- AppTabEditor.prototype.markAsLoaded = function (opts) {
25492
+ AppEditor.prototype.markAsLoaded = function (opts) {
25484
25493
  if (this._loading) {
25485
25494
  this._loading = false;
25486
25495
  if (!opts || opts.emitEvent !== false)
25487
25496
  this.markForCheck();
25488
25497
  }
25489
25498
  };
25490
- AppTabEditor.prototype.onTabChange = function (event, queryTabIndexParamName) {
25491
- queryTabIndexParamName = queryTabIndexParamName || this.queryTabIndexParamName;
25492
- if (!queryTabIndexParamName)
25493
- return true; // Skip if tab query param not set
25494
- if (!this.queryParams || +this.queryParams[queryTabIndexParamName] !== event.index) {
25495
- this.queryParams = this.queryParams || {};
25496
- this.queryParams[queryTabIndexParamName] = event.index;
25497
- if (queryTabIndexParamName === 'tab' && isNotNil(this.queryParams['subtab'])) {
25498
- delete this.queryParams.subtab; // clean subtab
25499
- }
25500
- this.router.navigate(['.'], {
25501
- relativeTo: this.route,
25502
- queryParams: this.queryParams,
25503
- replaceUrl: true
25504
- });
25505
- return true;
25506
- }
25507
- return false;
25499
+ AppEditor.prototype.markAsReady = function (opts) {
25500
+ var _a;
25501
+ (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAsReady(opts); });
25502
+ this._$ready.next(true);
25508
25503
  };
25509
- /**
25510
- * Action triggered when user swipes
25511
- */
25512
- AppTabEditor.prototype.onSwipeTab = function (event) {
25513
- var _this = this;
25514
- // DEBUG
25515
- // if (this.debug) console.debug("[tab-page] onSwipeTab()");
25516
- // Skip, if not a valid swipe event
25517
- if (!this.enableSwipe || !event
25518
- || event.defaultPrevented || (event.srcEvent && event.srcEvent.defaultPrevented)
25519
- || event.pointerType !== 'touch') {
25520
- return false;
25521
- }
25522
- // DEBUG
25523
- //if (this.debug)
25524
- //console.debug("[tab-page] Detected swipe: " + event.type, event);
25525
- var selectTabIndex = this.selectedTabIndex;
25526
- switch (event.type) {
25527
- // Open next tab
25528
- case 'swipeleft':
25529
- var isLast = selectTabIndex >= (this.tabCount - 1);
25530
- selectTabIndex = isLast ? 0 : selectTabIndex + 1;
25531
- break;
25532
- // Open previous tab
25533
- case 'swiperight':
25534
- var isFirst = selectTabIndex <= 0;
25535
- selectTabIndex = isFirst ? this.tabCount : selectTabIndex - 1;
25536
- break;
25537
- // Other case
25538
- default:
25539
- console.error('[tab-page] Unknown swipe action: ' + event.type);
25540
- return false;
25541
- }
25542
- setTimeout(function () {
25543
- _this.selectedTabIndex = selectTabIndex;
25544
- _this.markForCheck();
25545
- });
25546
- return true;
25504
+ AppEditor.prototype.ready = function (opts) {
25505
+ return firstTruePromise(this._$ready);
25547
25506
  };
25548
- AppTabEditor.prototype.onSubTabChange = function (event) {
25549
- this.onTabChange(event, 'subtab');
25507
+ AppEditor.prototype.waitIdle = function (opts) {
25508
+ return AppFormUtils.waitIdle(this, opts);
25550
25509
  };
25551
- AppTabEditor.prototype.cancel = function (event) {
25510
+ AppEditor.prototype.cancel = function (event) {
25552
25511
  return __awaiter(this, void 0, void 0, function () {
25553
25512
  return __generator(this, function (_b) {
25554
25513
  switch (_b.label) {
@@ -25574,12 +25533,11 @@
25574
25533
  *
25575
25534
  * @param opts
25576
25535
  */
25577
- AppTabEditor.prototype.unload = function (opts) {
25536
+ AppEditor.prototype.unload = function (opts) {
25578
25537
  return __awaiter(this, void 0, void 0, function () {
25579
25538
  return __generator(this, function (_b) {
25580
25539
  console.debug('[tab-page] Unloading data...');
25581
25540
  this.markAsLoading();
25582
- this.selectedTabIndex = 0;
25583
25541
  this._children.forEach(function (f) {
25584
25542
  if (f instanceof AppForm) {
25585
25543
  f.reset(null, opts);
@@ -25592,7 +25550,7 @@
25592
25550
  });
25593
25551
  });
25594
25552
  };
25595
- AppTabEditor.prototype.reloadWithConfirmation = function (confirm) {
25553
+ AppEditor.prototype.reloadWithConfirmation = function (confirm) {
25596
25554
  return __awaiter(this, void 0, void 0, function () {
25597
25555
  var needConfirm, translations, alert;
25598
25556
  return __generator(this, function (_b) {
@@ -25640,7 +25598,7 @@
25640
25598
  });
25641
25599
  });
25642
25600
  };
25643
- AppTabEditor.prototype.goBack = function (event) {
25601
+ AppEditor.prototype.goBack = function (event) {
25644
25602
  var _a;
25645
25603
  return __awaiter(this, void 0, void 0, function () {
25646
25604
  return __generator(this, function (_b) {
@@ -25656,32 +25614,15 @@
25656
25614
  });
25657
25615
  });
25658
25616
  };
25659
- AppTabEditor.prototype.setSelectedTabIndex = function (value, opts) {
25617
+ AppEditor.prototype.logFormErrors = function () {
25660
25618
  var _this = this;
25661
- // Fix value
25662
- if (value < 0) {
25663
- value = 0;
25664
- }
25665
- else if (value > this.tabCount - 1) {
25666
- value = this.tabCount - 1;
25667
- }
25668
- this._selectedTabIndex = value;
25669
- this.selectedTabIndexChange.next(value);
25670
- if (this.tabGroup && (!opts || opts.realignInkBar !== false)) {
25671
- this.tabGroup.selectedIndex = value;
25672
- this.markForCheck();
25673
- // Wait tab change in UI, before realign ink tab
25674
- setTimeout(function () { return _this.tabGroup.realignInkBar(); }, 200);
25675
- }
25676
- else if (!opts || opts.emitEvent !== false) {
25677
- this.markForCheck();
25678
- }
25679
- };
25680
- AppTabEditor.prototype.waitIdle = function (opts) {
25681
- return AppFormUtils.waitIdle(this, opts);
25619
+ var _a;
25620
+ if (this.debug)
25621
+ console.debug('[app-tab-editor] Page not valid. Checking where (forms, tables)...');
25622
+ (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return _this.logChildrenFormErrors(c); });
25682
25623
  };
25683
25624
  /* -- protected methods -- */
25684
- AppTabEditor.prototype.scrollToTop = function (duration) {
25625
+ AppEditor.prototype.scrollToTop = function (duration) {
25685
25626
  return __awaiter(this, void 0, void 0, function () {
25686
25627
  var scrollToTop_1;
25687
25628
  return __generator(this, function (_b) {
@@ -25703,13 +25644,13 @@
25703
25644
  });
25704
25645
  });
25705
25646
  };
25706
- AppTabEditor.prototype.registerSubscription = function (sub) {
25647
+ AppEditor.prototype.registerSubscription = function (sub) {
25707
25648
  this._subscription.add(sub);
25708
25649
  };
25709
- AppTabEditor.prototype.unregisterSubscription = function (sub) {
25650
+ AppEditor.prototype.unregisterSubscription = function (sub) {
25710
25651
  this._subscription.remove(sub);
25711
25652
  };
25712
- AppTabEditor.prototype.saveIfDirtyAndConfirm = function (event, opts) {
25653
+ AppEditor.prototype.saveIfDirtyAndConfirm = function (event, opts) {
25713
25654
  return __awaiter(this, void 0, void 0, function () {
25714
25655
  var confirm, cancel, translations, alert;
25715
25656
  return __generator(this, function (_b) {
@@ -25763,7 +25704,7 @@
25763
25704
  });
25764
25705
  });
25765
25706
  };
25766
- AppTabEditor.prototype.showToast = function (opts) {
25707
+ AppEditor.prototype.showToast = function (opts) {
25767
25708
  return __awaiter(this, void 0, void 0, function () {
25768
25709
  return __generator(this, function (_b) {
25769
25710
  switch (_b.label) {
@@ -25778,18 +25719,11 @@
25778
25719
  });
25779
25720
  });
25780
25721
  };
25781
- AppTabEditor.prototype.logFormErrors = function () {
25782
- var _this = this;
25783
- var _a;
25784
- if (this.debug)
25785
- console.debug('[app-tab-editor] Page not valid. Checking where (forms, tables)...');
25786
- (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return _this.logChildrenFormErrors(c); });
25787
- };
25788
- AppTabEditor.prototype.logChildrenFormErrors = function (c, prefix, path) {
25722
+ AppEditor.prototype.logChildrenFormErrors = function (c, prefix, path) {
25789
25723
  var _this = this;
25790
25724
  prefix = prefix || '[app-tab-editor] ';
25791
25725
  // If editor
25792
- if (c instanceof AppTabEditor) {
25726
+ if (c instanceof AppEditor) {
25793
25727
  c.logFormErrors();
25794
25728
  }
25795
25729
  // Angular form control
@@ -25827,11 +25761,179 @@
25827
25761
  console.warn(prefix + " Unknown children sub-form: ", c);
25828
25762
  }
25829
25763
  };
25830
- AppTabEditor.prototype.markForCheck = function () {
25764
+ AppEditor.prototype.markForCheck = function () {
25831
25765
  // Should be override by subclasses, if change detection is Push
25832
25766
  };
25833
- return AppTabEditor;
25767
+ return AppEditor;
25834
25768
  }());
25769
+ AppEditor.decorators = [
25770
+ { type: i0.Directive }
25771
+ ];
25772
+ AppEditor.ctorParameters = function () { return [
25773
+ { type: i3.ActivatedRoute },
25774
+ { type: i3.Router },
25775
+ { type: i1$5.AlertController },
25776
+ { type: i1$2.TranslateService }
25777
+ ]; };
25778
+ AppEditor.propDecorators = {
25779
+ toolbar: [{ type: i0.ViewChild, args: [ToolbarToken,] }],
25780
+ formButtonsBar: [{ type: i0.ViewChild, args: [FormButtonsBarToken, { static: true },] }],
25781
+ content: [{ type: i0.ViewChild, args: [i1$5.IonContent, { static: true },] }]
25782
+ };
25783
+ // eslint-disable-next-line @angular-eslint/directive-class-suffix
25784
+ var AppTabEditor = /** @class */ (function (_super_1) {
25785
+ __extends(AppTabEditor, _super_1);
25786
+ function AppTabEditor(route, router, alertCtrl, translate, options) {
25787
+ var _this = _super_1.call(this, route, router, alertCtrl, translate) || this;
25788
+ _this.route = route;
25789
+ _this.router = router;
25790
+ _this.alertCtrl = alertCtrl;
25791
+ _this.translate = translate;
25792
+ _this._selectedTabIndex = 0;
25793
+ _this.selectedTabIndexChange = new i0.EventEmitter();
25794
+ options = Object.assign({ tabCount: 1, enableSwipe: true, tabGroupAnimationDuration: '200ms' }, options);
25795
+ _this.tabCount = options.tabCount;
25796
+ _this.enableSwipe = options.enableSwipe;
25797
+ _this.tabGroupAnimationDuration = options.tabGroupAnimationDuration;
25798
+ return _this;
25799
+ }
25800
+ Object.defineProperty(AppTabEditor.prototype, "selectedTabIndex", {
25801
+ get: function () {
25802
+ return this._selectedTabIndex;
25803
+ },
25804
+ set: function (value) {
25805
+ this.setSelectedTabIndex(value);
25806
+ },
25807
+ enumerable: false,
25808
+ configurable: true
25809
+ });
25810
+ AppTabEditor.prototype.ngOnInit = function () {
25811
+ var _this = this;
25812
+ _super_1.prototype.ngOnInit.call(this);
25813
+ this.queryTabIndexParamName = this.queryTabIndexParamName || 'tab';
25814
+ // Read the selected tab index, from path query params
25815
+ if (this.tabGroup) {
25816
+ this.registerSubscription(this.route.queryParams
25817
+ .subscribe(function (queryParams) {
25818
+ _this.queryParams = Object.assign({}, queryParams);
25819
+ // Parse tab param
25820
+ if (_this.tabCount > 1 && _this.queryTabIndexParamName) {
25821
+ var tabIndex = queryParams[_this.queryTabIndexParamName];
25822
+ _this.queryParams[_this.queryTabIndexParamName] = tabIndex && parseInt(tabIndex) || undefined;
25823
+ if (isNotNil(_this.queryParams[_this.queryTabIndexParamName])) {
25824
+ _this.selectedTabIndex = _this.queryParams[_this.queryTabIndexParamName];
25825
+ }
25826
+ }
25827
+ // Realign tab, after a delay because the tab can be disabled when component is created
25828
+ setTimeout(function () { return _this.tabGroup.realignInkBar(); }, 500);
25829
+ }));
25830
+ }
25831
+ };
25832
+ AppTabEditor.prototype.ngOnDestroy = function () {
25833
+ _super_1.prototype.ngOnDestroy.call(this);
25834
+ this.selectedTabIndexChange.complete();
25835
+ };
25836
+ AppTabEditor.prototype.setSelectedTabIndex = function (value, opts) {
25837
+ var _this = this;
25838
+ // Fix value
25839
+ if (value < 0) {
25840
+ value = 0;
25841
+ }
25842
+ else if (value > this.tabCount - 1) {
25843
+ value = this.tabCount - 1;
25844
+ }
25845
+ this._selectedTabIndex = value;
25846
+ this.selectedTabIndexChange.next(value);
25847
+ if (this.tabGroup && (!opts || opts.realignInkBar !== false)) {
25848
+ this.tabGroup.selectedIndex = value;
25849
+ this.markForCheck();
25850
+ // Wait tab change in UI, before realign ink tab
25851
+ setTimeout(function () { return _this.tabGroup.realignInkBar(); }, 200);
25852
+ }
25853
+ else if (!opts || opts.emitEvent !== false) {
25854
+ this.markForCheck();
25855
+ }
25856
+ };
25857
+ AppTabEditor.prototype.onTabChange = function (event, queryTabIndexParamName) {
25858
+ queryTabIndexParamName = queryTabIndexParamName || this.queryTabIndexParamName;
25859
+ if (!queryTabIndexParamName)
25860
+ return true; // Skip if tab query param not set
25861
+ if (!this.queryParams || +this.queryParams[queryTabIndexParamName] !== event.index) {
25862
+ this.queryParams = this.queryParams || {};
25863
+ this.queryParams[queryTabIndexParamName] = event.index;
25864
+ if (queryTabIndexParamName === 'tab' && isNotNil(this.queryParams['subtab'])) {
25865
+ delete this.queryParams.subtab; // clean subtab
25866
+ }
25867
+ this.router.navigate(['.'], {
25868
+ relativeTo: this.route,
25869
+ queryParams: this.queryParams,
25870
+ replaceUrl: true
25871
+ });
25872
+ return true;
25873
+ }
25874
+ return false;
25875
+ };
25876
+ /**
25877
+ * Action triggered when user swipes
25878
+ */
25879
+ AppTabEditor.prototype.onSwipeTab = function (event) {
25880
+ var _this = this;
25881
+ // DEBUG
25882
+ // if (this.debug) console.debug("[tab-page] onSwipeTab()");
25883
+ // Skip, if not a valid swipe event
25884
+ if (!this.enableSwipe || !event
25885
+ || event.defaultPrevented || (event.srcEvent && event.srcEvent.defaultPrevented)
25886
+ || event.pointerType !== 'touch') {
25887
+ return false;
25888
+ }
25889
+ // DEBUG
25890
+ //if (this.debug)
25891
+ //console.debug("[tab-page] Detected swipe: " + event.type, event);
25892
+ var selectTabIndex = this.selectedTabIndex;
25893
+ switch (event.type) {
25894
+ // Open next tab
25895
+ case 'swipeleft':
25896
+ var isLast = selectTabIndex >= (this.tabCount - 1);
25897
+ selectTabIndex = isLast ? 0 : selectTabIndex + 1;
25898
+ break;
25899
+ // Open previous tab
25900
+ case 'swiperight':
25901
+ var isFirst = selectTabIndex <= 0;
25902
+ selectTabIndex = isFirst ? this.tabCount : selectTabIndex - 1;
25903
+ break;
25904
+ // Other case
25905
+ default:
25906
+ console.error('[tab-page] Unknown swipe action: ' + event.type);
25907
+ return false;
25908
+ }
25909
+ setTimeout(function () {
25910
+ _this.selectedTabIndex = selectTabIndex;
25911
+ _this.markForCheck();
25912
+ });
25913
+ return true;
25914
+ };
25915
+ AppTabEditor.prototype.onSubTabChange = function (event) {
25916
+ this.onTabChange(event, 'subtab');
25917
+ };
25918
+ AppTabEditor.prototype.unload = function (opts) {
25919
+ var _super = Object.create(null, {
25920
+ unload: { get: function () { return _super_1.prototype.unload; } }
25921
+ });
25922
+ return __awaiter(this, void 0, void 0, function () {
25923
+ return __generator(this, function (_b) {
25924
+ switch (_b.label) {
25925
+ case 0:
25926
+ this.selectedTabIndex = 0;
25927
+ return [4 /*yield*/, _super.unload.call(this, opts)];
25928
+ case 1:
25929
+ _b.sent();
25930
+ return [2 /*return*/];
25931
+ }
25932
+ });
25933
+ });
25934
+ };
25935
+ return AppTabEditor;
25936
+ }(AppEditor));
25835
25937
  AppTabEditor.decorators = [
25836
25938
  { type: i0.Directive }
25837
25939
  ];
@@ -25844,12 +25946,9 @@
25844
25946
  ]; };
25845
25947
  AppTabEditor.propDecorators = {
25846
25948
  queryTabIndexParamName: [{ type: i0.Input }],
25847
- tabGroup: [{ type: i0.ViewChild, args: ['tabGroup', { static: true },] }],
25848
- toolbar: [{ type: i0.ViewChild, args: [ToolbarToken,] }],
25849
- formButtonsBar: [{ type: i0.ViewChild, args: [FormButtonsBarToken, { static: true },] }],
25850
- content: [{ type: i0.ViewChild, args: [i1$5.IonContent, { static: true },] }],
25851
25949
  selectedTabIndex: [{ type: i0.Input }],
25852
- selectedTabIndexChange: [{ type: i0.Output }]
25950
+ selectedTabIndexChange: [{ type: i0.Output }],
25951
+ tabGroup: [{ type: i0.ViewChild, args: ['tabGroup', { static: true },] }]
25853
25952
  };
25854
25953
 
25855
25954
  var AppEditorOptions = /** @class */ (function (_super) {
@@ -26089,13 +26188,16 @@
26089
26188
  opts = Object.assign({ updateRoute: this._autoUpdateRoute && idChanged && !this.loading, openTabIndex: this._autoOpenNextTab && idChanged && isNil(this.previousDataId) && this.computeNextTabIndex() }, opts);
26090
26189
  this.data = data;
26091
26190
  this.previousDataId = data.id || null;
26092
- promiseOrVoid = this.setValue(data);
26093
- if (!promiseOrVoid) return [3 /*break*/, 2];
26094
- return [4 /*yield*/, promiseOrVoid];
26191
+ return [4 /*yield*/, this.ready()];
26095
26192
  case 1:
26096
26193
  _b.sent();
26097
- _b.label = 2;
26194
+ promiseOrVoid = this.setValue(data);
26195
+ if (!promiseOrVoid) return [3 /*break*/, 3];
26196
+ return [4 /*yield*/, promiseOrVoid];
26098
26197
  case 2:
26198
+ _b.sent();
26199
+ _b.label = 3;
26200
+ case 3:
26099
26201
  if (!opts || opts.emitEvent !== false) {
26100
26202
  this.markAsPristine();
26101
26203
  this.markAsUntouched();
@@ -27818,6 +27920,7 @@
27818
27920
  exports.AdminModule = AdminModule;
27819
27921
  exports.AdminRoutingModule = AdminRoutingModule;
27820
27922
  exports.Alerts = Alerts;
27923
+ exports.AppEditor = AppEditor;
27821
27924
  exports.AppEditorOptions = AppEditorOptions;
27822
27925
  exports.AppEntityEditor = AppEntityEditor;
27823
27926
  exports.AppForm = AppForm;