@sumaris-net/ngx-components 18.3.21 → 18.3.22

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.
@@ -31565,7 +31565,7 @@ class AppTable {
31565
31565
  saveBeforeFilter;
31566
31566
  propagateRowError = false;
31567
31567
  permanentSelectionAllowed = false; // Allow keep selected rows over page change or sort change
31568
- openRowThrottleTime = 800;
31568
+ openRowThrottleTime = 800; // Prevent double click - see issue sumaris-app#864
31569
31569
  defaultSortBy;
31570
31570
  defaultSortDirection;
31571
31571
  defaultPageSize = DEFAULT_PAGE_SIZE;
@@ -32421,11 +32421,17 @@ class AppTable {
32421
32421
  this.selection.clear();
32422
32422
  this.openRow(row.currentData.id, row)
32423
32423
  .catch((err) => console.error('Failed to open row', err)) // Continue
32424
- .then(async () => {
32424
+ .then(() => {
32425
32425
  this.markAsLoaded();
32426
- // Add the throttle time, before authorize to click again (prevent double click)
32427
- await sleep(this.openRowThrottleTime);
32428
- this._openingRow = false;
32426
+ // Prevent double click (use an open throttle time)
32427
+ if (this.openRowThrottleTime > 0) {
32428
+ setTimeout(() => {
32429
+ this._openingRow = false;
32430
+ }, this.openRowThrottleTime);
32431
+ }
32432
+ else {
32433
+ this._openingRow = false;
32434
+ }
32429
32435
  });
32430
32436
  return true;
32431
32437
  }
@@ -32551,8 +32557,6 @@ class AppTable {
32551
32557
  }
32552
32558
  this.editedRow = row;
32553
32559
  this.onStartEditingRow.emit(row);
32554
- // FIXME
32555
- //this.detectChanges(); // Workaround need by SUMARiS (e.g. for samples tables) otherwise the row will not be editable
32556
32560
  return true;
32557
32561
  }
32558
32562
  /**
@@ -32831,11 +32835,8 @@ class AppTable {
32831
32835
  this.visibleRowCount++;
32832
32836
  this.markAsDirty({ emitEvent: false /*markForCheck() is called just after*/ });
32833
32837
  // Emit event
32834
- if (!opts || opts.emitEvent !== false) {
32838
+ if (!opts || opts.emitEvent !== false)
32835
32839
  this.markForCheck();
32836
- // FIXME
32837
- //this.detectChanges(); // Workaround need by SUMARiS (e.g. samples tables) otherwise new row is not visible
32838
- }
32839
32840
  return row;
32840
32841
  }
32841
32842
  registerCellValueChanges(name, formPath, emitInitialValue) {
@@ -34250,6 +34251,7 @@ class AppAsyncTable {
34250
34251
  _dataSource;
34251
34252
  _filter;
34252
34253
  _initialized = false;
34254
+ _openingRow = false;
34253
34255
  _subscription = new Subscription();
34254
34256
  _dataSourceLoadingSubscription;
34255
34257
  _cellValueChangesDefs = {};
@@ -34309,6 +34311,7 @@ class AppAsyncTable {
34309
34311
  saveBeforeFilter;
34310
34312
  propagateRowError = false;
34311
34313
  permanentSelectionAllowed = false; // Allow keep selected rows over page change or sort change
34314
+ openRowThrottleTime = 800; // Prevent double click - see issue sumaris-app#864
34312
34315
  defaultSortBy;
34313
34316
  defaultSortDirection;
34314
34317
  defaultPageSize = DEFAULT_PAGE_SIZE;
@@ -34524,6 +34527,14 @@ class AppAsyncTable {
34524
34527
  get sortDirection() {
34525
34528
  return (this.sort && this.sort.direction && (this.sort.direction === 'desc' ? 'desc' : 'asc')) || undefined;
34526
34529
  }
34530
+ set sortDirection(value) {
34531
+ if (this.sort) {
34532
+ this.sort.direction = value;
34533
+ }
34534
+ else {
34535
+ this.defaultSortDirection = value;
34536
+ }
34537
+ }
34527
34538
  _paginator = null;
34528
34539
  set paginator(value) {
34529
34540
  this._paginator = value;
@@ -35103,15 +35114,29 @@ class AppAsyncTable {
35103
35114
  }
35104
35115
  // Open the detail page (if not inline editing)
35105
35116
  if (!this.inlineEdition) {
35117
+ if (this._openingRow)
35118
+ return; // Prevent double click
35106
35119
  if (event) {
35107
35120
  event.stopPropagation();
35108
35121
  event.preventDefault();
35109
35122
  }
35123
+ this._openingRow = true; // Prevent double click
35110
35124
  this.markAsLoading();
35111
35125
  this.selection.clear();
35112
35126
  this.openRow(row.currentData.id, row)
35113
- .then(() => this.markAsLoaded())
35114
- .catch(() => this.markAsLoaded());
35127
+ .catch((err) => console.error('Failed to open row', err)) // Continue
35128
+ .then(() => {
35129
+ this.markAsLoaded();
35130
+ // Prevent double click (use an open throttle time)
35131
+ if (this.openRowThrottleTime > 0) {
35132
+ setTimeout(() => {
35133
+ this._openingRow = false;
35134
+ }, this.openRowThrottleTime);
35135
+ }
35136
+ else {
35137
+ this._openingRow = false;
35138
+ }
35139
+ });
35115
35140
  return true;
35116
35141
  }
35117
35142
  // Start editing row
@@ -35727,7 +35752,7 @@ class AppAsyncTable {
35727
35752
  }
35728
35753
  }
35729
35754
  setLoading(value, opts) {
35730
- if (this.loadingSubject.value !== value) {
35755
+ if (!this.loadingSubject.closed && this.loadingSubject.value !== value) {
35731
35756
  this.loadingSubject.next(value);
35732
35757
  if (!opts || opts.emitEvent !== false) {
35733
35758
  this.markForCheck();
@@ -35875,7 +35900,7 @@ class AppAsyncTable {
35875
35900
  }
35876
35901
  }
35877
35902
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AppAsyncTable, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
35878
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: AppAsyncTable, inputs: { settingsId: "settingsId", debug: "debug", i18nColumnPrefix: "i18nColumnPrefix", i18nColumnSuffix: "i18nColumnSuffix", autoLoad: "autoLoad", readOnly: "readOnly", inlineEdition: "inlineEdition", focusFirstColumn: "focusFirstColumn", confirmBeforeDelete: "confirmBeforeDelete", confirmBeforeCancel: "confirmBeforeCancel", undoableDeletion: "undoableDeletion", saveBeforeDelete: "saveBeforeDelete", keepEditedRowOnSave: "keepEditedRowOnSave", saveBeforeSort: "saveBeforeSort", saveBeforeFilter: "saveBeforeFilter", propagateRowError: "propagateRowError", permanentSelectionAllowed: "permanentSelectionAllowed", defaultSortBy: "defaultSortBy", defaultSortDirection: "defaultSortDirection", defaultPageSize: "defaultPageSize", defaultPageSizeOptions: "defaultPageSizeOptions", focusColumn: "focusColumn", dataSource: "dataSource", filter: "filter", disabled: "disabled", paginator: "paginator" }, outputs: { onRefresh: "onRefresh", onOpenRow: "onOpenRow", onNewRow: "onNewRow", onStartEditingRow: "onStartEditingRow", onConfirmEditCreateRow: "onConfirmEditCreateRow", onCancelOrDeleteRow: "onCancelOrDeleteRow", onBeforeDeleteRows: "onBeforeDeleteRows", onBeforeCancelRows: "onBeforeCancelRows", onBeforeSave: "onBeforeSave", onAfterDeletedRows: "onAfterDeletedRows", onSort: "onSort", onDirty: "onDirty", onError: "onError" }, viewQueries: [{ propertyName: "table", first: true, predicate: MatTable, descendants: true }, { propertyName: "childPaginator", first: true, predicate: MatPaginator, descendants: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true }], ngImport: i0 });
35903
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.11", type: AppAsyncTable, inputs: { settingsId: "settingsId", debug: "debug", i18nColumnPrefix: "i18nColumnPrefix", i18nColumnSuffix: "i18nColumnSuffix", autoLoad: "autoLoad", readOnly: "readOnly", inlineEdition: "inlineEdition", focusFirstColumn: "focusFirstColumn", confirmBeforeDelete: "confirmBeforeDelete", confirmBeforeCancel: "confirmBeforeCancel", undoableDeletion: "undoableDeletion", saveBeforeDelete: "saveBeforeDelete", keepEditedRowOnSave: "keepEditedRowOnSave", saveBeforeSort: "saveBeforeSort", saveBeforeFilter: "saveBeforeFilter", propagateRowError: "propagateRowError", permanentSelectionAllowed: "permanentSelectionAllowed", openRowThrottleTime: "openRowThrottleTime", defaultSortBy: "defaultSortBy", defaultSortDirection: "defaultSortDirection", defaultPageSize: "defaultPageSize", defaultPageSizeOptions: "defaultPageSizeOptions", focusColumn: "focusColumn", dataSource: "dataSource", filter: "filter", disabled: "disabled", paginator: "paginator" }, outputs: { onRefresh: "onRefresh", onOpenRow: "onOpenRow", onNewRow: "onNewRow", onStartEditingRow: "onStartEditingRow", onConfirmEditCreateRow: "onConfirmEditCreateRow", onCancelOrDeleteRow: "onCancelOrDeleteRow", onBeforeDeleteRows: "onBeforeDeleteRows", onBeforeCancelRows: "onBeforeCancelRows", onBeforeSave: "onBeforeSave", onAfterDeletedRows: "onAfterDeletedRows", onSort: "onSort", onDirty: "onDirty", onError: "onError" }, viewQueries: [{ propertyName: "table", first: true, predicate: MatTable, descendants: true }, { propertyName: "childPaginator", first: true, predicate: MatPaginator, descendants: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true }], ngImport: i0 });
35879
35904
  }
35880
35905
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AppAsyncTable, decorators: [{
35881
35906
  type: Directive
@@ -35913,6 +35938,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
35913
35938
  type: Input
35914
35939
  }], permanentSelectionAllowed: [{
35915
35940
  type: Input
35941
+ }], openRowThrottleTime: [{
35942
+ type: Input
35916
35943
  }], defaultSortBy: [{
35917
35944
  type: Input
35918
35945
  }], defaultSortDirection: [{