@sumaris-net/ngx-components 1.23.24 → 1.23.26

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.
@@ -589,6 +589,10 @@
589
589
  return isNotNil(value) && NUMBER_RANGE_REGEXP.test(value);
590
590
  }
591
591
  function getPropertyByPath(obj, path, defaultValue) {
592
+ // Path is an array: convert path to string
593
+ if (Array.isArray(path)) {
594
+ return getPropertyByPath(obj, path.join('.'), defaultValue);
595
+ }
592
596
  if (isNil(obj))
593
597
  return defaultValue;
594
598
  if (isNilOrBlank(path))
@@ -603,7 +607,8 @@
603
607
  var key = path.substring(0, i);
604
608
  if (isNil(obj[key]))
605
609
  return defaultValue;
606
- if (obj[key] && typeof obj[key] === 'object') {
610
+ if (typeof obj[key] === 'object') { // Object or Array
611
+ // Recursive call
607
612
  return getPropertyByPath(obj[key], path.substring(i + 1));
608
613
  }
609
614
  throw new Error("Invalid property path: '" + key + "' is not an valid object.");
@@ -615,7 +620,7 @@
615
620
  }
616
621
  function getPropertyByPathAsString(obj, path) {
617
622
  var res = getPropertyByPath(obj, path);
618
- return res && (typeof res === 'string' ? res : ('' + res));
623
+ return (typeof res === 'string') ? res : ('' + res);
619
624
  }
620
625
  function sleep(ms) {
621
626
  if (ms <= 0)
@@ -3096,10 +3101,18 @@
3096
3101
  var ArrayPluckPipe = /** @class */ (function () {
3097
3102
  function ArrayPluckPipe() {
3098
3103
  }
3099
- ArrayPluckPipe.prototype.transform = function (val, opts) {
3100
- return (opts.omitNil !== true) ?
3101
- (val || []).map(function (value) { return value && value[opts.property]; }) :
3102
- (val || []).map(function (value) { return value && value[opts.property]; }).filter(isNotNil);
3104
+ /**
3105
+ *
3106
+ * @param values
3107
+ * @param opts property to get, or options
3108
+ */
3109
+ ArrayPluckPipe.prototype.transform = function (values, opts) {
3110
+ if (!opts || !values)
3111
+ return values;
3112
+ var property = (typeof opts === 'string') || Array.isArray(opts) ? opts : opts.property;
3113
+ return (opts['omitNil'] !== true) ?
3114
+ values.map(function (value) { return getPropertyByPath(value, property); }) :
3115
+ values.map(function (value) { return getPropertyByPath(value, property); }).filter(isNotNil);
3103
3116
  };
3104
3117
  return ArrayPluckPipe;
3105
3118
  }());
@@ -3134,6 +3147,19 @@
3134
3147
  name: 'arrayFilter'
3135
3148
  },] }
3136
3149
  ];
3150
+ var ArrayJoinPipe = /** @class */ (function () {
3151
+ function ArrayJoinPipe() {
3152
+ }
3153
+ ArrayJoinPipe.prototype.transform = function (val, separator) {
3154
+ return val && val.join(separator) || '';
3155
+ };
3156
+ return ArrayJoinPipe;
3157
+ }());
3158
+ ArrayJoinPipe.decorators = [
3159
+ { type: i0.Pipe, args: [{
3160
+ name: 'arrayJoin'
3161
+ },] }
3162
+ ];
3137
3163
 
3138
3164
  var MapGetPipe = /** @class */ (function () {
3139
3165
  function MapGetPipe() {
@@ -5043,6 +5069,7 @@
5043
5069
  ArrayPluckPipe,
5044
5070
  ArrayIncludesPipe,
5045
5071
  ArrayFilterPipe,
5072
+ ArrayJoinPipe,
5046
5073
  MapGetPipe,
5047
5074
  MapKeysPipe,
5048
5075
  MapValuesPipe,
@@ -5083,6 +5110,7 @@
5083
5110
  ArrayLengthPipe,
5084
5111
  ArrayFirstPipe,
5085
5112
  ArrayPluckPipe,
5113
+ ArrayJoinPipe,
5086
5114
  MapGetPipe,
5087
5115
  MapKeysPipe,
5088
5116
  MapValuesPipe,
@@ -28430,11 +28458,12 @@
28430
28458
  this.translate = translate;
28431
28459
  this._subscription = new rxjs.Subscription();
28432
28460
  this._enabled = false;
28433
- this._dirty = false;
28434
28461
  this.destroySubject = new rxjs.Subject();
28435
28462
  this.readySubject = new rxjs.BehaviorSubject(false);
28463
+ this.dirtySubject = new rxjs.BehaviorSubject(false);
28436
28464
  this.loadingSubject = new rxjs.BehaviorSubject(true);
28437
28465
  this.errorSubject = new rxjs.BehaviorSubject(undefined);
28466
+ this.savingSubject = new rxjs.BehaviorSubject(false);
28438
28467
  this.debug = false;
28439
28468
  this.submitted = false;
28440
28469
  this.toolbar = null;
@@ -28486,6 +28515,14 @@
28486
28515
  enumerable: false,
28487
28516
  configurable: true
28488
28517
  });
28518
+ Object.defineProperty(AppEditor.prototype, "saving", {
28519
+ get: function () {
28520
+ var _a;
28521
+ return this.savingSubject.value || ((_a = this.editors) === null || _a === void 0 ? void 0 : _a.some(function (e) { return e.saving; }));
28522
+ },
28523
+ enumerable: false,
28524
+ configurable: true
28525
+ });
28489
28526
  Object.defineProperty(AppEditor.prototype, "tables", {
28490
28527
  get: function () {
28491
28528
  return this._children && this._children.filter(function (c) { return c instanceof AppTable; });
@@ -28509,7 +28546,7 @@
28509
28546
  });
28510
28547
  Object.defineProperty(AppEditor.prototype, "dirty", {
28511
28548
  get: function () {
28512
- return this._dirty || (this._children && this._children.findIndex(function (c) { return c.enabled && c.dirty; }) !== -1) || false;
28549
+ return this.dirtySubject.value || (this._children && this._children.findIndex(function (c) { return c.enabled && c.dirty; }) !== -1) || false;
28513
28550
  },
28514
28551
  enumerable: false,
28515
28552
  configurable: true
@@ -28569,7 +28606,7 @@
28569
28606
  });
28570
28607
  Object.defineProperty(AppEditor.prototype, "empty", {
28571
28608
  get: function () {
28572
- return this._enabled;
28609
+ return !this._enabled;
28573
28610
  },
28574
28611
  enumerable: false,
28575
28612
  configurable: true
@@ -28634,7 +28671,9 @@
28634
28671
  var _a;
28635
28672
  this.error = null;
28636
28673
  this.submitted = false;
28637
- this._dirty = false;
28674
+ if (this.dirtySubject.value !== false) {
28675
+ this.dirtySubject.next(false);
28676
+ }
28638
28677
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return c.markAsPristine(opts); });
28639
28678
  if (!this.loading && (!opts || opts.emitEvent !== false))
28640
28679
  this.markForCheck();
@@ -28662,9 +28701,11 @@
28662
28701
  this.markForCheck();
28663
28702
  };
28664
28703
  AppEditor.prototype.markAsDirty = function (opts) {
28665
- this._dirty = true;
28666
- if (!this.loading && (!opts || opts.emitEvent !== false))
28667
- this.markForCheck();
28704
+ if (!this.dirtySubject.value) {
28705
+ this.dirtySubject.next(true);
28706
+ if (!this.loading && (!opts || opts.emitEvent !== false))
28707
+ this.markForCheck();
28708
+ }
28668
28709
  };
28669
28710
  AppEditor.prototype.markAsLoading = function (opts) {
28670
28711
  if (!this.loadingSubject.value) {
@@ -28703,6 +28744,20 @@
28703
28744
  return Promise.resolve();
28704
28745
  return waitForFalse(this.loadingSubject, opts);
28705
28746
  };
28747
+ AppEditor.prototype.markAsSaving = function (opts) {
28748
+ if (this.savingSubject.value !== true) {
28749
+ this.savingSubject.next(true);
28750
+ if (!opts || opts.emitEvent !== false)
28751
+ this.markForCheck();
28752
+ }
28753
+ };
28754
+ AppEditor.prototype.markAsSaved = function (opts) {
28755
+ if (this.savingSubject.value !== false) {
28756
+ this.savingSubject.next(false);
28757
+ if (!opts || opts.emitEvent !== false)
28758
+ this.markForCheck();
28759
+ }
28760
+ };
28706
28761
  AppEditor.prototype.cancel = function (event) {
28707
28762
  return __awaiter(this, void 0, void 0, function () {
28708
28763
  return __generator(this, function (_c) {
@@ -28733,7 +28788,7 @@
28733
28788
  var _a;
28734
28789
  return __awaiter(this, void 0, void 0, function () {
28735
28790
  return __generator(this, function (_c) {
28736
- console.debug('[tab-page] Unloading data...');
28791
+ console.debug('[editor] Unloading data...');
28737
28792
  this.markAsLoading();
28738
28793
  (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
28739
28794
  if (f instanceof AppForm) {
@@ -28742,7 +28797,12 @@
28742
28797
  else if (f instanceof AppTable) {
28743
28798
  f.dataSource.disconnect();
28744
28799
  }
28800
+ else if (f instanceof AppEditor) {
28801
+ f.unload(opts);
28802
+ }
28745
28803
  });
28804
+ this.markAsPristine(opts);
28805
+ this.markAsSaved(opts);
28746
28806
  return [2 /*return*/];
28747
28807
  });
28748
28808
  });
@@ -28811,12 +28871,12 @@
28811
28871
  });
28812
28872
  });
28813
28873
  };
28814
- AppEditor.prototype.logFormErrors = function () {
28874
+ AppEditor.prototype.logFormErrors = function (prefix) {
28815
28875
  var _this = this;
28816
28876
  var _a;
28817
28877
  if (this.debug)
28818
- console.debug('[app-tab-editor] Page not valid. Checking where (forms, tables)...');
28819
- (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return _this.logChildrenFormErrors(c); });
28878
+ console.debug('[editor] Editor not valid. Checking where (forms, tables)...');
28879
+ (_a = this._children) === null || _a === void 0 ? void 0 : _a.forEach(function (c) { return _this.logChildrenErrors(c, prefix); });
28820
28880
  };
28821
28881
  /* -- protected methods -- */
28822
28882
  AppEditor.prototype.scrollToTop = function (duration) {
@@ -28918,7 +28978,7 @@
28918
28978
  });
28919
28979
  });
28920
28980
  };
28921
- AppEditor.prototype.logChildrenFormErrors = function (c, prefix, path) {
28981
+ AppEditor.prototype.logChildrenErrors = function (c, prefix, path) {
28922
28982
  var _this = this;
28923
28983
  prefix = prefix || '[app-tab-editor] ';
28924
28984
  // If editor
@@ -28932,7 +28992,7 @@
28932
28992
  // If form provider: get delegate
28933
28993
  else if (c instanceof AppFormProvider) {
28934
28994
  if (!c.empty && !c.valid) {
28935
- c.waitDelegate({ timeout: 1000 }).then(function (delegate) { return _this.logChildrenFormErrors(delegate, prefix, 'provider'); });
28995
+ c.waitDelegate({ timeout: 1000 }).then(function (delegate) { return _this.logChildrenErrors(delegate, prefix, 'provider'); });
28936
28996
  }
28937
28997
  }
28938
28998
  // If table
@@ -28942,20 +29002,34 @@
28942
29002
  AppFormUtils.logFormErrors(c.editedRow.validator, prefix, path_1);
28943
29003
  }
28944
29004
  }
28945
- // If IAppForm
29005
+ // If form
28946
29006
  else if (c instanceof AppForm) {
28947
29007
  if (!c.empty && !c.valid) {
28948
29008
  if (c.pending) {
28949
29009
  var path_2 = c.constructor.name.toLowerCase();
28950
29010
  console.warn(prefix + " -> " + path_2 + ": waiting while pending...");
28951
29011
  AppFormUtils.waitWhilePending(c, { timeout: 1000 })
28952
- .then(function () { return _this.logChildrenFormErrors(c.form, prefix, path_2); });
29012
+ .then(function () { return _this.logChildrenErrors(c.form, prefix, path_2); });
28953
29013
  }
28954
29014
  else {
28955
29015
  AppFormUtils.logFormErrors(c.form, prefix);
28956
29016
  }
28957
29017
  }
28958
29018
  }
29019
+ // If editor
29020
+ else if (c instanceof AppEditor) {
29021
+ if (!c.empty && !c.valid) {
29022
+ if (c.pending) {
29023
+ var path_3 = c.constructor.name.toLowerCase();
29024
+ console.warn(prefix + " -> " + path_3 + ": waiting while pending...");
29025
+ AppFormUtils.waitWhilePending(c, { timeout: 1000 })
29026
+ .then(function () { return c.logFormErrors(prefix); });
29027
+ }
29028
+ else {
29029
+ c.logFormErrors(prefix);
29030
+ }
29031
+ }
29032
+ }
28959
29033
  else {
28960
29034
  console.warn(prefix + " Unknown children sub-form: ", c);
28961
29035
  }
@@ -29182,24 +29256,23 @@
29182
29256
  tabGroup: [{ type: i0.ViewChild, args: ['tabGroup', { static: true },] }]
29183
29257
  };
29184
29258
 
29185
- var AppEditorOptions = /** @class */ (function (_super) {
29186
- __extends(AppEditorOptions, _super);
29259
+ var AppEditorOptions = /** @class */ (function (_super_1) {
29260
+ __extends(AppEditorOptions, _super_1);
29187
29261
  function AppEditorOptions() {
29188
- return _super !== null && _super.apply(this, arguments) || this;
29262
+ return _super_1 !== null && _super_1.apply(this, arguments) || this;
29189
29263
  }
29190
29264
  return AppEditorOptions;
29191
29265
  }(AppTabEditorOptions));
29192
29266
  // @dynamic
29193
29267
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
29194
- var AppEntityEditor = /** @class */ (function (_super) {
29195
- __extends(AppEntityEditor, _super);
29268
+ var AppEntityEditor = /** @class */ (function (_super_1) {
29269
+ __extends(AppEntityEditor, _super_1);
29196
29270
  function AppEntityEditor(injector, dataType, dataService, options) {
29197
29271
  var _this = this;
29198
29272
  var _a, _b;
29199
- _this = _super.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
29273
+ _this = _super_1.call(this, injector.get(i3.ActivatedRoute), injector.get(i3.Router), injector.get(i1$5.AlertController), injector.get(i1$2.TranslateService), options) || this;
29200
29274
  _this.dataType = dataType;
29201
29275
  _this.dataService = dataService;
29202
- _this.savingSubject = new rxjs.BehaviorSubject(false);
29203
29276
  _this.$title = new rxjs.Subject();
29204
29277
  _this.onUpdateView = new i0.EventEmitter();
29205
29278
  _this.environment = injector.get(ENVIRONMENT);
@@ -29255,20 +29328,6 @@
29255
29328
  enumerable: false,
29256
29329
  configurable: true
29257
29330
  });
29258
- Object.defineProperty(AppEntityEditor.prototype, "loading", {
29259
- get: function () {
29260
- return this.loadingSubject.value;
29261
- },
29262
- enumerable: false,
29263
- configurable: true
29264
- });
29265
- Object.defineProperty(AppEntityEditor.prototype, "saving", {
29266
- get: function () {
29267
- return this.savingSubject.value;
29268
- },
29269
- enumerable: false,
29270
- configurable: true
29271
- });
29272
29331
  Object.defineProperty(AppEntityEditor.prototype, "service", {
29273
29332
  get: function () {
29274
29333
  return this.dataService;
@@ -29276,22 +29335,8 @@
29276
29335
  enumerable: false,
29277
29336
  configurable: true
29278
29337
  });
29279
- AppEntityEditor.prototype.markAsSaving = function (opts) {
29280
- if (this.savingSubject.value !== true) {
29281
- this.savingSubject.next(true);
29282
- if (!opts || opts.emitEvent !== false)
29283
- this.markForCheck();
29284
- }
29285
- };
29286
- AppEntityEditor.prototype.markAsSaved = function (opts) {
29287
- if (this.savingSubject.value !== false) {
29288
- this.savingSubject.next(false);
29289
- if (!opts || opts.emitEvent !== false)
29290
- this.markForCheck();
29291
- }
29292
- };
29293
29338
  AppEntityEditor.prototype.ngOnInit = function () {
29294
- _super.prototype.ngOnInit.call(this);
29339
+ _super_1.prototype.ngOnInit.call(this);
29295
29340
  // Defaults
29296
29341
  this._autoOpenNextTab = toBoolean(this._autoOpenNextTab, !this.isOnFieldMode);
29297
29342
  this.historyIcon = this.historyIcon || { icon: 'list' };
@@ -29302,14 +29347,14 @@
29302
29347
  };
29303
29348
  AppEntityEditor.prototype.ngAfterViewInit = function () {
29304
29349
  var _this = this;
29305
- _super.prototype.ngAfterViewInit.call(this);
29350
+ _super_1.prototype.ngAfterViewInit.call(this);
29306
29351
  // Load data
29307
29352
  if (this._autoLoad) {
29308
29353
  setTimeout(function () { return _this.loadFromRoute(); }, this._autoLoadDelay);
29309
29354
  }
29310
29355
  };
29311
29356
  AppEntityEditor.prototype.ngOnDestroy = function () {
29312
- _super.prototype.ngOnDestroy.call(this);
29357
+ _super_1.prototype.ngOnDestroy.call(this);
29313
29358
  this._listenChangesSubscription = null; // already unsubscribe in the super function
29314
29359
  this.$title.complete();
29315
29360
  this.$title.unsubscribe();
@@ -29321,7 +29366,7 @@
29321
29366
  // Wait end of saving
29322
29367
  if (this.saving)
29323
29368
  return waitForFalse(this.savingSubject);
29324
- return _super.prototype.waitIdle.call(this, opts);
29369
+ return _super_1.prototype.waitIdle.call(this, opts);
29325
29370
  };
29326
29371
  /**
29327
29372
  * Load data from the snapshot route
@@ -29456,7 +29501,7 @@
29456
29501
  };
29457
29502
  AppEntityEditor.prototype.updateView = function (data, opts) {
29458
29503
  return __awaiter(this, void 0, void 0, function () {
29459
- var idChanged, promiseOrVoid;
29504
+ var idChanged;
29460
29505
  var _this = this;
29461
29506
  return __generator(this, function (_c) {
29462
29507
  switch (_c.label) {
@@ -29470,13 +29515,9 @@
29470
29515
  return [4 /*yield*/, this.ready()];
29471
29516
  case 1:
29472
29517
  _c.sent();
29473
- promiseOrVoid = this.setValue(data);
29474
- if (!promiseOrVoid) return [3 /*break*/, 3];
29475
- return [4 /*yield*/, promiseOrVoid];
29518
+ return [4 /*yield*/, this.setValue(data)];
29476
29519
  case 2:
29477
29520
  _c.sent();
29478
- _c.label = 3;
29479
- case 3:
29480
29521
  if (!opts || opts.emitEvent !== false) {
29481
29522
  this.markAsPristine();
29482
29523
  this.markAsUntouched();
@@ -29800,16 +29841,22 @@
29800
29841
  });
29801
29842
  });
29802
29843
  };
29803
- AppEntityEditor.prototype.unload = function () {
29844
+ AppEntityEditor.prototype.unload = function (opts) {
29845
+ var _super = Object.create(null, {
29846
+ unload: { get: function () { return _super_1.prototype.unload; } }
29847
+ });
29804
29848
  return __awaiter(this, void 0, void 0, function () {
29805
29849
  return __generator(this, function (_c) {
29806
- this.stopListenRemoteChanges();
29807
- this.form.reset();
29808
- this.registerForms();
29809
- this._dirty = false;
29810
- this.data = null;
29811
- this.savingSubject.next(false);
29812
- return [2 /*return*/];
29850
+ switch (_c.label) {
29851
+ case 0: return [4 /*yield*/, _super.unload.call(this, opts)];
29852
+ case 1:
29853
+ _c.sent();
29854
+ this.stopListenRemoteChanges();
29855
+ this.form.reset();
29856
+ this.registerForms();
29857
+ this.data = null;
29858
+ return [2 /*return*/];
29859
+ }
29813
29860
  });
29814
29861
  });
29815
29862
  };
@@ -29833,15 +29880,15 @@
29833
29880
  });
29834
29881
  };
29835
29882
  AppEntityEditor.prototype.resetError = function (opts) {
29836
- _super.prototype.resetError.call(this, opts);
29883
+ _super_1.prototype.resetError.call(this, opts);
29837
29884
  };
29838
29885
  AppEntityEditor.prototype.setError = function (err, opts) {
29839
29886
  if (!err) {
29840
- _super.prototype.setError.call(this, undefined, opts);
29887
+ _super_1.prototype.setError.call(this, undefined, opts);
29841
29888
  }
29842
29889
  else if (typeof err === 'string') {
29843
29890
  console.error('[entity-editor] Error: ' + (err || ''));
29844
- _super.prototype.setError.call(this, err, opts);
29891
+ _super_1.prototype.setError.call(this, err, opts);
29845
29892
  }
29846
29893
  else {
29847
29894
  console.error('[entity-editor] Error: ' + err.message || '', err);
@@ -29856,7 +29903,7 @@
29856
29903
  userMessage += detailMessage.length < 70 ? detailMessage : detailMessage.substring(0, 67) + '...';
29857
29904
  userMessage += '</small>';
29858
29905
  }
29859
- _super.prototype.setError.call(this, userMessage, opts);
29906
+ _super_1.prototype.setError.call(this, userMessage, opts);
29860
29907
  }
29861
29908
  };
29862
29909
  /* -- protected methods -- */
@@ -35201,6 +35248,7 @@
35201
35248
  exports.ArrayFilterPipe = ArrayFilterPipe;
35202
35249
  exports.ArrayFirstPipe = ArrayFirstPipe;
35203
35250
  exports.ArrayIncludesPipe = ArrayIncludesPipe;
35251
+ exports.ArrayJoinPipe = ArrayJoinPipe;
35204
35252
  exports.ArrayLengthPipe = ArrayLengthPipe;
35205
35253
  exports.ArrayPluckPipe = ArrayPluckPipe;
35206
35254
  exports.AudioProvider = AudioProvider;