@sumaris-net/ngx-components 1.19.2 → 1.20.0-rc2

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.
@@ -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
@@ -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,66 +25220,111 @@
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
- var _this = this;
25141
- this.markAsLoading();
25142
- var data = rows.map(function (r) { return r.currentData; });
25143
- var rowsById = rows.reduce(function (res, row) {
25144
- res[row.id] = row;
25145
- return res;
25146
- }, {});
25147
- var self = this;
25148
- var selfDelete = _super_1.prototype.delete;
25149
- return this.dataService.deleteAll(data, this.serviceOptions)
25150
- .catch(function (err) { return _this.handleErrorPromise(err); })
25151
- .then(function () {
25152
- // Workaround, to be sure all rows has been deleted
25153
- // Sometimes, the service miss deletion, or GrapQHl cache remove failed
25154
- var rowNotDeleted = Object.getOwnPropertyNames(rowsById).reduce(function (res, id) {
25155
- var row = rowsById[id];
25156
- var present = self.getRow(+id) === row;
25157
- return present ? res.concat(row) : res;
25158
- }, []).sort(function (a, b) { return a.id > b.id ? -1 : 1; });
25159
- // Apply missing deletion
25160
- if (isNotEmptyArray(rowNotDeleted)) {
25161
- 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); });
25163
- }
25164
- _this.loadingSubject.next(false);
25273
+ var _super = Object.create(null, {
25274
+ delete: { get: function () { return _super_1.prototype.delete; } }
25275
+ });
25276
+ return __awaiter(this, void 0, void 0, function () {
25277
+ var data, rowsById, self, rowNotDeleted, err_2;
25278
+ var _this = this;
25279
+ return __generator(this, function (_a) {
25280
+ switch (_a.label) {
25281
+ case 0:
25282
+ this.markAsLoading();
25283
+ data = this.getDataFromRows(rows);
25284
+ rowsById = rows.reduce(function (res, row) {
25285
+ res[row.id] = row;
25286
+ return res;
25287
+ }, {});
25288
+ self = this;
25289
+ _a.label = 1;
25290
+ case 1:
25291
+ _a.trys.push([1, 5, 6, 7]);
25292
+ return [4 /*yield*/, this.dataService.deleteAll(data, this.serviceOptions)];
25293
+ case 2:
25294
+ _a.sent();
25295
+ rowNotDeleted = Object.getOwnPropertyNames(rowsById).reduce(function (res, id) {
25296
+ var row = rowsById[id];
25297
+ var present = self.getRow(+id) === row;
25298
+ return present ? res.concat(row) : res;
25299
+ }, []).sort(function (a, b) { return a.id > b.id ? -1 : 1; });
25300
+ if (!isNotEmptyArray(rowNotDeleted)) return [3 /*break*/, 4];
25301
+ console.warn("[table-datasource] Force deletion of " + rowNotDeleted.length + " rows (Is service applying deletion to observable ?)");
25302
+ return [4 /*yield*/, Promise.all(rowNotDeleted.map(function (r) { return _super.delete.call(_this, r.id); }))];
25303
+ case 3:
25304
+ _a.sent();
25305
+ _a.label = 4;
25306
+ case 4: return [3 /*break*/, 7];
25307
+ case 5:
25308
+ err_2 = _a.sent();
25309
+ this.handleErrorPromise(err_2);
25310
+ return [3 /*break*/, 7];
25311
+ case 6:
25312
+ this.markAsLoaded();
25313
+ return [7 /*endfinally*/];
25314
+ case 7: return [2 /*return*/];
25315
+ }
25316
+ });
25165
25317
  });
25166
25318
  };
25167
25319
  EntitiesTableDataSource.prototype.getRows = function () {
25168
- return firstNotNilPromise(this.connect(null));
25320
+ return this.rowsSubject.toPromise();
25169
25321
  };
25170
25322
  EntitiesTableDataSource.prototype.asyncCreateNew = function (insertAt) {
25171
25323
  var _super = Object.create(null, {
25172
25324
  createNew: { get: function () { return _super_1.prototype.createNew; } }
25173
25325
  });
25174
25326
  return __awaiter(this, void 0, void 0, function () {
25175
- var row, res, err_1;
25327
+ var row, res, err_3;
25176
25328
  return __generator(this, function (_a) {
25177
25329
  switch (_a.label) {
25178
25330
  case 0:
@@ -25181,8 +25333,8 @@
25181
25333
  this._creating = true;
25182
25334
  _super.createNew.call(this, insertAt);
25183
25335
  row = this.getRow(-1);
25184
- if (!(row && this._options && this._options.onRowCreated)) return [3 /*break*/, 4];
25185
- res = this._options.onRowCreated(row);
25336
+ if (!(row && this.config.onRowCreated)) return [3 /*break*/, 4];
25337
+ res = this.config.onRowCreated(row);
25186
25338
  if (!(res instanceof Promise)) return [3 /*break*/, 4];
25187
25339
  _a.label = 1;
25188
25340
  case 1:
@@ -25192,8 +25344,8 @@
25192
25344
  _a.sent();
25193
25345
  return [3 /*break*/, 4];
25194
25346
  case 3:
25195
- err_1 = _a.sent();
25196
- console.error(err_1 && err_1.message || err_1, err_1);
25347
+ err_3 = _a.sent();
25348
+ console.error(err_3 && err_3.message || err_3, err_3);
25197
25349
  return [3 /*break*/, 4];
25198
25350
  case 4:
25199
25351
  this._editingRowCount++;
@@ -25221,19 +25373,19 @@
25221
25373
  updateDatasource: { get: function () { return _super_1.prototype.updateDatasource; } }
25222
25374
  });
25223
25375
  return __awaiter(this, void 0, void 0, function () {
25224
- var res, existingData;
25376
+ var fetchMoreFn, res, existingData;
25225
25377
  return __generator(this, function (_a) {
25226
25378
  switch (_a.label) {
25227
25379
  case 0:
25228
25380
  if (!this._fetchMoreFn)
25229
- return [2 /*return*/, false]; // Avoid multiple call
25381
+ return [2 /*return*/, false];
25230
25382
  if (this._editingRowCount > 0) {
25231
25383
  console.warn('Cannot fetch more because still editing row');
25232
25384
  return [2 /*return*/];
25233
25385
  }
25234
- // Fetch next page
25235
- this._fetchMoreFn = null; // Avoid multiple call
25236
- return [4 /*yield*/, this._fetchMoreFn()];
25386
+ fetchMoreFn = this._fetchMoreFn;
25387
+ this._fetchMoreFn = null;
25388
+ return [4 /*yield*/, fetchMoreFn()];
25237
25389
  case 1:
25238
25390
  res = _a.sent();
25239
25391
  // Skip if empty (no more data)
@@ -25242,8 +25394,10 @@
25242
25394
  return [4 /*yield*/, this.getData()];
25243
25395
  case 2:
25244
25396
  existingData = _a.sent();
25245
- _super.updateDatasource.call(this, existingData.concat.apply(existingData, __spread(res.data)), opts);
25246
- // Remember fetchMore
25397
+ return [4 /*yield*/, _super.updateDatasource.call(this, existingData.concat.apply(existingData, __spread(res.data)), opts)];
25398
+ case 3:
25399
+ _a.sent();
25400
+ // Store next fetchMore function
25247
25401
  this._fetchMoreFn = res.fetchMore;
25248
25402
  return [2 /*return*/, true];
25249
25403
  }
@@ -25269,8 +25423,8 @@
25269
25423
  EntitiesTableDataSource.ctorParameters = function () { return [
25270
25424
  { type: Function },
25271
25425
  { type: undefined },
25272
- { type: ngxMaterialTable.ValidatorService },
25273
- { type: AppTableDataSourceOptions }
25426
+ { type: undefined },
25427
+ { type: undefined }
25274
25428
  ]; };
25275
25429
 
25276
25430
  var SETTINGS_DISPLAY_COLUMNS = 'displayColumns';
@@ -25761,7 +25915,6 @@
25761
25915
  };
25762
25916
  AppTable.prototype.ngOnDestroy = function () {
25763
25917
  var _this = this;
25764
- var _a;
25765
25918
  this._subscription.unsubscribe();
25766
25919
  // Unsubscribe column value changes
25767
25920
  Object.keys(this._cellValueChangesDefs).forEach(function (col) { return _this.stopCellValueChanges(col, true); });
@@ -25786,7 +25939,6 @@
25786
25939
  this.onError.unsubscribe();
25787
25940
  this._destroy$.next();
25788
25941
  this._destroy$.unsubscribe();
25789
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
25790
25942
  };
25791
25943
  AppTable.prototype.updateView = function (res, opts) {
25792
25944
  return __awaiter(this, void 0, void 0, function () {
@@ -25831,7 +25983,7 @@
25831
25983
  this._dataSourceLoadingSubscription.unsubscribe();
25832
25984
  this._subscription.remove(this._dataSourceLoadingSubscription);
25833
25985
  }
25834
- (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.ngOnDestroy();
25986
+ (_a = this._dataSource) === null || _a === void 0 ? void 0 : _a.disconnect();
25835
25987
  this._dataSource = null;
25836
25988
  };
25837
25989
  AppTable.prototype.addColumnDef = function (column) {
@@ -26017,6 +26169,7 @@
26017
26169
  // Keep edited row id (should be done BEFORE confirmEditCreate() )
26018
26170
  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
26171
  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;
26172
+ // TODO: remove this, has it redundant with dataSource.confirmAllRows() called in dataSource.save()
26020
26173
  if (!this.confirmEditCreate()) {
26021
26174
  throw { code: ErrorCodes.TABLE_INVALID_ROW_ERROR, message: 'ERROR.TABLE_INVALID_ROW_ERROR' };
26022
26175
  }
@@ -27031,7 +27184,7 @@
27031
27184
  return __generator(this, function (_e) {
27032
27185
  switch (_e.label) {
27033
27186
  case 0:
27034
- markRowAsPristine = ((_a = this.dataSource) === null || _a === void 0 ? void 0 : _a.options.keepOriginalDataAfterConfirm) === true;
27187
+ markRowAsPristine = ((_a = this.dataSource) === null || _a === void 0 ? void 0 : _a.config.keepOriginalDataAfterConfirm) === true;
27035
27188
  if (!markRowAsPristine) return [3 /*break*/, 2];
27036
27189
  (_b = row.validator) === null || _b === void 0 ? void 0 : _b.markAsPristine();
27037
27190
  if (!(!opts || opts.onlySelf !== true)) return [3 /*break*/, 2];
@@ -28774,7 +28927,7 @@
28774
28927
  { type: Function },
28775
28928
  { type: InMemoryEntitiesService },
28776
28929
  { type: ngxMaterialTable.ValidatorService },
28777
- { type: AppTableDataSourceOptions },
28930
+ { type: undefined },
28778
28931
  { type: undefined }
28779
28932
  ]; };
28780
28933
  AppInMemoryTable.propDecorators = {
@@ -30035,7 +30188,11 @@
30035
30188
  switch (authTokenType) {
30036
30189
  case "basic":
30037
30190
  _this.setShowColumn('pubkey', false, { emitEvent: false });
30191
+ _this.setShowColumn('username', true, { emitEvent: false });
30192
+ _this.setShowColumn('usernameExtranet', true, { emitEvent: false });
30193
+ break;
30038
30194
  case "basic-and-token":
30195
+ _this.setShowColumn('pubkey', true, { emitEvent: false });
30039
30196
  _this.setShowColumn('username', true, { emitEvent: false });
30040
30197
  _this.setShowColumn('usernameExtranet', true, { emitEvent: false });
30041
30198
  break;
@@ -31789,7 +31946,6 @@
31789
31946
  exports.AppTabEditor = AppTabEditor;
31790
31947
  exports.AppTabEditorOptions = AppTabEditorOptions;
31791
31948
  exports.AppTable = AppTable;
31792
- exports.AppTableDataSourceOptions = AppTableDataSourceOptions;
31793
31949
  exports.AppTableUtils = AppTableUtils;
31794
31950
  exports.AppValidatorService = AppValidatorService;
31795
31951
  exports.AppendToInputDirective = AppendToInputDirective;