@trudb/tru-common-lib 0.2.29 → 0.2.31

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Input, Directive, Injectable, NgModule, Inject, Component, HostListener, InjectionToken, ViewChild, EventEmitter, Output, ViewEncapsulation, Pipe, ViewContainerRef, createComponent, Optional, ViewChildren, signal, ChangeDetectionStrategy, QueryList, ContentChildren } from '@angular/core';
2
+ import { Input, Directive, Injectable, NgModule, Inject, Component, HostListener, InjectionToken, ViewChild, EventEmitter, Output, ViewEncapsulation, Pipe, ViewContainerRef, ChangeDetectionStrategy, createComponent, Optional, ViewChildren, signal, QueryList, ContentChildren } from '@angular/core';
3
3
  import { EntityAspect, MetadataStore, DataService, EntityManager, EntityQuery, Predicate, FetchStrategy, EntityAction, breeze, EntityState, BinaryPredicate, AndOrPredicate } from 'breeze-client';
4
4
  import * as i1$1 from '@angular/common';
5
5
  import { CommonModule, NgIf, NgClass, DatePipe } from '@angular/common';
@@ -5903,16 +5903,90 @@ class TruDataGridCellRenderer {
5903
5903
  }
5904
5904
  }
5905
5905
 
5906
+ class TruDataGridClipboard {
5907
+ tableName = null;
5908
+ rowData = [];
5909
+ copiedRows = (tableName, rowData) => {
5910
+ this.tableName = tableName;
5911
+ this.rowData = rowData;
5912
+ };
5913
+ getCopiedRows = () => {
5914
+ return this.rowData;
5915
+ };
5916
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
5917
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, providedIn: 'root' });
5918
+ }
5919
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridClipboard, decorators: [{
5920
+ type: Injectable,
5921
+ args: [{
5922
+ providedIn: 'root',
5923
+ }]
5924
+ }] });
5925
+
5906
5926
  class TruDataGridPkeyCellRenderer {
5927
+ dataGridClipboard;
5928
+ util;
5929
+ contextMenu;
5930
+ params;
5931
+ contextMenuPosition = { x: '0px', y: '0px' };
5932
+ displayValue = '';
5933
+ copyIsDisabled = true;
5934
+ pasteIsDisabled = true;
5907
5935
  // private eGui: is an empty element to satisfy the getGui method.
5908
5936
  eGui;
5909
- init(params) {
5910
- params.eGridCell.innerHTML = '';
5911
- let value = params.value;
5937
+ constructor(dataGridClipboard, util) {
5938
+ this.dataGridClipboard = dataGridClipboard;
5939
+ this.util = util;
5940
+ }
5941
+ onRightClick = (event) => {
5942
+ event.preventDefault();
5943
+ this.copyIsDisabled = this.params.api.getSelectedRows().length ? false : true;
5944
+ this.pasteIsDisabled = this.dataGridClipboard.getCopiedRows().length && this.params.api.getSelectedRows().length ? false : true;
5945
+ this.contextMenuPosition.x = event.pageX + 'px';
5946
+ this.contextMenuPosition.y = (event.pageY - 130) + 'px';
5947
+ this.contextMenu.menu?.focusFirstItem('mouse');
5948
+ this.contextMenu.openMenu();
5949
+ };
5950
+ onMouseUp = (event) => {
5951
+ if (event.ctrlKey) {
5952
+ if (this.params.node.isSelected())
5953
+ this.params.node.setSelected(false, true);
5954
+ else
5955
+ this.params.node.setSelected(true, true);
5956
+ }
5957
+ else {
5958
+ this.params.node.setSelected(true, true);
5959
+ }
5960
+ };
5961
+ onCopy = (event) => {
5962
+ let selectedRows = this.params.api.getSelectedRows();
5963
+ if (selectedRows.length) {
5964
+ let copiedRowData = selectedRows.map((row) => row.$entity);
5965
+ this.dataGridClipboard.copiedRows('', copiedRowData);
5966
+ }
5967
+ };
5968
+ onPaste = (event) => {
5969
+ let copiedRowData = this.dataGridClipboard.getCopiedRows();
5970
+ copiedRowData.forEach((row) => {
5971
+ let properties = row.entityType.getPropertyNames();
5972
+ properties
5973
+ .filter((propertyName) => {
5974
+ return propertyName !== 'Ref' &&
5975
+ propertyName !== row.entityType.name + 'Ref' &&
5976
+ !this.util.isLowerCase(propertyName.charAt(0));
5977
+ }).forEach((propertyName) => {
5978
+ console.log(propertyName);
5979
+ });
5980
+ });
5981
+ };
5982
+ agInit(params) {
5983
+ this.params = params;
5912
5984
  if (params.value < 0)
5913
- value = 'NEW';
5914
- var content = document.createTextNode(value);
5915
- params.eGridCell.appendChild(content);
5985
+ this.displayValue = 'NEW';
5986
+ else
5987
+ this.displayValue = params.value;
5988
+ params.eGridCell.addEventListener('contextmenu', this.onRightClick);
5989
+ params.eGridCell.addEventListener('mouseup', this.onMouseUp);
5916
5990
  }
5917
5991
  getGui() {
5918
5992
  return this.eGui;
@@ -5920,8 +5994,67 @@ class TruDataGridPkeyCellRenderer {
5920
5994
  refresh() {
5921
5995
  return false;
5922
5996
  }
5923
- destroy() { }
5924
- }
5997
+ destroy() {
5998
+ this.params.eGridCell.removeEventListener('contextmenu', this.onRightClick);
5999
+ this.params.eGridCell.removeEventListener('mouseup', this.onMouseUp);
6000
+ }
6001
+ 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 });
6002
+ 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}}
6003
+ <div style="visibility: hidden; position: fixed"
6004
+ [style.left]="contextMenuPosition.x"
6005
+ [style.top]="contextMenuPosition.y"
6006
+ [matMenuTriggerFor]="truDataGridContextMenu">
6007
+ </div>
6008
+ <mat-menu #truDataGridContextMenu="matMenu">
6009
+ <button mat-menu-item [disabled]="copyIsDisabled" (click)="onCopy($event)">
6010
+ <mat-icon [svgIcon]="'copy-icon'"></mat-icon>
6011
+ <span>Copy</span>
6012
+ </button>
6013
+ <button mat-menu-item [disabled]="pasteIsDisabled" (click)="onPaste($event)">
6014
+ <mat-icon [svgIcon]="'paste-icon'"></mat-icon>
6015
+ <span>Paste</span>
6016
+ </button>
6017
+ <button mat-menu-item>
6018
+ <mat-icon [svgIcon]="'insert-icon'"></mat-icon>
6019
+ <span>Insert At Top</span>
6020
+ </button>
6021
+ </mat-menu>
6022
+ </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 });
6023
+ }
6024
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.3", ngImport: i0, type: TruDataGridPkeyCellRenderer, decorators: [{
6025
+ type: Component,
6026
+ args: [{ standalone: true, imports: [
6027
+ NgIf,
6028
+ NgClass,
6029
+ CommonModule,
6030
+ MatIconModule,
6031
+ MatButtonModule,
6032
+ MatMenuModule
6033
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: `<div (contextmenu)="onRightClick($event)">{{displayValue}}
6034
+ <div style="visibility: hidden; position: fixed"
6035
+ [style.left]="contextMenuPosition.x"
6036
+ [style.top]="contextMenuPosition.y"
6037
+ [matMenuTriggerFor]="truDataGridContextMenu">
6038
+ </div>
6039
+ <mat-menu #truDataGridContextMenu="matMenu">
6040
+ <button mat-menu-item [disabled]="copyIsDisabled" (click)="onCopy($event)">
6041
+ <mat-icon [svgIcon]="'copy-icon'"></mat-icon>
6042
+ <span>Copy</span>
6043
+ </button>
6044
+ <button mat-menu-item [disabled]="pasteIsDisabled" (click)="onPaste($event)">
6045
+ <mat-icon [svgIcon]="'paste-icon'"></mat-icon>
6046
+ <span>Paste</span>
6047
+ </button>
6048
+ <button mat-menu-item>
6049
+ <mat-icon [svgIcon]="'insert-icon'"></mat-icon>
6050
+ <span>Insert At Top</span>
6051
+ </button>
6052
+ </mat-menu>
6053
+ </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"] }]
6054
+ }], ctorParameters: () => [{ type: TruDataGridClipboard }, { type: TruUtil }], propDecorators: { contextMenu: [{
6055
+ type: ViewChild,
6056
+ args: [MatMenuTrigger]
6057
+ }] } });
5925
6058
 
5926
6059
  var TruDataGridTypes;
5927
6060
  (function (TruDataGridTypes) {
@@ -7307,16 +7440,16 @@ class TruDataGrid {
7307
7440
  else {
7308
7441
  if (cellData.event.ctrlKey) {
7309
7442
  if (this.rowSelectedOnMousedown)
7310
- cellData.node.setSelected(false);
7443
+ cellData.node.setSelected(false, false, true);
7311
7444
  else
7312
- cellData.node.setSelected(true);
7445
+ cellData.node.setSelected(true, false, true);
7313
7446
  }
7314
7447
  else if (cellData.event.shiftKey) {
7315
7448
  let focusedId = this.rowFocuedOnMousedown.id;
7316
7449
  }
7317
7450
  else {
7318
7451
  cellData.api.deselectAll();
7319
- cellData.node.setSelected(true);
7452
+ cellData.node.setSelected(true, false, true);
7320
7453
  }
7321
7454
  }
7322
7455
  };