@trudb/tru-common-lib 0.2.126 → 0.2.127

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.
@@ -5906,19 +5906,27 @@ class TruDataGridClipboard {
5906
5906
  util;
5907
5907
  uiNotification;
5908
5908
  tableName = null;
5909
+ columnName = null;
5910
+ copiedCell = null;
5909
5911
  copiedRows = [];
5910
5912
  constructor(util, uiNotification) {
5911
5913
  this.util = util;
5912
5914
  this.uiNotification = uiNotification;
5913
5915
  }
5914
- copy = (tableName, copiedRows) => {
5916
+ copyCell = (tableName, columnName, copiedCell) => {
5915
5917
  this.tableName = tableName;
5916
- this.copiedRows = copiedRows;
5918
+ this.columnName = columnName;
5919
+ this.copiedCell = copiedCell;
5917
5920
  };
5918
- getCopiedRows = () => {
5919
- return this.copiedRows;
5921
+ pasteCell = (tableName, columnName, pastedCell) => {
5922
+ //pastedCell.setProperty(this.columnName, this.copiedCell?.getProperty(this.columnName));
5923
+ let test = '';
5920
5924
  };
5921
- paste = (gridApi, config, selectedRows) => {
5925
+ copyRow = (tableName, copiedRows) => {
5926
+ this.tableName = tableName;
5927
+ this.copiedRows = copiedRows;
5928
+ };
5929
+ pasteRow = (gridApi, config, selectedRows) => {
5922
5930
  if (this.tableName !== config.tableName) {
5923
5931
  this.uiNotification.error('Clipboard data does not match the current table name: ' + this.tableName + ' vs ' + config.tableName);
5924
5932
  return;
@@ -5971,6 +5979,9 @@ class TruDataGridClipboard {
5971
5979
  });
5972
5980
  }
5973
5981
  };
5982
+ getCopiedRows = () => {
5983
+ return this.copiedRows;
5984
+ };
5974
5985
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, deps: [{ token: TruUtil }, { token: TruUiNotification }], target: i0.ɵɵFactoryTarget.Injectable });
5975
5986
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, providedIn: 'root' });
5976
5987
  }
@@ -6005,14 +6016,20 @@ class TruDataGridCellRenderer {
6005
6016
  event.preventDefault();
6006
6017
  this.copyIsDisabled = this.params.api.getSelectedRows().length ? false : true;
6007
6018
  this.pasteIsDisabled = this.dataGridClipboard.getCopiedRows().length && this.params.api.getSelectedRows().length ? false : true;
6008
- this.contextMenuPosition.x = event.pageX + 'px';
6009
- this.contextMenuPosition.y = (event.pageY) + 'px';
6010
- this.contextMenu.menu?.focusFirstItem('mouse');
6011
- this.contextMenu.openMenu();
6019
+ let clickedElement = event.target;
6020
+ if (clickedElement instanceof Element) {
6021
+ let rect = clickedElement.getBoundingClientRect();
6022
+ this.contextMenuPosition.x = rect.x + 'px';
6023
+ this.contextMenuPosition.y = (event.pageY) + 'px';
6024
+ this.contextMenu.menu?.focusFirstItem('mouse');
6025
+ this.contextMenu.openMenu();
6026
+ }
6012
6027
  };
6013
6028
  onCopy = (event) => {
6029
+ this.dataGridClipboard.copyCell(this.params.context.grid.config.tableName, this.params.colDef?.field, this.params.data.$entity);
6014
6030
  };
6015
6031
  onPaste = (event) => {
6032
+ this.dataGridClipboard.pasteCell(this.params.context.grid.config.tableName, this.params.colDef?.field, this.params.data.$entity);
6016
6033
  };
6017
6034
  init(params) {
6018
6035
  }
@@ -6132,11 +6149,11 @@ class TruDataGridPkeyCellRenderer {
6132
6149
  let selectedRows = this.params.api.getSelectedRows();
6133
6150
  if (selectedRows.length) {
6134
6151
  let copiedRowData = selectedRows.map((row) => row.$entity);
6135
- this.dataGridClipboard.copy(this.params.context.grid.config.tableName, copiedRowData);
6152
+ this.dataGridClipboard.copyRow(this.params.context.grid.config.tableName, copiedRowData);
6136
6153
  }
6137
6154
  };
6138
6155
  onPaste = (event) => {
6139
- this.dataGridClipboard.paste(this.params.api, this.params.context.grid.config, this.params.api.getSelectedRows());
6156
+ this.dataGridClipboard.pasteRow(this.params.api, this.params.context.grid.config, this.params.api.getSelectedRows());
6140
6157
  };
6141
6158
  onInsertAtTop = (event) => {
6142
6159
  this.dataGridClipboard.insertRowsAtTop(this.dataContext, this.params.context.grid.config, this.params.context.grid.addEntity);
@@ -7650,10 +7667,10 @@ class TruDataGrid {
7650
7667
  else if (params.column.isPinned() && event.ctrlKey && event.code === 'KeyC') {
7651
7668
  let selectedRows = this.api.getSelectedRows();
7652
7669
  if (selectedRows.length)
7653
- this.dataGridClipboard.copy(this.config.tableName, selectedRows.map((row) => row.$entity));
7670
+ this.dataGridClipboard.copyRow(this.config.tableName, selectedRows.map((row) => row.$entity));
7654
7671
  }
7655
7672
  else if (params.column.isPinned() && event.ctrlKey && event.code === 'KeyV') {
7656
- this.dataGridClipboard.paste(this.api, this.config, this.api.getSelectedRows());
7673
+ this.dataGridClipboard.pasteRow(this.api, this.config, this.api.getSelectedRows());
7657
7674
  }
7658
7675
  };
7659
7676
  onCellMouseOver(e) {