@sumaris-net/ngx-components 18.25.3 → 18.25.4

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.
@@ -42522,6 +42522,7 @@ class AppAsyncTable {
42522
42522
  previouslyEditedRowId;
42523
42523
  formErrorAdapter;
42524
42524
  destroySubject = new Subject();
42525
+ logPrefix = '[table]';
42525
42526
  excludesColumns = [];
42526
42527
  displayedColumns;
42527
42528
  errorTranslateOptions;
@@ -42887,7 +42888,7 @@ class AppAsyncTable {
42887
42888
  this.registerSubscription(this.onStartEditingRow
42888
42889
  .pipe(filter((row) => row?.validator && true), mergeMap((row) => row.validator.valueChanges.pipe(filter(() => row.validator.dirty), first(),
42889
42890
  // DEBUG
42890
- //tap(() => console.debug("Propagate row's dirty to table..."))
42891
+ // tap(() => console.debug(`${this.logPrefix} Propagate row's dirty to table...`))
42891
42892
  // Stop if next another row, or destroying
42892
42893
  takeUntil(this.onStartEditingRow), takeUntil(this.destroySubject))))
42893
42894
  .subscribe(() => this.markAsDirty()));
@@ -42901,14 +42902,14 @@ class AppAsyncTable {
42901
42902
  }
42902
42903
  if (!this._dataSource) {
42903
42904
  if (this.debug)
42904
- console.debug('[table] Skipping data load: no dataSource defined');
42905
+ console.debug(`${this.logPrefix} Skipping data load: no dataSource defined`);
42905
42906
  return of(undefined);
42906
42907
  }
42907
42908
  if (this.debug)
42908
- console.debug('[table] Calling dataSource.watchAll()...');
42909
+ console.debug(`${this.logPrefix} Calling dataSource.watchAll()...`);
42909
42910
  return this._dataSource.watchAll(this.pageOffset, this.pageSize, this.sortActive, this.sortDirection, this._filter).pipe(takeUntil(this.onRefresh), catchError((err) => {
42910
42911
  if (this.debug)
42911
- console.error(err);
42912
+ console.error(this.logPrefix, err);
42912
42913
  this.setError((err && err.message) || err);
42913
42914
  return of(undefined); // Continue
42914
42915
  }), tap$1((res) => this.updateView(res, opts)));
@@ -42924,7 +42925,7 @@ class AppAsyncTable {
42924
42925
  ngAfterViewInit() {
42925
42926
  // Detect when parent ngOnInit() not call
42926
42927
  if (this.debug && !this.displayedColumns)
42927
- console.warn(`[table] Missing 'displayedColumns'. Did you call parent ngOnInit() in component ${this.constructor.name} ?`);
42928
+ console.warn(`${this.logPrefix} Missing 'displayedColumns'. Did you call parent ngOnInit() in component ${this.constructor.name} ?`);
42928
42929
  // Start listening sort and paginator events
42929
42930
  // noinspection JSIgnoredPromiseFromCall
42930
42931
  this.listenSortAndPaginationEvents();
@@ -42964,10 +42965,10 @@ class AppAsyncTable {
42964
42965
  ? res.total
42965
42966
  : ((this.paginator && this.paginator.pageIndex * (this.paginator.pageSize || DEFAULT_PAGE_SIZE)) || 0) + this.visibleRowCount;
42966
42967
  if (this.debug)
42967
- console.debug(`[table] ${res.data.length} rows loaded`);
42968
+ console.debug(`${this.logPrefix} ${res.data.length} rows loaded`);
42968
42969
  }
42969
42970
  else {
42970
- //if (this.debug) console.debug('[table] NO rows loaded');
42971
+ // if (this.debug) console.debug(`${this.logPrefix} NO rows loaded`);
42971
42972
  this.totalRowCount = 0;
42972
42973
  this.visibleRowCount = 0;
42973
42974
  }
@@ -42980,7 +42981,7 @@ class AppAsyncTable {
42980
42981
  }
42981
42982
  setDatasource(datasource) {
42982
42983
  if (this._dataSource)
42983
- throw new Error('[table] dataSource already set !');
42984
+ throw new Error(`${this.logPrefix} dataSource already set !`);
42984
42985
  if (datasource && this._dataSource !== datasource) {
42985
42986
  this._dataSource = datasource;
42986
42987
  if (this._initialized)
@@ -43129,8 +43130,8 @@ class AppAsyncTable {
43129
43130
  if (row.validator) {
43130
43131
  // NOT confirmed = row has error
43131
43132
  if (this.debug) {
43132
- console.warn('[table] Cannot confirm row, because invalid');
43133
- AppFormUtils.logFormErrors(row.validator, '[table] ');
43133
+ console.warn(`${this.logPrefix} Cannot confirm row, because invalid`);
43134
+ AppFormUtils.logFormErrors(row.validator, this.logPrefix);
43134
43135
  }
43135
43136
  // fix: mark all controls as touched to show errors
43136
43137
  row.validator.markAllAsTouched();
@@ -43159,7 +43160,7 @@ class AppAsyncTable {
43159
43160
  }
43160
43161
  async addRow(event, insertAt, opts) {
43161
43162
  if (this.debug)
43162
- console.debug('[table] Asking for new row...');
43163
+ console.debug(`${this.logPrefix} Asking for new row...`);
43163
43164
  if (!this._enabled)
43164
43165
  return false;
43165
43166
  // Use modal if inline edition is disabled
@@ -43199,7 +43200,7 @@ class AppAsyncTable {
43199
43200
  try {
43200
43201
  // Calling service save()
43201
43202
  if (this.debug)
43202
- console.debug('[table] Calling dataSource.save()...');
43203
+ console.debug(`${this.logPrefix} Calling dataSource.save()...`);
43203
43204
  const isOK = await this._dataSource.save();
43204
43205
  if (isOK)
43205
43206
  this.markAsPristine();
@@ -43328,7 +43329,7 @@ class AppAsyncTable {
43328
43329
  if (!this._enabled || isEmptyArray(rows))
43329
43330
  return 0; // Skip is disabled, or no rows to delete
43330
43331
  if (this.loading && (!opts || opts.interactive !== false)) {
43331
- console.warn('[app-table] Skip deleteRows() because table is busy (loading). Use opts.interactive = false to force deletion');
43332
+ console.warn(`${this.logPrefix} Skip deleteRows() because table is busy (loading). Use opts.interactive = false to force deletion`);
43332
43333
  return 0; // Skip if loading
43333
43334
  }
43334
43335
  // Make sure to keep newly created row
@@ -43356,7 +43357,7 @@ class AppAsyncTable {
43356
43357
  // - or if invalid and not editing (= not cancellable)
43357
43358
  if (row.id === -1 || (!row.editing && row.invalid) /*do not use !valid because if row is disabled, it will be always !valid */) {
43358
43359
  if (this.debug)
43359
- console.debug(`[table] Delete row #${row.id}`);
43360
+ console.debug(`${this.logPrefix} Delete row #${row.id}`);
43360
43361
  this.selection.deselect(row);
43361
43362
  row.delete();
43362
43363
  this.visibleRowCount--;
@@ -43390,7 +43391,7 @@ class AppAsyncTable {
43390
43391
  // If no more rows to delete, continue anyway to clear editedRow and selection (issue IMAGINE-669)
43391
43392
  if (tempRows.length) {
43392
43393
  if (this.debug)
43393
- console.debug(`[table] Delete ${tempRows.length} rows...`);
43394
+ console.debug(`${this.logPrefix} Delete ${tempRows.length} rows...`);
43394
43395
  await this._dataSource.deleteAll(tempRows);
43395
43396
  }
43396
43397
  // DO not update manually, because watchALl().subscribe() will update this count
@@ -43441,15 +43442,15 @@ class AppAsyncTable {
43441
43442
  if (this.loading) {
43442
43443
  // Wait while loading, and loop
43443
43444
  if (this.debug)
43444
- console.debug('[table] Waiting before apply clickRow() (datasource is busy)...');
43445
+ console.debug(`${this.logPrefix} Waiting before apply clickRow() (datasource is busy)...`);
43445
43446
  await this.waitIdle({ timeout: 2000 });
43446
43447
  }
43447
43448
  // DEBUG
43448
- //console.debug("[table] Detect click on row");
43449
+ // console.debug(`${this.logPrefix} Detect click on row`);
43449
43450
  // Cancelled by event
43450
43451
  if (event?.defaultPrevented) {
43451
43452
  if (this.debug)
43452
- console.debug('[table] clickRow event is defaultPrevented');
43453
+ console.debug(`${this.logPrefix} clickRow event is defaultPrevented`);
43453
43454
  return false;
43454
43455
  }
43455
43456
  // Call onClickRow if observed
@@ -43468,7 +43469,7 @@ class AppAsyncTable {
43468
43469
  this._openingRow = true; // Prevent double click
43469
43470
  this.markAsLoading();
43470
43471
  this.openRow(row.currentData.id, row)
43471
- .catch((err) => console.error('Failed to open row', err)) // Continue
43472
+ .catch((err) => console.error(`${this.logPrefix} Failed to open row`, err)) // Continue
43472
43473
  .then(() => {
43473
43474
  this.markAsLoaded();
43474
43475
  // Prevent double click (use an open throttle time)
@@ -43550,7 +43551,7 @@ class AppAsyncTable {
43550
43551
  if (!row || !row.editing)
43551
43552
  return;
43552
43553
  // DEBUG
43553
- //console.debug('[app-table] Cancel the row (keydown.escape)');
43554
+ // console.debug(`${this.logPrefix} Cancel the row (keydown.escape)`);
43554
43555
  if (event) {
43555
43556
  // Avoid to cancel the editor
43556
43557
  event.preventDefault();
@@ -43622,20 +43623,20 @@ class AppAsyncTable {
43622
43623
  done = await this.selectRowById(id);
43623
43624
  if (done)
43624
43625
  return true;
43625
- console.warn('[app-table] Save: Cannot reselect row by row.id: ', id);
43626
+ console.warn(`${this.logPrefix} Save: Cannot reselect row by row.id: `, id);
43626
43627
  }
43627
43628
  // Try by data
43628
43629
  if (data) {
43629
43630
  done = await this.selectRowByData(data);
43630
43631
  if (done)
43631
43632
  return true;
43632
- console.warn('[app-table] Save: Cannot reselect row by data: ', data);
43633
+ console.warn(`${this.logPrefix} Save: Cannot reselect row by data: `, data);
43633
43634
  }
43634
43635
  return false;
43635
43636
  }
43636
43637
  catch (err) {
43637
43638
  // Log, but continue
43638
- console.error((err && err.message) || err);
43639
+ console.error(`${this.logPrefix} Save error: `, (err && err.message) || err);
43639
43640
  return false;
43640
43641
  }
43641
43642
  }
@@ -43658,7 +43659,7 @@ class AppAsyncTable {
43658
43659
  catch (err) {
43659
43660
  if (err === 'CANCELLED')
43660
43661
  return false; // User cancel
43661
- console.error('Error while checking if can delete rows', err);
43662
+ console.error(`${this.logPrefix} Error while checking if can delete rows`, err);
43662
43663
  throw err;
43663
43664
  }
43664
43665
  }
@@ -43685,7 +43686,7 @@ class AppAsyncTable {
43685
43686
  catch (err) {
43686
43687
  if (err === 'CANCELLED')
43687
43688
  return false; // User cancel
43688
- console.error('Error while checking if can cancel rows', err);
43689
+ console.error(`${this.logPrefix} Error while checking if can cancel rows`, err);
43689
43690
  throw err;
43690
43691
  }
43691
43692
  }
@@ -43729,7 +43730,7 @@ class AppAsyncTable {
43729
43730
  catch (err) {
43730
43731
  if (err === 'CANCELLED')
43731
43732
  return false; // User cancel
43732
- console.error('Error while checking if can delete rows', err);
43733
+ console.error(`${this.logPrefix} Error while checking if can delete rows`, err);
43733
43734
  throw err;
43734
43735
  }
43735
43736
  }
@@ -43756,7 +43757,7 @@ class AppAsyncTable {
43756
43757
  async openRow(id, row) {
43757
43758
  if (this.allowRowDetail) {
43758
43759
  if (this.debug && this.dirty) {
43759
- console.warn('[table] Opening row details, but table has unsaved changes!');
43760
+ console.warn(`${this.logPrefix} Opening row details, but table has unsaved changes!`);
43760
43761
  }
43761
43762
  if (this.onOpenRow.observed) {
43762
43763
  // Clear selection (because next route can change the current table content)
@@ -43766,7 +43767,7 @@ class AppAsyncTable {
43766
43767
  }
43767
43768
  // No ID defined: unable to open details
43768
43769
  if (isNil(id)) {
43769
- console.warn('[table] Opening row details, but data has no id!');
43770
+ console.warn(`${this.logPrefix} Opening row details, but data has no id!`);
43770
43771
  return false;
43771
43772
  }
43772
43773
  // Clear selection (because next route can change the current table content)
@@ -43867,13 +43868,13 @@ class AppAsyncTable {
43867
43868
  .replace(/\/\d+/g, '_id') +
43868
43869
  '_' +
43869
43870
  componentId;
43870
- //if (this.debug) console.debug('[table] id = ' + id);
43871
+ // if (this.debug) console.debug(`${this.logPrefix} id = ` + id);
43871
43872
  return id;
43872
43873
  }
43873
43874
  async addRowToTable(insertAt, opts) {
43874
43875
  // Try to finish edited row first
43875
43876
  if (!(await this.confirmEditCreate())) {
43876
- console.warn('[table] Cannot add new row, because the previous edited row cannot be confirmed');
43877
+ console.warn(`${this.logPrefix} Cannot add new row, because the previous edited row cannot be confirmed`);
43877
43878
  return undefined;
43878
43879
  }
43879
43880
  const editing = this.inlineEdition && (!opts || opts.editing !== false); // true by default, if inlineEdition
@@ -43905,7 +43906,7 @@ class AppAsyncTable {
43905
43906
  // Not exists: register new definition
43906
43907
  if (!def) {
43907
43908
  if (this.debug)
43908
- console.debug(`[table] New listener {${name}} for value changes on path ${formPath}`);
43909
+ console.debug(`${this.logPrefix} New listener {${name}} for value changes on path ${formPath}`);
43909
43910
  def = {
43910
43911
  subject: new Subject(),
43911
43912
  subscription: null,
@@ -44064,7 +44065,7 @@ class AppAsyncTable {
44064
44065
  // DEBUG only -- alert user that table not found in template
44065
44066
  if (this.debug) {
44066
44067
  setTimeout(() => !this.table &&
44067
- console.warn(`[table] Missing <mat-table> in the HTML template (after waiting 500ms)! Component: ${this.constructor.name}`), 500);
44068
+ console.warn(`${this.logPrefix} Missing <mat-table> in the HTML template (after waiting 500ms)! Component: ${this.constructor.name}`), 500);
44068
44069
  }
44069
44070
  // Make sure to wait the table
44070
44071
  await waitFor(() => !!this.table, { stop: this.destroySubject, stopError: false /*avoid error when destorying the table*/ });
@@ -44178,7 +44179,7 @@ class AppAsyncTable {
44178
44179
  }
44179
44180
  applyFilter(filter, opts) {
44180
44181
  if (this.debug)
44181
- console.debug('[table] Applying filter', filter);
44182
+ console.debug(`${this.logPrefix} Applying filter`, filter);
44182
44183
  this._filter = filter;
44183
44184
  if (opts && opts.emitEvent) {
44184
44185
  if (this.paginator && this.paginator.pageIndex > 0) {
@@ -44189,11 +44190,11 @@ class AppAsyncTable {
44189
44190
  }
44190
44191
  listenDatasourceLoading(dataSource) {
44191
44192
  if (!dataSource)
44192
- throw new Error('[table] dataSource not set !');
44193
+ throw new Error(`${this.logPrefix} dataSource not set !`);
44193
44194
  // Cleaning previous subscription on datasource
44194
44195
  if (isNotNil(this._dataSourceLoadingSubscription)) {
44195
44196
  if (this.debug)
44196
- console.debug('[table] Many call to listenDatasource(): Cleaning previous subscriptions...');
44197
+ console.debug(`${this.logPrefix} Many call to listenDatasource(): Cleaning previous subscriptions...`);
44197
44198
  this._dataSourceLoadingSubscription.unsubscribe();
44198
44199
  this.unregisterSubscription(this._dataSourceLoadingSubscription);
44199
44200
  }
@@ -44211,7 +44212,7 @@ class AppAsyncTable {
44211
44212
  startCellValueChanges(name, row) {
44212
44213
  const def = this._cellValueChangesDefs[name];
44213
44214
  if (!def) {
44214
- console.warn('[table] Listener with name {' + name + '} not registered! Please call registerCellValueChanges() before;');
44215
+ console.warn(`${this.logPrefix} Listener with name {` + name + '} not registered! Please call registerCellValueChanges() before;');
44215
44216
  return;
44216
44217
  }
44217
44218
  // Stop previous subscription
@@ -44221,12 +44222,12 @@ class AppAsyncTable {
44221
44222
  }
44222
44223
  else {
44223
44224
  if (this.debug)
44224
- console.debug(`[table] Start values changes on row path {${def.formPath}}`);
44225
+ console.debug(`${this.logPrefix} Start values changes on row path {${def.formPath}}`);
44225
44226
  }
44226
44227
  // Listen value changes, and redirect to event emitter
44227
44228
  const control = row.validator && AppFormUtils.getControlFromPath(row.validator, def.formPath);
44228
44229
  if (!control) {
44229
- console.warn(`[table] Could not listen cell changes: no validator or invalid form path {${def.formPath}}`);
44230
+ console.warn(`${this.logPrefix} Could not listen cell changes: no validator or invalid form path {${def.formPath}}`);
44230
44231
  }
44231
44232
  else {
44232
44233
  def.subscription = control.valueChanges
@@ -44246,7 +44247,7 @@ class AppAsyncTable {
44246
44247
  return;
44247
44248
  if (def.subscription) {
44248
44249
  if (this.debug)
44249
- console.debug('[table] Stop value changes on row path {' + def.formPath + '}');
44250
+ console.debug(`${this.logPrefix} Stop value changes on row path {` + def.formPath + '}');
44250
44251
  def.subscription.unsubscribe();
44251
44252
  def.subscription = null;
44252
44253
  }