@trudb/tru-common-lib 0.2.12 → 0.2.14

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.
@@ -5900,20 +5900,71 @@ class TruDataGridCellRenderer {
5900
5900
  }
5901
5901
  }
5902
5902
 
5903
+ class TruDataGridClipboard {
5904
+ tableName = null;
5905
+ rowData = [];
5906
+ copiedRows = (tableName, rowData) => {
5907
+ this.tableName = tableName;
5908
+ this.rowData = rowData;
5909
+ };
5910
+ getCopiedRows = () => {
5911
+ return this.rowData;
5912
+ };
5913
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5914
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, providedIn: 'root' });
5915
+ }
5916
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, decorators: [{
5917
+ type: Injectable,
5918
+ args: [{
5919
+ providedIn: 'root',
5920
+ }]
5921
+ }] });
5922
+
5903
5923
  class TruDataGridPkeyCellRenderer {
5924
+ dataGridClipboard;
5925
+ util;
5904
5926
  contextMenu;
5905
5927
  params;
5906
5928
  contextMenuPosition = { x: '0px', y: '0px' };
5907
5929
  displayValue = '';
5930
+ copyIsDisabled = true;
5931
+ pasteIsDisabled = true;
5908
5932
  // private eGui: is an empty element to satisfy the getGui method.
5909
5933
  eGui;
5934
+ constructor(dataGridClipboard, util) {
5935
+ this.dataGridClipboard = dataGridClipboard;
5936
+ this.util = util;
5937
+ }
5910
5938
  onRightClick = (event) => {
5911
5939
  event.preventDefault();
5912
- this.contextMenuPosition.x = event.clientX + 'px';
5913
- this.contextMenuPosition.y = (event.clientY - 130) + 'px';
5940
+ this.copyIsDisabled = this.params.api.getSelectedRows().length ? false : true;
5941
+ this.pasteIsDisabled = this.dataGridClipboard.getCopiedRows().length && this.params.api.getSelectedRows().length ? false : true;
5942
+ this.contextMenuPosition.x = event.pageX + 'px';
5943
+ this.contextMenuPosition.y = (event.pageY - 130) + 'px';
5914
5944
  this.contextMenu.menu?.focusFirstItem('mouse');
5915
5945
  this.contextMenu.openMenu();
5916
5946
  };
5947
+ onCopy = (event) => {
5948
+ let selectedRows = this.params.api.getSelectedRows();
5949
+ if (selectedRows.length) {
5950
+ let copiedRowData = selectedRows.map((row) => row.$entity);
5951
+ this.dataGridClipboard.copiedRows('', copiedRowData);
5952
+ }
5953
+ };
5954
+ onPaste = (event) => {
5955
+ let copiedRowData = this.dataGridClipboard.getCopiedRows();
5956
+ copiedRowData.forEach((row) => {
5957
+ let properties = row.entityType.getPropertyNames();
5958
+ properties
5959
+ .filter((propertyName) => {
5960
+ return propertyName !== 'Ref' &&
5961
+ propertyName !== row.entityType.name + 'Ref' &&
5962
+ !this.util.isLowerCase(propertyName.charAt(0));
5963
+ }).forEach((propertyName) => {
5964
+ console.log(propertyName);
5965
+ });
5966
+ });
5967
+ };
5917
5968
  agInit(params) {
5918
5969
  this.params = params;
5919
5970
  if (params.value < 0)
@@ -5929,7 +5980,7 @@ class TruDataGridPkeyCellRenderer {
5929
5980
  return false;
5930
5981
  }
5931
5982
  destroy() { }
5932
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridPkeyCellRenderer, deps: [], target: i0.ɵɵFactoryTarget.Component });
5983
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridPkeyCellRenderer, deps: [{ token: TruDataGridClipboard }, { token: TruUtil }], target: i0.ɵɵFactoryTarget.Component });
5933
5984
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.3", type: TruDataGridPkeyCellRenderer, isStandalone: true, selector: "ng-component", viewQueries: [{ propertyName: "contextMenu", first: true, predicate: MatMenuTrigger, descendants: true }], ngImport: i0, template: `<div (contextmenu)="onRightClick($event)">{{displayValue}}
5934
5985
  <div style="visibility: hidden; position: fixed"
5935
5986
  [style.left]="contextMenuPosition.x"
@@ -5937,11 +5988,11 @@ class TruDataGridPkeyCellRenderer {
5937
5988
  [matMenuTriggerFor]="truDataGridContextMenu">
5938
5989
  </div>
5939
5990
  <mat-menu #truDataGridContextMenu="matMenu">
5940
- <button mat-menu-item>
5991
+ <button mat-menu-item [disabled]="copyIsDisabled" (click)="onCopy($event)">
5941
5992
  <mat-icon [svgIcon]="'copy-icon'"></mat-icon>
5942
5993
  <span>Copy</span>
5943
5994
  </button>
5944
- <button mat-menu-item disabled>
5995
+ <button mat-menu-item [disabled]="pasteIsDisabled" (click)="onPaste($event)">
5945
5996
  <mat-icon [svgIcon]="'paste-icon'"></mat-icon>
5946
5997
  <span>Paste</span>
5947
5998
  </button>
@@ -5950,7 +6001,7 @@ class TruDataGridPkeyCellRenderer {
5950
6001
  <span>Insert At Top</span>
5951
6002
  </button>
5952
6003
  </mat-menu>
5953
- </div>`, isInline: true, styles: ["::ng-deep .mat-menu-item{height:25px!important;min-height:20px!important}::ng-deep mat-icon svg{fill:#949494}::ng-deep .mat-mdc-menu-item-text{font-size:12px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i5.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i5.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i5.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
6004
+ </div>`, isInline: true, styles: ["::ng-deep .mat-mdc-menu-item{height:25px!important;min-height:25px!important}::ng-deep .mat-mdc-menu-content mat-icon svg{fill:#949494}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i5.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i5.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i5.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
5954
6005
  }
5955
6006
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridPkeyCellRenderer, decorators: [{
5956
6007
  type: Component,
@@ -5968,11 +6019,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImpor
5968
6019
  [matMenuTriggerFor]="truDataGridContextMenu">
5969
6020
  </div>
5970
6021
  <mat-menu #truDataGridContextMenu="matMenu">
5971
- <button mat-menu-item>
6022
+ <button mat-menu-item [disabled]="copyIsDisabled" (click)="onCopy($event)">
5972
6023
  <mat-icon [svgIcon]="'copy-icon'"></mat-icon>
5973
6024
  <span>Copy</span>
5974
6025
  </button>
5975
- <button mat-menu-item disabled>
6026
+ <button mat-menu-item [disabled]="pasteIsDisabled" (click)="onPaste($event)">
5976
6027
  <mat-icon [svgIcon]="'paste-icon'"></mat-icon>
5977
6028
  <span>Paste</span>
5978
6029
  </button>
@@ -5981,8 +6032,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImpor
5981
6032
  <span>Insert At Top</span>
5982
6033
  </button>
5983
6034
  </mat-menu>
5984
- </div>`, styles: ["::ng-deep .mat-menu-item{height:25px!important;min-height:20px!important}::ng-deep mat-icon svg{fill:#949494}::ng-deep .mat-mdc-menu-item-text{font-size:12px}\n"] }]
5985
- }], propDecorators: { contextMenu: [{
6035
+ </div>`, styles: ["::ng-deep .mat-mdc-menu-item{height:25px!important;min-height:25px!important}::ng-deep .mat-mdc-menu-content mat-icon svg{fill:#949494}\n"] }]
6036
+ }], ctorParameters: () => [{ type: TruDataGridClipboard }, { type: TruUtil }], propDecorators: { contextMenu: [{
5986
6037
  type: ViewChild,
5987
6038
  args: [MatMenuTrigger]
5988
6039
  }] } });