@sumaris-net/ngx-components 0.27.6 → 0.27.10

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.
@@ -1046,24 +1046,35 @@
1046
1046
  * @param opts
1047
1047
  */
1048
1048
  function waitFor(predicate, opts) {
1049
- if (predicate())
1050
- return Promise.resolve(true);
1051
- var period = opts && opts.checkPeriod || 300;
1052
- var dueTime = opts && opts.dueTime || period;
1053
- var wait$ = rxjs.timer(dueTime, period)
1054
- .pipe(
1055
- // For DEBUG :
1056
- //tap(() => console.debug("Waiting form idle...", form)),
1057
- operators.filter(function (_) { return predicate(); }), operators.map(function (_) { return true; }));
1058
- // Add timeout
1059
- if (opts && opts.timeout) {
1060
- var $timeout = rxjs.timer(opts.timeout);
1061
- wait$ = rxjs.merge(wait$.pipe(operators.takeUntil($timeout)), $timeout
1062
- .pipe(operators.map(function () {
1063
- throw new Error("Timeout waitIdle() - after " + opts.timeout + "ms");
1064
- })));
1065
- }
1066
- return firstNotNilPromise(wait$);
1049
+ return __awaiter(this, void 0, void 0, function () {
1050
+ var period, dueTime, wait$, $timeout;
1051
+ return __generator(this, function (_a) {
1052
+ switch (_a.label) {
1053
+ case 0:
1054
+ if (predicate())
1055
+ return [2 /*return*/, Promise.resolve()];
1056
+ period = opts && opts.checkPeriod || 300;
1057
+ dueTime = opts && opts.dueTime || period;
1058
+ wait$ = rxjs.timer(dueTime, period)
1059
+ .pipe(
1060
+ // For DEBUG :
1061
+ //tap(() => console.debug("Waiting form idle...", form)),
1062
+ operators.filter(function (_) { return predicate(); }), operators.map(function (_) { return true; }));
1063
+ // Add timeout
1064
+ if (opts && opts.timeout) {
1065
+ $timeout = rxjs.timer(opts.timeout);
1066
+ wait$ = rxjs.merge(wait$.pipe(operators.takeUntil($timeout)), $timeout
1067
+ .pipe(operators.map(function () {
1068
+ throw new Error("Timeout waitIdle() - after " + opts.timeout + "ms");
1069
+ })));
1070
+ }
1071
+ return [4 /*yield*/, firstNotNilPromise(wait$)];
1072
+ case 1:
1073
+ _a.sent();
1074
+ return [2 /*return*/];
1075
+ }
1076
+ });
1077
+ });
1067
1078
  }
1068
1079
 
1069
1080
  function createPromiseEventEmitter() {
@@ -3134,7 +3145,6 @@
3134
3145
  var endField = group.get(endDateField);
3135
3146
  var endDate = fromDateISOString(endField.value);
3136
3147
  if (isNotNil(startDate) && isNotNil(endDate) && Math.abs(startDate.diff(endDate, durationUnit)) > maxDuration) {
3137
- console.log('TODO error !');
3138
3148
  // Update end field
3139
3149
  endField.markAsTouched({ onlySelf: true });
3140
3150
  endField.markAsPending();
@@ -3471,6 +3481,9 @@
3471
3481
  AppFormProvider.prototype.ready = function () {
3472
3482
  return this.delegate.ready();
3473
3483
  };
3484
+ AppFormProvider.prototype.waitIdle = function (opts) {
3485
+ return this.delegate.waitIdle();
3486
+ };
3474
3487
  AppFormProvider.prototype.disable = function (opts) {
3475
3488
  return this.delegate.disable(opts);
3476
3489
  };
@@ -19032,7 +19045,7 @@
19032
19045
  var _this = this;
19033
19046
  this.error = null;
19034
19047
  this._enable = false;
19035
- this._$ready = new rxjs.BehaviorSubject(true);
19048
+ this._$ready = new rxjs.BehaviorSubject(false);
19036
19049
  this._loading = true;
19037
19050
  this.i18nFieldPrefix = null;
19038
19051
  this._subscription = new rxjs.Subscription();
@@ -19041,6 +19054,7 @@
19041
19054
  this.onSubmit = new i0.EventEmitter();
19042
19055
  if (form)
19043
19056
  this.setForm(form);
19057
+ this.translate = injector.get(i1$2.TranslateService);
19044
19058
  this.settings = injector.get(LocalSettingsService);
19045
19059
  this.errorTranslator = injector.get(FormErrorTranslator);
19046
19060
  this.autocompleteHelper = new MatAutocompleteConfigHolder(this.settings && {
@@ -19048,6 +19062,13 @@
19048
19062
  });
19049
19063
  this.autocompleteFields = this.autocompleteHelper.fields;
19050
19064
  }
19065
+ Object.defineProperty(AppForm.prototype, "_ready", {
19066
+ get: function () {
19067
+ return this._$ready.value == true;
19068
+ },
19069
+ enumerable: false,
19070
+ configurable: true
19071
+ });
19051
19072
  Object.defineProperty(AppForm.prototype, "value", {
19052
19073
  get: function () {
19053
19074
  return this.form.value;
@@ -19259,14 +19280,27 @@
19259
19280
  * @param opts
19260
19281
  */
19261
19282
  AppForm.prototype.ready = function (opts) {
19262
- return firstTruePromise(this._$ready);
19283
+ return __awaiter(this, void 0, void 0, function () {
19284
+ return __generator(this, function (_b) {
19285
+ switch (_b.label) {
19286
+ case 0: return [4 /*yield*/, firstTruePromise(this._$ready)];
19287
+ case 1:
19288
+ _b.sent();
19289
+ return [2 /*return*/];
19290
+ }
19291
+ });
19292
+ });
19263
19293
  };
19264
19294
  /**
19265
19295
  * Wait form is idle (not loading)
19266
19296
  * @param opts
19267
19297
  */
19268
19298
  AppForm.prototype.waitIdle = function (opts) {
19269
- return AppFormUtils.waitIdle(this, opts);
19299
+ return __awaiter(this, void 0, void 0, function () {
19300
+ return __generator(this, function (_b) {
19301
+ return [2 /*return*/, AppFormUtils.waitIdle(this, opts)];
19302
+ });
19303
+ });
19270
19304
  };
19271
19305
  AppForm.prototype.updateValueAndValidity = function (opts) {
19272
19306
  AppFormUtils.updateValueAndValidity(this.form, opts);
@@ -19274,7 +19308,9 @@
19274
19308
  this.markForCheck();
19275
19309
  };
19276
19310
  AppForm.prototype.translateControlPath = function (path) {
19277
- return this.getFieldName(path);
19311
+ var _a;
19312
+ var i18nFieldName = this.getI18nFieldName(path);
19313
+ return ((_a = this.translate) === null || _a === void 0 ? void 0 : _a.instant(i18nFieldName)) || i18nFieldName;
19278
19314
  };
19279
19315
  /* -- protected methods -- */
19280
19316
  AppForm.prototype.getFormError = function (form, opts) {
@@ -19282,7 +19318,7 @@
19282
19318
  return undefined;
19283
19319
  return this.errorTranslator.translateErrors(this.form, Object.assign({ controlPathTranslator: this }, opts));
19284
19320
  };
19285
- AppForm.prototype.getFieldName = function (path) {
19321
+ AppForm.prototype.getI18nFieldName = function (path) {
19286
19322
  return (this.i18nFieldPrefix || '') + changeCaseToUnderscore(path).toUpperCase();
19287
19323
  };
19288
19324
  AppForm.prototype.registerSubscription = function (sub) {
@@ -19292,7 +19328,7 @@
19292
19328
  return this.autocompleteHelper.add(fieldName, opts);
19293
19329
  };
19294
19330
  AppForm.prototype.markForCheck = function () {
19295
- // Should be override by subclasses
19331
+ // Should be overwritten by subclasses
19296
19332
  console.warn('markForCheck() has been called, but is not overwritten by component ' + this.constructor.name);
19297
19333
  };
19298
19334
  return AppForm;
@@ -23762,6 +23798,7 @@
23762
23798
  };
23763
23799
  AppTable.prototype.markAsSaving = function (opts) {
23764
23800
  if (this.savingSubject.value !== true) {
23801
+ this.focusColumn = undefined; // unselect focus column
23765
23802
  this.savingSubject.next(true);
23766
23803
  if (!opts || opts.emitEvent !== false) {
23767
23804
  this.markForCheck();
@@ -24512,10 +24549,28 @@
24512
24549
  this.dataSource.move(id, direction);
24513
24550
  };
24514
24551
  AppTable.prototype.ready = function () {
24515
- return firstTruePromise(this.readySubject);
24552
+ return __awaiter(this, void 0, void 0, function () {
24553
+ return __generator(this, function (_d) {
24554
+ switch (_d.label) {
24555
+ case 0: return [4 /*yield*/, firstTruePromise(this.readySubject)];
24556
+ case 1:
24557
+ _d.sent();
24558
+ return [2 /*return*/];
24559
+ }
24560
+ });
24561
+ });
24516
24562
  };
24517
- AppTable.prototype.waitIdle = function () {
24518
- return firstFalsePromise(this.loadingSubject);
24563
+ AppTable.prototype.waitIdle = function (opts) {
24564
+ return __awaiter(this, void 0, void 0, function () {
24565
+ return __generator(this, function (_d) {
24566
+ switch (_d.label) {
24567
+ case 0: return [4 /*yield*/, firstFalsePromise(this.loadingSubject)];
24568
+ case 1:
24569
+ _d.sent();
24570
+ return [2 /*return*/];
24571
+ }
24572
+ });
24573
+ });
24519
24574
  };
24520
24575
  AppTable.prototype.openSelectColumnsModal = function (event) {
24521
24576
  return __awaiter(this, void 0, void 0, function () {
@@ -25502,7 +25557,16 @@
25502
25557
  this._$ready.next(true);
25503
25558
  };
25504
25559
  AppEditor.prototype.ready = function (opts) {
25505
- return firstTruePromise(this._$ready);
25560
+ return __awaiter(this, void 0, void 0, function () {
25561
+ return __generator(this, function (_b) {
25562
+ switch (_b.label) {
25563
+ case 0: return [4 /*yield*/, firstTruePromise(this._$ready)];
25564
+ case 1:
25565
+ _b.sent();
25566
+ return [2 /*return*/];
25567
+ }
25568
+ });
25569
+ });
25506
25570
  };
25507
25571
  AppEditor.prototype.waitIdle = function (opts) {
25508
25572
  return AppFormUtils.waitIdle(this, opts);