@sumaris-net/ngx-components 1.19.1 → 1.20.0-rc1

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.
Files changed (27) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +292 -155
  2. package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
  3. package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
  4. package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
  5. package/doc/changelog.md +7 -0
  6. package/esm2015/src/app/admin/users/list/users.js +5 -1
  7. package/esm2015/src/app/core/auth/form/form-auth.js +26 -20
  8. package/esm2015/src/app/core/core.module.js +3 -1
  9. package/esm2015/src/app/core/form/form.class.js +27 -7
  10. package/esm2015/src/app/core/services/base-entity-service.class.js +6 -6
  11. package/esm2015/src/app/core/services/model/entity.model.js +5 -1
  12. package/esm2015/src/app/core/table/entities-table-datasource.class.js +136 -99
  13. package/esm2015/src/app/core/table/memory-table.class.js +3 -3
  14. package/esm2015/src/app/core/table/table.class.js +4 -5
  15. package/esm2015/src/app/shared/platforms.js +3 -3
  16. package/esm2015/src/app/shared/validator/validators.js +2 -2
  17. package/fesm2015/sumaris-net.ngx-components.js +203 -133
  18. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  19. package/package.json +2 -2
  20. package/src/app/core/auth/form/form-auth.d.ts +1 -1
  21. package/src/app/core/form/form.class.d.ts +8 -1
  22. package/src/app/core/services/model/entity.model.d.ts +1 -0
  23. package/src/app/core/table/entities-table-datasource.class.d.ts +20 -26
  24. package/src/assets/i18n/en-US.json +21 -2
  25. package/src/assets/i18n/en.json +19 -1
  26. package/src/assets/i18n/fr.json +2 -2
  27. package/sumaris-net.ngx-components.metadata.json +1 -1
@@ -1357,13 +1357,13 @@
1357
1357
  var isIOS = function (win) { return testUserAgent(win, /iPhone|iPod/i) || isIpad(win); };
1358
1358
  var isAndroid = function (win) { return testUserAgent(win, /android|sink/i); };
1359
1359
  var isCordova = function (win) {
1360
- if (_cache.cordova === undefined) {
1360
+ if (_cache.cordova === null || _cache.cordova === undefined) {
1361
1361
  _cache.cordova = !!(win['cordova'] || win['phonegap'] || win['PhoneGap']);
1362
1362
  }
1363
1363
  return _cache.cordova;
1364
1364
  };
1365
1365
  var isMobile = function (win) {
1366
- if (_cache.mobile === undefined) {
1366
+ if (_cache.mobile === null || _cache.mobile === undefined) {
1367
1367
  _cache.mobile = isCordova(window)
1368
1368
  || isAndroid(win) || isIOS(window)
1369
1369
  || (isTouchUi(win) && !isWindows(win));
@@ -3363,7 +3363,7 @@
3363
3363
  function SharedValidators() {
3364
3364
  }
3365
3365
  SharedValidators.getDoubleRegexp = function (maxDecimals) {
3366
- if (isNil(maxDecimals))
3366
+ if (isNil(maxDecimals) || maxDecimals === -1)
3367
3367
  return this._REGEXP_CACHE.DOUBLE_BY_MAX_DECIMALS.NO_LIMIT;
3368
3368
  if (maxDecimals < 0)
3369
3369
  throw new Error("Invalid maxDecimals value: " + maxDecimals);
@@ -10919,6 +10919,10 @@
10919
10919
  return isNotNil(obj.__typename) && (typeof obj.fromObject === 'function') && (typeof obj.asObject === 'function');
10920
10920
  };
10921
10921
  // Check that the object has a NOT nil attribute (ID by default)
10922
+ EntityUtils.isNotEntity = function (obj) {
10923
+ return isNil(obj.__typename) || (typeof obj.fromObject !== 'function') || (typeof obj.asObject !== 'function');
10924
+ };
10925
+ // Check that the object has a NOT nil attribute (ID by default)
10922
10926
  EntityUtils.isNotEmpty = function (obj, checkedAttribute) {
10923
10927
  return !!obj && obj[checkedAttribute] !== null && obj[checkedAttribute] !== undefined;
10924
10928
  };
@@ -19663,12 +19667,41 @@
19663
19667
  AppForm.prototype.cancel = function () {
19664
19668
  this.onCancel.emit();
19665
19669
  };
19666
- AppForm.prototype.doSubmit = function (event) {
19667
- if (!this.form || !this.form.valid) {
19668
- this.markAllAsTouched({ emitEvent: true });
19669
- return;
19670
- }
19671
- this.onSubmit.emit(event);
19670
+ /**
19671
+ *
19672
+ * @param event
19673
+ * @param opts allow to skip validation check, using {checkValid: false}
19674
+ */
19675
+ AppForm.prototype.doSubmit = function (event, opts) {
19676
+ return __awaiter(this, void 0, void 0, function () {
19677
+ return __generator(this, function (_b) {
19678
+ switch (_b.label) {
19679
+ case 0:
19680
+ if (!this._form) {
19681
+ this.markAllAsTouched({ emitEvent: true });
19682
+ return [2 /*return*/];
19683
+ }
19684
+ if (!((!opts || opts.checkValid !== false) && !this._form.valid)) return [3 /*break*/, 2];
19685
+ // Wait validation end
19686
+ return [4 /*yield*/, AppFormUtils.waitWhilePending(this._form)];
19687
+ case 1:
19688
+ // Wait validation end
19689
+ _b.sent();
19690
+ // Form is invalid: exit (+ log if debug)
19691
+ if (this._form.invalid) {
19692
+ this.markAllAsTouched({ emitEvent: true });
19693
+ if (this.debug)
19694
+ AppFormUtils.logFormErrors(this._form);
19695
+ return [2 /*return*/];
19696
+ }
19697
+ _b.label = 2;
19698
+ case 2:
19699
+ // Emit event
19700
+ this.onSubmit.emit(event);
19701
+ return [2 /*return*/];
19702
+ }
19703
+ });
19704
+ });
19672
19705
  };
19673
19706
  AppForm.prototype.setForm = function (form) {
19674
19707
  var _this = this;
@@ -20953,25 +20986,41 @@
20953
20986
  this.onCancel.emit();
20954
20987
  };
20955
20988
  AuthForm.prototype.doSubmit = function (event) {
20956
- var _this = this;
20957
- if (event) {
20958
- event.preventDefault();
20959
- event.stopPropagation();
20960
- }
20961
- if (this.form.invalid || this.loading)
20962
- return;
20963
- this.markAsLoading();
20964
- var data = this.form.value;
20965
- this.showPwd = false; // Hide password
20966
- this.error = null; // Reset error
20967
- this.registerSubscription(this.onSubmit
20968
- .pipe(operators.debounceTime(500))
20969
- .subscribe(function (res) { return _this.markAsLoaded(); }));
20970
- setTimeout(function () { return _this.onSubmit.emit({
20971
- username: data.username,
20972
- password: data.password,
20973
- offline: data.offline
20974
- }); });
20989
+ return __awaiter(this, void 0, void 0, function () {
20990
+ var data;
20991
+ var _this = this;
20992
+ return __generator(this, function (_a) {
20993
+ switch (_a.label) {
20994
+ case 0:
20995
+ if (event) {
20996
+ event.preventDefault();
20997
+ event.stopPropagation();
20998
+ }
20999
+ if (this.loading)
21000
+ return [2 /*return*/];
21001
+ if (!!this.form.valid) return [3 /*break*/, 2];
21002
+ return [4 /*yield*/, AppFormUtils.waitWhilePending(this.form)];
21003
+ case 1:
21004
+ _a.sent();
21005
+ if (this.form.invalid) {
21006
+ AppFormUtils.logFormErrors(this.form);
21007
+ return [2 /*return*/]; // Skip if invalid
21008
+ }
21009
+ _a.label = 2;
21010
+ case 2:
21011
+ this.markAsLoading();
21012
+ data = this.form.value;
21013
+ this.showPwd = false; // Hide password
21014
+ this.error = null; // Reset error
21015
+ setTimeout(function () { return _this.onSubmit.emit({
21016
+ username: data.username,
21017
+ password: data.password,
21018
+ offline: data.offline
21019
+ }); });
21020
+ return [2 /*return*/];
21021
+ }
21022
+ });
21023
+ });
20975
21024
  };
20976
21025
  AuthForm.prototype.register = function () {
20977
21026
  var _this = this;
@@ -24176,6 +24225,7 @@
24176
24225
  ionicCache.CacheModule,
24177
24226
  i3$2.IonicStorageModule,
24178
24227
  ngxJdenticon.NgxJdenticonModule,
24228
+ i1$2.TranslateModule.forChild(),
24179
24229
  // Sub modules
24180
24230
  AppGraphQLModule,
24181
24231
  AppMenuModule
@@ -24431,7 +24481,7 @@
24431
24481
  };
24432
24482
  BaseEntityService.prototype.loadAll = function (offset, size, sortBy, sortDirection, filter, opts) {
24433
24483
  return __awaiter(this, void 0, void 0, function () {
24434
- var debug, variables, now, withTotal, query, _b, data, total, entities, res, nextOffset_1;
24484
+ var debug, variables, now, withTotal, query, _b, data, total, entities, result, nextOffset_1;
24435
24485
  var _this = this;
24436
24486
  return __generator(this, function (_c) {
24437
24487
  switch (_c.label) {
@@ -24465,18 +24515,18 @@
24465
24515
  (data || []);
24466
24516
  if (debug)
24467
24517
  console.debug(this._logPrefix + (this._logTypeName + " items loaded in " + (Date.now() - now) + "ms"));
24468
- res = {
24518
+ result = {
24469
24519
  data: entities,
24470
- total: total
24520
+ total: total || entities.length
24471
24521
  };
24472
24522
  // Add fetch more capability, if total was fetched
24473
24523
  if (withTotal) {
24474
24524
  nextOffset_1 = (offset || 0) + entities.length;
24475
- if (nextOffset_1 < res.total) {
24476
- res.fetchMore = function () { return _this.loadAll(nextOffset_1, size, sortBy, sortDirection, filter, opts); };
24525
+ if (nextOffset_1 < result.total) {
24526
+ result.fetchMore = function () { return _this.loadAll(nextOffset_1, size, sortBy, sortDirection, filter, opts); };
24477
24527
  }
24478
24528
  }
24479
- return [2 /*return*/, res];
24529
+ return [2 /*return*/, result];
24480
24530
  }
24481
24531
  });
24482
24532
  });
@@ -24861,11 +24911,6 @@
24861
24911
  return AppTableUtils;
24862
24912
  }());
24863
24913
 
24864
- var AppTableDataSourceOptions = /** @class */ (function () {
24865
- function AppTableDataSourceOptions() {
24866
- }
24867
- return AppTableDataSourceOptions;
24868
- }());
24869
24914
  // @dynamic
24870
24915
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
24871
24916
  var EntitiesTableDataSource = /** @class */ (function (_super_1) {
@@ -24875,40 +24920,29 @@
24875
24920
  *
24876
24921
  * @param dataService A service to load and save data
24877
24922
  * @param dataType Type of data contained by the Table. If not specified, then `data` with at least one element must be specified.
24878
- * @param environment
24879
24923
  * @param validatorService Service that create instances of the FormGroup used to validate row fields.
24880
24924
  * @param config Additional configuration for table.
24881
24925
  */
24882
24926
  function EntitiesTableDataSource(dataType, dataService, validatorService, config) {
24883
- var _this = _super_1.call(this, [], dataType, validatorService, config) || this;
24927
+ var _this = _super_1.call(this, [], dataType, validatorService, Object.assign({ dataServiceOptions: {}, debug: config && config.suppressErrors === false, keepOriginalDataAfterConfirm: false }, config)) || this;
24884
24928
  _this.dataService = dataService;
24885
24929
  _this._creating = false;
24886
24930
  _this._saving = false;
24887
- _this._useValidator = false;
24888
24931
  _this._stopWatching$ = new rxjs.Subject();
24889
24932
  _this._editingRowCount = 0;
24890
24933
  _this._fetchMoreFn = null;
24891
24934
  _this.loadingSubject = new rxjs.BehaviorSubject(undefined);
24892
- _this._options = Object.assign({ dataServiceOptions: {}, debug: config && config.suppressErrors === false, keepOriginalDataAfterConfirm: false }, config);
24893
- _this._useValidator = isNotNil(validatorService);
24894
24935
  _this._logTypeName = removeEnd((new dataType()).__typename || 'UnknownVO', 'VO');
24895
24936
  // For DEV ONLY
24896
- _this._debug = _this._options.debug === true;
24937
+ _this._debug = _this.config.debug === true;
24897
24938
  return _this;
24898
24939
  }
24899
24940
  Object.defineProperty(EntitiesTableDataSource.prototype, "serviceOptions", {
24900
24941
  get: function () {
24901
- return this._options.dataServiceOptions;
24942
+ return this.config.dataServiceOptions;
24902
24943
  },
24903
24944
  set: function (value) {
24904
- this._options.dataServiceOptions = value;
24905
- },
24906
- enumerable: false,
24907
- configurable: true
24908
- });
24909
- Object.defineProperty(EntitiesTableDataSource.prototype, "options", {
24910
- get: function () {
24911
- return this._options;
24945
+ this.config.dataServiceOptions = value;
24912
24946
  },
24913
24947
  enumerable: false,
24914
24948
  configurable: true
@@ -24927,12 +24961,11 @@
24927
24961
  enumerable: false,
24928
24962
  configurable: true
24929
24963
  });
24930
- EntitiesTableDataSource.prototype.ngOnDestroy = function () {
24964
+ EntitiesTableDataSource.prototype.disconnect = function (collectionViewer) {
24965
+ _super_1.prototype.disconnect.call(this, collectionViewer);
24931
24966
  this._stopWatching$.next();
24932
24967
  this._stopWatching$.complete();
24933
- this._stopWatching$.unsubscribe();
24934
24968
  this.loadingSubject.complete();
24935
- this.loadingSubject.unsubscribe();
24936
24969
  };
24937
24970
  EntitiesTableDataSource.prototype.watchAll = function (offset, size, sortBy, sortDirection, filter) {
24938
24971
  var _this = this;
@@ -24959,7 +24992,7 @@
24959
24992
  };
24960
24993
  EntitiesTableDataSource.prototype.save = function () {
24961
24994
  return __awaiter(this, void 0, void 0, function () {
24962
- var onlyDirtyRows, rows, invalidRows, data, dataToSave_1, error_1;
24995
+ var onlyDirtyRows, rows, confirmed, data, dataToSave_1, error_1;
24963
24996
  var _this = this;
24964
24997
  return __generator(this, function (_a) {
24965
24998
  switch (_a.label) {
@@ -24978,32 +25011,33 @@
24978
25011
  onlyDirtyRows = toBoolean(this.serviceOptions.saveOnlyDirtyRows, false);
24979
25012
  _a.label = 1;
24980
25013
  case 1:
24981
- _a.trys.push([1, 4, 5, 6]);
25014
+ _a.trys.push([1, 5, 6, 7]);
24982
25015
  if (this._debug)
24983
25016
  console.debug("[table-datasource] Saving " + this._logTypeName + " rows... {onlyDirty: " + onlyDirtyRows + "}");
24984
25017
  return [4 /*yield*/, this.getRows()];
24985
25018
  case 2:
24986
25019
  rows = _a.sent();
24987
- invalidRows = rows.filter(function (row) { return row.editing && !row.confirmEditCreate(); });
25020
+ return [4 /*yield*/, this.confirmRows(rows)];
25021
+ case 3:
25022
+ confirmed = _a.sent();
24988
25023
  // Cannot finish some rows: error
24989
- if (invalidRows.length) {
25024
+ if (!confirmed) {
24990
25025
  // log errors
24991
25026
  if (this._debug)
24992
- invalidRows.forEach(function (row) { return AppTableUtils.logRowErrors(row, "[table-datasource] " + _this._logTypeName + " row #" + row.id); });
25027
+ this.getEditingRows(rows).forEach(function (row) { return AppTableUtils.logRowErrors(row, "[table-datasource] " + _this._logTypeName + " row #" + row.id); });
24993
25028
  // Stop with an error
24994
25029
  throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
24995
25030
  }
24996
25031
  this._editingRowCount = 0;
24997
25032
  data = void 0;
24998
- if (this._useValidator) {
25033
+ if (!!this.validatorService) {
24999
25034
  dataToSave_1 = [];
25000
25035
  data = rows.map(function (row) {
25001
- var currentData = new _this.dataConstructor();
25002
- currentData.fromObject(row.currentData);
25036
+ var entity = _this.toEntity(row.currentData);
25003
25037
  // Filter to keep only dirty row
25004
25038
  if (onlyDirtyRows && row.validator.dirty)
25005
- dataToSave_1.push(currentData);
25006
- return currentData;
25039
+ dataToSave_1.push(entity);
25040
+ return entity;
25007
25041
  });
25008
25042
  if (!onlyDirtyRows)
25009
25043
  dataToSave_1 = data;
@@ -25023,46 +25057,65 @@
25023
25057
  if (this._debug)
25024
25058
  console.debug("[table-datasource] Asking service to save this " + this._logTypeName + " data:", dataToSave_1);
25025
25059
  return [4 /*yield*/, this.dataService.saveAll(dataToSave_1, this.serviceOptions)];
25026
- case 3:
25060
+ case 4:
25027
25061
  _a.sent();
25028
25062
  if (this._debug)
25029
25063
  console.debug("[table-datasource] Saving " + this._logTypeName + " data [OK]");
25030
25064
  // LP 23/03/2021: update datasource is necessary but can be changed to a refetch() on QueryRef (must be created and registered in GraphqlService.watchQuery)
25031
25065
  this.updateDatasource(data, { emitEvent: false });
25032
25066
  return [2 /*return*/, true];
25033
- case 4:
25067
+ case 5:
25034
25068
  error_1 = _a.sent();
25035
25069
  if (this._debug)
25036
25070
  console.error('[table-datasource] Error while saving: ' + error_1 && error_1.message || error_1);
25037
25071
  throw error_1;
25038
- case 5:
25072
+ case 6:
25039
25073
  this._saving = false;
25040
25074
  this.markAsLoaded();
25041
25075
  return [7 /*endfinally*/];
25042
- case 6: return [2 /*return*/];
25076
+ case 7: return [2 /*return*/];
25043
25077
  }
25044
25078
  });
25045
25079
  });
25046
25080
  };
25047
- EntitiesTableDataSource.prototype.updateDatasource = function (data, opts) {
25048
- if (this._debug)
25049
- console.debug("[table-datasource] Updating datasource with data:", data);
25050
- _super_1.prototype.updateDatasource.call(this, data, opts);
25051
- if (!opts || opts.emitEvent !== false) {
25052
- this.markAsLoaded();
25081
+ EntitiesTableDataSource.prototype.getDataFromRows = function (rows, options) {
25082
+ var _this = this;
25083
+ if (options === void 0) { options = { originalData: false, toEntity: false }; }
25084
+ if (options.toEntity) {
25085
+ return _super_1.prototype.getDataFromRows.call(this, rows, options)
25086
+ .map(function (data) { return _this.toEntity(data); });
25053
25087
  }
25088
+ return _super_1.prototype.getDataFromRows.call(this, rows, options);
25054
25089
  };
25055
- // Overwrite default signature
25056
- EntitiesTableDataSource.prototype.createNew = function (insertAt) {
25057
- this.asyncCreateNew(insertAt);
25058
- };
25059
- EntitiesTableDataSource.prototype.connect = function (collectionViewer) {
25060
- // DEBUG console.debug("[entities-datasource] connect");
25061
- return _super_1.prototype.connect.call(this, collectionViewer);
25090
+ EntitiesTableDataSource.prototype.toEntity = function (data) {
25091
+ if (EntityUtils.isNotEntity(data)) {
25092
+ var entity = new this.dataConstructor();
25093
+ entity.fromObject(data);
25094
+ return entity;
25095
+ }
25096
+ return data;
25062
25097
  };
25063
- EntitiesTableDataSource.prototype.disconnect = function (collectionViewer) {
25064
- _super_1.prototype.disconnect.call(this, collectionViewer);
25065
- this._stopWatching$.next();
25098
+ EntitiesTableDataSource.prototype.updateDatasource = function (data, opts) {
25099
+ if (opts === void 0) { opts = { emitEvent: true }; }
25100
+ var _super = Object.create(null, {
25101
+ updateDatasource: { get: function () { return _super_1.prototype.updateDatasource; } }
25102
+ });
25103
+ return __awaiter(this, void 0, void 0, function () {
25104
+ return __generator(this, function (_a) {
25105
+ switch (_a.label) {
25106
+ case 0:
25107
+ if (this._debug)
25108
+ console.debug("[table-datasource] Updating datasource with data:", data);
25109
+ return [4 /*yield*/, _super.updateDatasource.call(this, data, opts)];
25110
+ case 1:
25111
+ _a.sent();
25112
+ if (opts.emitEvent) {
25113
+ this.markAsLoaded();
25114
+ }
25115
+ return [2 /*return*/];
25116
+ }
25117
+ });
25118
+ });
25066
25119
  };
25067
25120
  EntitiesTableDataSource.prototype.waitIdle = function (debounceTimeMs) {
25068
25121
  return firstFalsePromise(this.loadingSubject
@@ -25071,34 +25124,88 @@
25071
25124
  ));
25072
25125
  };
25073
25126
  EntitiesTableDataSource.prototype.confirmCreate = function (row) {
25074
- if (!_super_1.prototype.confirmCreate.call(this, row))
25075
- return false;
25076
- if (row.editing && row.validator) {
25077
- console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
25078
- row.validator.disable({ onlySelf: true, emitEvent: false });
25079
- }
25080
- return true;
25127
+ var _super = Object.create(null, {
25128
+ confirmCreate: { get: function () { return _super_1.prototype.confirmCreate; } }
25129
+ });
25130
+ return __awaiter(this, void 0, void 0, function () {
25131
+ return __generator(this, function (_a) {
25132
+ switch (_a.label) {
25133
+ case 0: return [4 /*yield*/, _super.confirmCreate.call(this, row)];
25134
+ case 1:
25135
+ if (!(_a.sent()))
25136
+ return [2 /*return*/, false];
25137
+ if (row.editing && row.validator) {
25138
+ console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
25139
+ row.validator.disable({ onlySelf: true, emitEvent: false });
25140
+ }
25141
+ return [2 /*return*/, true];
25142
+ }
25143
+ });
25144
+ });
25081
25145
  };
25082
25146
  EntitiesTableDataSource.prototype.confirmEdit = function (row) {
25083
- if (!_super_1.prototype.confirmEdit.call(this, row))
25084
- return false;
25085
- if (row.editing && row.validator) {
25086
- console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
25087
- row.validator.disable({ onlySelf: true, emitEvent: false });
25088
- }
25089
- return true;
25147
+ var _super = Object.create(null, {
25148
+ confirmEdit: { get: function () { return _super_1.prototype.confirmEdit; } }
25149
+ });
25150
+ return __awaiter(this, void 0, void 0, function () {
25151
+ return __generator(this, function (_a) {
25152
+ switch (_a.label) {
25153
+ case 0: return [4 /*yield*/, _super.confirmEdit.call(this, row)];
25154
+ case 1:
25155
+ if (!(_a.sent()))
25156
+ return [2 /*return*/, false];
25157
+ if (row.editing && row.validator) {
25158
+ console.warn('[table-datasource] Row still has {editing: true} after confirmCreate()! Force editing to false');
25159
+ row.validator.disable({ onlySelf: true, emitEvent: false });
25160
+ }
25161
+ return [2 /*return*/, true];
25162
+ }
25163
+ });
25164
+ });
25090
25165
  };
25091
25166
  EntitiesTableDataSource.prototype.startEdit = function (row) {
25092
- if (this._debug)
25093
- console.debug('[table-datasource] Start to edit row', row);
25094
- row.startEdit();
25095
- this._editingRowCount++;
25167
+ var _super = Object.create(null, {
25168
+ startEdit: { get: function () { return _super_1.prototype.startEdit; } }
25169
+ });
25170
+ return __awaiter(this, void 0, void 0, function () {
25171
+ var done;
25172
+ return __generator(this, function (_a) {
25173
+ switch (_a.label) {
25174
+ case 0:
25175
+ if (row.editing)
25176
+ return [2 /*return*/]; // Already editing
25177
+ if (this._debug)
25178
+ console.debug('[table-datasource] Start to edit row', row);
25179
+ return [4 /*yield*/, _super.startEdit.call(this, row)];
25180
+ case 1:
25181
+ done = _a.sent();
25182
+ if (done)
25183
+ this._editingRowCount++;
25184
+ return [2 /*return*/, done];
25185
+ }
25186
+ });
25187
+ });
25096
25188
  };
25097
- EntitiesTableDataSource.prototype.cancelOrDelete = function (row) {
25098
- if (this._debug)
25099
- console.debug('[table-datasource] Cancelling or deleting row', row);
25100
- row.cancelOrDelete();
25101
- this._editingRowCount--;
25189
+ EntitiesTableDataSource.prototype.cancel = function (row) {
25190
+ var _super = Object.create(null, {
25191
+ cancel: { get: function () { return _super_1.prototype.cancel; } }
25192
+ });
25193
+ return __awaiter(this, void 0, void 0, function () {
25194
+ var done;
25195
+ return __generator(this, function (_a) {
25196
+ switch (_a.label) {
25197
+ case 0:
25198
+ if (this._debug)
25199
+ console.debug('[table-datasource] Cancelling row', row);
25200
+ return [4 /*yield*/, _super.cancel.call(this, row)];
25201
+ case 1:
25202
+ done = _a.sent();
25203
+ if (done)
25204
+ this._editingRowCount--;
25205
+ return [2 /*return*/, done];
25206
+ }
25207
+ });
25208
+ });
25102
25209
  };
25103
25210
  EntitiesTableDataSource.prototype.handleError = function (error, message) {
25104
25211
  var errorMsg = error && error.message || error;
@@ -25113,39 +25220,65 @@
25113
25220
  throw error;
25114
25221
  };
25115
25222
  EntitiesTableDataSource.prototype.delete = function (id) {
25116
- var _this = this;
25117
- // If new row: not need to propagate to the dataService
25118
- if (id === -1) {
25119
- return _super_1.prototype.delete.call(this, id);
25120
- }
25121
- var row = this.getRow(id);
25122
- if (!row) {
25123
- console.error("[table-datasource] Row to delete with id=" + id + " not found");
25124
- return;
25125
- }
25126
- this.loadingSubject.next(true);
25127
- this.dataService.deleteAll([row.currentData], this.serviceOptions)
25128
- .catch(function (err) { return _this.handleErrorPromise(err); })
25129
- .then(function () {
25130
- setTimeout(function () {
25131
- // make sure row has been deleted (because GrapQHl cache remove can failed)
25132
- var present = _this.getRow(id) === row;
25133
- if (present)
25134
- _super_1.prototype.delete.call(_this, id);
25135
- _this.loadingSubject.next(false);
25136
- }, 300);
25223
+ var _super = Object.create(null, {
25224
+ delete: { get: function () { return _super_1.prototype.delete; } }
25225
+ });
25226
+ return __awaiter(this, void 0, void 0, function () {
25227
+ var row, present, err_1;
25228
+ return __generator(this, function (_a) {
25229
+ switch (_a.label) {
25230
+ case 0:
25231
+ // If new row: not need to propagate to the dataService
25232
+ if (id === -1) {
25233
+ return [2 /*return*/, _super.delete.call(this, id)];
25234
+ }
25235
+ row = this.getRow(id);
25236
+ if (!row) {
25237
+ console.error("[table-datasource] Row to delete with id=" + id + " not found");
25238
+ return [2 /*return*/];
25239
+ }
25240
+ this.markAsLoading();
25241
+ _a.label = 1;
25242
+ case 1:
25243
+ _a.trys.push([1, 6, 7, 8]);
25244
+ return [4 /*yield*/, this.dataService.deleteAll([row.currentData], this.serviceOptions)];
25245
+ case 2:
25246
+ _a.sent();
25247
+ // Make sure row has been deleted (because GrapQHl cache remove can failed)
25248
+ return [4 /*yield*/, sleep(300)];
25249
+ case 3:
25250
+ // Make sure row has been deleted (because GrapQHl cache remove can failed)
25251
+ _a.sent();
25252
+ present = this.getRow(id) === row;
25253
+ if (!present) return [3 /*break*/, 5];
25254
+ console.warn('[table-datasource] Force deletion of 1 row (Is service applying deletion to observable ?)');
25255
+ return [4 /*yield*/, _super.delete.call(this, id)];
25256
+ case 4:
25257
+ _a.sent();
25258
+ _a.label = 5;
25259
+ case 5: return [3 /*break*/, 8];
25260
+ case 6:
25261
+ err_1 = _a.sent();
25262
+ this.handleErrorPromise(err_1);
25263
+ return [3 /*break*/, 8];
25264
+ case 7:
25265
+ this.markAsLoaded();
25266
+ return [7 /*endfinally*/];
25267
+ case 8: return [2 /*return*/];
25268
+ }
25269
+ });
25137
25270
  });
25138
25271
  };
25139
25272
  EntitiesTableDataSource.prototype.deleteAll = function (rows) {
25140
25273
  var _this = this;
25141
25274
  this.markAsLoading();
25142
- var data = rows.map(function (r) { return r.currentData; });
25275
+ var data = this.getDataFromRows(rows);
25143
25276
  var rowsById = rows.reduce(function (res, row) {
25144
25277
  res[row.id] = row;
25145
25278
  return res;
25146
25279
  }, {});
25147
25280
  var self = this;
25148
- var selfDelete = _super_1.prototype.delete;
25281
+ var inheritedDelete = _super_1.prototype.delete;
25149
25282
  return this.dataService.deleteAll(data, this.serviceOptions)
25150
25283
  .catch(function (err) { return _this.handleErrorPromise(err); })
25151
25284
  .then(function () {
@@ -25159,20 +25292,20 @@
25159
25292
  // Apply missing deletion
25160
25293
  if (isNotEmptyArray(rowNotDeleted)) {
25161
25294
  console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows (Is service applying deletion to observable ?)");
25162
- rowNotDeleted.forEach(function (r) { return selfDelete.call(self, r.id); });
25295
+ rowNotDeleted.forEach(function (r) { return inheritedDelete.call(self, r.id); });
25163
25296
  }
25164
25297
  _this.loadingSubject.next(false);
25165
25298
  });
25166
25299
  };
25167
25300
  EntitiesTableDataSource.prototype.getRows = function () {
25168
- return firstNotNilPromise(this.connect(null));
25301
+ return this.rowsSubject.toPromise();
25169
25302
  };
25170
25303
  EntitiesTableDataSource.prototype.asyncCreateNew = function (insertAt) {
25171
25304
  var _super = Object.create(null, {
25172
25305
  createNew: { get: function () { return _super_1.prototype.createNew; } }
25173
25306
  });
25174
25307
  return __awaiter(this, void 0, void 0, function () {
25175
- var row, res, err_1;
25308
+ var row, res, err_2;
25176
25309
  return __generator(this, function (_a) {
25177
25310
  switch (_a.label) {
25178
25311
  case 0:
@@ -25181,8 +25314,8 @@
25181
25314
  this._creating = true;
25182
25315
  _super.createNew.call(this, insertAt);
25183
25316
  row = this.getRow(-1);
25184
- if (!(row && this._options && this._options.onRowCreated)) return [3 /*break*/, 4];
25185
- res = this._options.onRowCreated(row);
25317
+ if (!(row && this.config.onRowCreated)) return [3 /*break*/, 4];
25318
+ res = this.config.onRowCreated(row);
25186
25319
  if (!(res instanceof Promise)) return [3 /*break*/, 4];
25187
25320
  _a.label = 1;
25188
25321
  case 1:
@@ -25192,8 +25325,8 @@
25192
25325
  _a.sent();
25193
25326
  return [3 /*break*/, 4];
25194
25327
  case 3:
25195
- err_1 = _a.sent();
25196
- console.error(err_1 && err_1.message || err_1, err_1);
25328
+ err_2 = _a.sent();
25329
+ console.error(err_2 && err_2.message || err_2, err_2);
25197
25330
  return [3 /*break*/, 4];
25198
25331
  case 4:
25199
25332
  this._editingRowCount++;
@@ -25221,19 +25354,19 @@
25221
25354
  updateDatasource: { get: function () { return _super_1.prototype.updateDatasource; } }
25222
25355
  });
25223
25356
  return __awaiter(this, void 0, void 0, function () {
25224
- var res, existingData;
25357
+ var fetchMoreFn, res, existingData;
25225
25358
  return __generator(this, function (_a) {
25226
25359
  switch (_a.label) {
25227
25360
  case 0:
25228
25361
  if (!this._fetchMoreFn)
25229
- return [2 /*return*/, false]; // Avoid multiple call
25362
+ return [2 /*return*/, false];
25230
25363
  if (this._editingRowCount > 0) {
25231
25364
  console.warn('Cannot fetch more because still editing row');
25232
25365
  return [2 /*return*/];
25233
25366
  }
25234
- // Fetch next page
25235
- this._fetchMoreFn = null; // Avoid multiple call
25236
- return [4 /*yield*/, this._fetchMoreFn()];
25367
+ fetchMoreFn = this._fetchMoreFn;
25368
+ this._fetchMoreFn = null;
25369
+ return [4 /*yield*/, fetchMoreFn()];
25237
25370
  case 1:
25238
25371
  res = _a.sent();
25239
25372
  // Skip if empty (no more data)
@@ -25242,8 +25375,10 @@
25242
25375
  return [4 /*yield*/, this.getData()];
25243
25376
  case 2:
25244
25377
  existingData = _a.sent();
25245
- _super.updateDatasource.call(this, existingData.concat.apply(existingData, __spread(res.data)), opts);
25246
- // Remember fetchMore
25378
+ return [4 /*yield*/, _super.updateDatasource.call(this, existingData.concat.apply(existingData, __spread(res.data)), opts)];
25379
+ case 3:
25380
+ _a.sent();
25381
+ // Store next fetchMore function
25247
25382
  this._fetchMoreFn = res.fetchMore;
25248
25383
  return [2 /*return*/, true];
25249
25384
  }
@@ -25269,8 +25404,8 @@
25269
25404
  EntitiesTableDataSource.ctorParameters = function () { return [
25270
25405
  { type: Function },
25271
25406
  { type: undefined },
25272
- { type: ngxMaterialTable.ValidatorService },
25273
- { type: AppTableDataSourceOptions }
25407
+ { type: undefined },
25408
+ { type: undefined }
25274
25409
  ]; };
25275
25410
 
25276
25411
  var SETTINGS_DISPLAY_COLUMNS = 'displayColumns';
@@ -25761,7 +25896,6 @@
25761
25896
  };
25762
25897
  AppTable.prototype.ngOnDestroy = function () {
25763
25898
  var _this = this;
25764
- var _a;
25765
25899
  this._subscription.unsubscribe();
25766
25900
  // Unsubscribe column value changes
25767
25901
  Object.keys(this._cellValueChangesDefs).forEach(function (col) { return _this.stopCellValueChanges(col, true); });
@@ -25786,7 +25920,6 @@
25786
25920
  this.onError.unsubscribe();
25787
25921
  this._destroy$.next();
25788
25922
  this._destroy$.unsubscribe();
25789
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
25790
25923
  };
25791
25924
  AppTable.prototype.updateView = function (res, opts) {
25792
25925
  return __awaiter(this, void 0, void 0, function () {
@@ -25831,7 +25964,7 @@
25831
25964
  this._dataSourceLoadingSubscription.unsubscribe();
25832
25965
  this._subscription.remove(this._dataSourceLoadingSubscription);
25833
25966
  }
25834
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
25967
+ (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.disconnect();
25835
25968
  this._dataSource = null;
25836
25969
  };
25837
25970
  AppTable.prototype.addColumnDef = function (column) {
@@ -26017,6 +26150,7 @@
26017
26150
  // Keep edited row id (should be done BEFORE confirmEditCreate() )
26018
26151
  this.previouslyEditedRowId = opts.keepEditing ? ((((_a = this.editedRow) === null || _a === void 0 ? void 0 : _a.editing) ? this.editedRow.id : undefined) || ((_b = this.singleSelectedRow) === null || _b === void 0 ? void 0 : _b.id)) : undefined;
26019
26152
  previouslyEditedData = opts.keepEditing ? (isNotNil(this.previouslyEditedRowId) && ((_c = this.editedRow) === null || _c === void 0 ? void 0 : _c.currentData) || ((_d = this.singleSelectedRow) === null || _d === void 0 ? void 0 : _d.currentData)) : undefined;
26153
+ // TODO: remove this, has it redundant with dataSource.confirmAllRows() called in dataSource.save()
26020
26154
  if (!this.confirmEditCreate()) {
26021
26155
  throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
26022
26156
  }
@@ -27031,7 +27165,7 @@
27031
27165
  return __generator(this, function (_e) {
27032
27166
  switch (_e.label) {
27033
27167
  case 0:
27034
- markRowAsPristine = ((_a = this.dataSource) === null || _a === void 0 ? void 0 : _a.options.keepOriginalDataAfterConfirm) === true;
27168
+ markRowAsPristine = ((_a = this.dataSource) === null || _a === void 0 ? void 0 : _a.config.keepOriginalDataAfterConfirm) === true;
27035
27169
  if (!markRowAsPristine) return [3 /*break*/, 2];
27036
27170
  (_b = row.validator) === null || _b === void 0 ? void 0 : _b.markAsPristine();
27037
27171
  if (!(!opts || opts.onlySelf !== true)) return [3 /*break*/, 2];
@@ -28774,7 +28908,7 @@
28774
28908
  { type: Function },
28775
28909
  { type: InMemoryEntitiesService },
28776
28910
  { type: ngxMaterialTable.ValidatorService },
28777
- { type: AppTableDataSourceOptions },
28911
+ { type: undefined },
28778
28912
  { type: undefined }
28779
28913
  ]; };
28780
28914
  AppInMemoryTable.propDecorators = {
@@ -30035,7 +30169,11 @@
30035
30169
  switch (authTokenType) {
30036
30170
  case "basic":
30037
30171
  _this.setShowColumn('pubkey', false, { emitEvent: false });
30172
+ _this.setShowColumn('username', true, { emitEvent: false });
30173
+ _this.setShowColumn('usernameExtranet', true, { emitEvent: false });
30174
+ break;
30038
30175
  case "basic-and-token":
30176
+ _this.setShowColumn('pubkey', true, { emitEvent: false });
30039
30177
  _this.setShowColumn('username', true, { emitEvent: false });
30040
30178
  _this.setShowColumn('usernameExtranet', true, { emitEvent: false });
30041
30179
  break;
@@ -31789,7 +31927,6 @@
31789
31927
  exports.AppTabEditor = AppTabEditor;
31790
31928
  exports.AppTabEditorOptions = AppTabEditorOptions;
31791
31929
  exports.AppTable = AppTable;
31792
- exports.AppTableDataSourceOptions = AppTableDataSourceOptions;
31793
31930
  exports.AppTableUtils = AppTableUtils;
31794
31931
  exports.AppValidatorService = AppValidatorService;
31795
31932
  exports.AppendToInputDirective = AppendToInputDirective;