@colijnit/corecomponents_v12 12.2.27 → 12.2.28

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.
@@ -16,6 +16,7 @@ import { DragDropModule, moveItemInArray } from '@angular/cdk/drag-drop';
16
16
  import * as i1 from '@angular/cdk/overlay';
17
17
  import { OverlayConfig, Overlay } from '@angular/cdk/overlay';
18
18
  import { ComponentPortal } from '@angular/cdk/portal';
19
+ import * as XLSX from 'xlsx';
19
20
  import { ScrollingModule } from '@angular/cdk/scrolling';
20
21
  import { ArrayUtils as ArrayUtils$1 } from '@colijnit/ioneconnector/build/utils/array-utils';
21
22
  import { DEFAULT_GET_OBJECT_CONFIGURATION_PARAMS } from '@colijnit/ioneconnector/build/model/default-get-object-configurations-params';
@@ -5683,6 +5684,7 @@ class InputTextComponent extends BaseInputComponent {
5683
5684
  this.excludePlusMinus = true;
5684
5685
  this.showClearButton = true;
5685
5686
  this.showPlaceholderOnFocus = true;
5687
+ this.selectOnFocus = false;
5686
5688
  this.noStyle = false;
5687
5689
  this.hideArrowButtons = false;
5688
5690
  this.leftIconClick = new EventEmitter();
@@ -5776,12 +5778,14 @@ class InputTextComponent extends BaseInputComponent {
5776
5778
  handleInputFocus(event) {
5777
5779
  event.preventDefault();
5778
5780
  event.stopPropagation();
5781
+ if (this.selectOnFocus) {
5782
+ this.input.select();
5783
+ }
5779
5784
  this.isFocused.emit(this.focused);
5780
5785
  }
5781
5786
  handleBlur(event) {
5782
5787
  event.preventDefault();
5783
5788
  event.stopPropagation();
5784
- this.focused = false;
5785
5789
  this.isFocused.emit(false);
5786
5790
  }
5787
5791
  clearInput(event) {
@@ -5822,7 +5826,7 @@ InputTextComponent.decorators = [
5822
5826
  <ng-content></ng-content>
5823
5827
  </div>
5824
5828
  </ng-container>
5825
- <co-icon [class.show]="showClearButton && hasValue && focused && !readonly" class="input-text-clear-button" [icon]="icons.CrossSkinny" (click)="clearInput($event)"></co-icon>
5829
+ <co-icon [class.show]="showClearButton && hasValue && !readonly" class="input-text-clear-button" [icon]="icons.CrossSkinny" (click)="clearInput($event)"></co-icon>
5826
5830
  <div class="required-indicator"></div>
5827
5831
  </div>
5828
5832
  <div *ngIf="rightIcon || rightIconData" class="spacer right-icon"></div>
@@ -5877,6 +5881,7 @@ InputTextComponent.propDecorators = {
5877
5881
  rightIcon: [{ type: Input }],
5878
5882
  leftIconData: [{ type: Input }],
5879
5883
  rightIconData: [{ type: Input }],
5884
+ selectOnFocus: [{ type: Input }],
5880
5885
  noStyle: [{ type: HostBinding, args: ['class.no-style',] }, { type: Input }],
5881
5886
  hideArrowButtons: [{ type: Input }, { type: HostBinding, args: ['class.hide-arrows',] }],
5882
5887
  isDate: [{ type: HostBinding, args: ["class.isDate",] }],
@@ -8976,6 +8981,7 @@ class SimpleGridColumnDirective {
8976
8981
  this.resizable = true;
8977
8982
  this.required = false;
8978
8983
  this.autoFit = false;
8984
+ this.isSelected = false;
8979
8985
  this.readonly = false;
8980
8986
  this.order = 0;
8981
8987
  this.singleColumn = false;
@@ -9067,6 +9073,7 @@ SimpleGridColumnDirective.propDecorators = {
9067
9073
  resizable: [{ type: Input }],
9068
9074
  required: [{ type: Input }],
9069
9075
  autoFit: [{ type: Input }],
9076
+ isSelected: [{ type: Input }],
9070
9077
  width: [{ type: Input }],
9071
9078
  readonly: [{ type: Input }],
9072
9079
  collection: [{ type: Input }],
@@ -9098,6 +9105,7 @@ class BaseSimpleGridComponent {
9098
9105
  this.rowVisible = new EventEmitter();
9099
9106
  this.columns = [];
9100
9107
  this.headerColumns = [];
9108
+ this.headerColumnsCopy = [];
9101
9109
  this._data = [];
9102
9110
  this.disabledRows = [];
9103
9111
  this._prepared = false;
@@ -9172,6 +9180,7 @@ class BaseSimpleGridComponent {
9172
9180
  this.disabledRows.length = 0;
9173
9181
  if (this.columns && this.columns.length > 0) {
9174
9182
  this.headerColumns = this.columns.filter(c => !c.singleColumn);
9183
+ this.headerColumnsCopy = this.headerColumns;
9175
9184
  let singleColumnIndex = -1;
9176
9185
  for (let i = 0; i < this.columns.length; i++) {
9177
9186
  if (this.columns[i].singleColumn) {
@@ -9235,8 +9244,9 @@ BaseSimpleGridComponent.propDecorators = {
9235
9244
  };
9236
9245
 
9237
9246
  class SimpleGridComponent extends BaseSimpleGridComponent {
9238
- constructor(_changeDetection, _formMaster) {
9247
+ constructor(icons, _changeDetection, _formMaster) {
9239
9248
  super();
9249
+ this.icons = icons;
9240
9250
  this._changeDetection = _changeDetection;
9241
9251
  this._formMaster = _formMaster;
9242
9252
  this.defaultTextAlign = ColumnAlign.Left;
@@ -9246,10 +9256,13 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
9246
9256
  this.rightToolbar = false;
9247
9257
  this.rowsPerPage = 1000;
9248
9258
  this.editing = false;
9259
+ this.isSettingsMenuOpen = false;
9249
9260
  this.editRowIndex = -1;
9250
9261
  this.editCellIndex = -1;
9251
9262
  this.selectedRowIndex = -1;
9252
9263
  this.currentPage = 1;
9264
+ this.sortDirection = 'asc';
9265
+ this.Icons = CoreComponentsIcon;
9253
9266
  this._doubleClicked = false;
9254
9267
  this._newRow = false;
9255
9268
  this.dataChanged.subscribe(() => {
@@ -9439,6 +9452,95 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
9439
9452
  this._detectChanges();
9440
9453
  });
9441
9454
  }
9455
+ toggleSettingsMenu() {
9456
+ this.headerColumnsCopy.forEach(i => i.isSelected = false);
9457
+ this.isSettingsMenuOpen = !this.isSettingsMenuOpen;
9458
+ }
9459
+ toggleColumnMenu(col) {
9460
+ this.isSettingsMenuOpen = false;
9461
+ if (col.isSelected) {
9462
+ col.isSelected = false;
9463
+ }
9464
+ else {
9465
+ this.headerColumnsCopy.forEach(i => i.isSelected = false);
9466
+ col.isSelected = true;
9467
+ }
9468
+ }
9469
+ hideColumn(col) {
9470
+ col.isSelected = false;
9471
+ this.headerColumnsCopy = this.headerColumnsCopy.filter((obj) => {
9472
+ return obj !== col;
9473
+ });
9474
+ }
9475
+ // TODO Fix this sort method
9476
+ // public sortColumn(col: any, columnValue: string): void {
9477
+ // console.log(col);
9478
+ // console.log("columnValue " + columnValue);
9479
+ // col.isSelected = false;
9480
+ //
9481
+ // if (this.sortColumnValue === columnValue) {
9482
+ // this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
9483
+ // } else {
9484
+ // this.sortColumnValue = columnValue;
9485
+ // this.sortDirection = 'asc';
9486
+ // }
9487
+ //
9488
+ // console.log(this.data);
9489
+ // // this.data = this._sortData(this.data);
9490
+ //
9491
+ //
9492
+ // this.data.sort((a, b) => {
9493
+ // const sign = this.sortDirection === 'asc' ? 1 : -1;
9494
+ //
9495
+ // console.log("a " + a);
9496
+ // console.log("b " + b);
9497
+ // console.log(a[this.sortColumnValue]);
9498
+ // console.log(b[this.sortColumnValue]);
9499
+ // console.log("sign " + sign);
9500
+ //
9501
+ // if (a[this.sortColumnValue] < b[this.sortColumnValue]) {
9502
+ // return -1 * sign;
9503
+ // } else if (a[this.sortColumnValue] > b[this.sortColumnValue]) {
9504
+ // return 1 * sign;
9505
+ // }
9506
+ // return 0;
9507
+ // });
9508
+ //
9509
+ //
9510
+ //
9511
+ // this._detectChanges();
9512
+ // // this.data.sort((a, b) => a[this.sortColumnValue] - b[this.sortColumnValue]);
9513
+ // console.log(this.data);
9514
+ // }
9515
+ _sortData(tableData) {
9516
+ return tableData.sort((a, b) => {
9517
+ const sign = this.sortDirection === 'asc' ? 1 : -1;
9518
+ console.log("a " + a);
9519
+ console.log("b " + b);
9520
+ console.log(a[this.sortColumnValue]);
9521
+ console.log(b[this.sortColumnValue]);
9522
+ console.log("sign " + sign);
9523
+ if (a[this.sortColumnValue] < b[this.sortColumnValue]) {
9524
+ return -1 * sign;
9525
+ }
9526
+ else if (a[this.sortColumnValue] > b[this.sortColumnValue]) {
9527
+ return 1 * sign;
9528
+ }
9529
+ return 0;
9530
+ });
9531
+ }
9532
+ showAllColumns() {
9533
+ this.isSettingsMenuOpen = false;
9534
+ this.headerColumnsCopy = this.headerColumns;
9535
+ }
9536
+ exportToExcel() {
9537
+ this.isSettingsMenuOpen = false;
9538
+ let element = document.getElementById('simple-grid-table');
9539
+ const ws = XLSX.utils.table_to_sheet(element);
9540
+ const wb = XLSX.utils.book_new();
9541
+ XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
9542
+ XLSX.writeFile(wb, 'ExcelSheet.xlsx');
9543
+ }
9442
9544
  prepareDataRow(row, index) {
9443
9545
  this.isRowDisabled(row, index);
9444
9546
  }
@@ -9595,31 +9697,69 @@ SimpleGridComponent.decorators = [
9595
9697
  (cancelClick)="cancelEditRow()"
9596
9698
  (deleteClick)="removeRow()"
9597
9699
  ></co-grid-toolbar>
9598
- <table class="simple-grid-table" [clickOutside]="editing" (clickOutside)="handleClickOutsideRow()">
9700
+ <table
9701
+ id="simple-grid-table"
9702
+ class="simple-grid-table"
9703
+ [clickOutside]="editing"
9704
+ (clickOutside)="handleClickOutsideRow()">
9599
9705
  <colgroup>
9600
- <col *ngFor="let column of headerColumns; let index = index"
9706
+ <col *ngFor="let column of headerColumnsCopy; let index = index"
9601
9707
  [class.simple-grid-column-auto-fit]="column.autoFit"
9602
9708
  [style.width.px]="column.width"
9603
9709
  [style.min-width.px]="MIN_COLUMN_WIDTH">
9604
9710
  </colgroup>
9605
9711
  <thead>
9606
9712
  <tr>
9607
- <th scope="col" #headerCell class="simple-grid-column-header" *ngFor="let column of headerColumns; let index = index">
9608
- <div class="simple-grid-column-header-wrapper" [class.resizable]="resizable"
9609
- [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign">
9713
+ <th
9714
+ scope="col"
9715
+ #headerCell
9716
+ class="simple-grid-column-header"
9717
+ *ngFor="let column of headerColumnsCopy; let index = index">
9718
+ <div
9719
+ class="simple-grid-column-header-wrapper"
9720
+ [class.resizable]="resizable"
9721
+ [class.selected]="column.isSelected"
9722
+ [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign">
9610
9723
  <ng-container *ngIf="column.headerTemplate; else noHeaderTemplate">
9611
9724
  <ng-container [ngTemplateOutlet]="column.headerTemplate"></ng-container>
9612
9725
  </ng-container>
9613
9726
  <ng-template #noHeaderTemplate>
9614
- <div class="simple-grid-column-header-label" [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign"
9727
+ <div class="simple-grid-column-header-label"
9728
+ [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign"
9615
9729
  [textContent]="column.headerText || '&nbsp;'"
9616
- ></div>
9730
+ (click)="toggleColumnMenu(column)">
9731
+ </div>
9732
+
9733
+ <div class="column-menu" *ngIf="column.isSelected">
9734
+ <h3 [textContent]="'COLUMN_OPTIONS' | coreLocalize"></h3>
9735
+ <ul>
9736
+ <li (click)="hideColumn(column)">Hide Column</li>
9737
+ <!-- <li (click)="sortColumn(column, column.field)">Sort Column</li>-->
9738
+ </ul>
9739
+ </div>
9617
9740
  </ng-template>
9618
9741
  <div *ngIf="resizable && column.resizable" class="simple-grid-column-sizer"
9619
9742
  (mousedown)="handleSizerMouseDown($event, column)"
9620
9743
  ></div>
9621
9744
  </div>
9622
9745
  </th>
9746
+ <th class="simple-grid-column-header grid-settings">
9747
+ <co-button
9748
+ [class.selected]="isSettingsMenuOpen"
9749
+ [iconData]="icons.getIcon(Icons.CogWheels)"
9750
+ (click)="toggleSettingsMenu()">
9751
+ </co-button>
9752
+
9753
+ <div class="settings-menu" *ngIf="isSettingsMenuOpen">
9754
+ <h3 [textContent]="'GRID_OPTIONS' | coreLocalize"></h3>
9755
+ <ul>
9756
+ <li (click)="exportToExcel()">Export to Excel</li>
9757
+ <li *ngIf="headerColumnsCopy.length !== headerColumns.length" (click)="showAllColumns()">Show All
9758
+ Columns
9759
+ </li>
9760
+ </ul>
9761
+ </div>
9762
+ </th>
9623
9763
  </tr>
9624
9764
  </thead>
9625
9765
  <tbody #dropList cdkDropList cdkDropListOrientation="vertical"
@@ -9628,36 +9768,42 @@ SimpleGridComponent.decorators = [
9628
9768
  [cdkDropListData]="data"
9629
9769
  [cdkDropListEnterPredicate]="handleCanDragDrop"
9630
9770
  (cdkDropListDropped)="handleDrop($event)">
9631
- <tr class="simple-grid-row" [class.selected]="rowIndex === selectedRowIndex && !editing" observeVisibility
9632
- [class.disabled]="getIsRowDisabled(rowIndex)"
9633
- [class.editing]="rowIndex === editRowIndex" *ngFor="let row of (!!rowsPerPage ? (data | paginate: {itemsPerPage: rowsPerPage, currentPage: currentPage}) : data); last as last; let rowIndex = index" cdkDrag
9634
- (click)="handleClickRow($event, rowIndex, row)" (dblclick)="handleDblClickRow($event, rowIndex, row)" (visibilityChange)="rowVisible.next(row)">
9635
- <co-form class="simple-grid-row-form">
9636
- <ng-container *ngIf="isSingleColumnRow(row)">
9637
- <td class="simple-grid-single-column-cell" [attr.colspan]="headerColumns.length">
9771
+ <tr
9772
+ class="simple-grid-row"
9773
+ [class.selected]="rowIndex === selectedRowIndex && !editing" observeVisibility
9774
+ [class.disabled]="getIsRowDisabled(rowIndex)"
9775
+ [class.editing]="rowIndex === editRowIndex"
9776
+ *ngFor="let row of (!!rowsPerPage ? (data | paginate: {itemsPerPage: rowsPerPage, currentPage: currentPage}) : data); last as last; let rowIndex = index"
9777
+ cdkDrag
9778
+ (click)="handleClickRow($event, rowIndex, row)" (dblclick)="handleDblClickRow($event, rowIndex, row)"
9779
+ (visibilityChange)="rowVisible.next(row)">
9780
+ <co-form class="simple-grid-row-form">
9781
+ <ng-container *ngIf="isSingleColumnRow(row)">
9782
+ <td class="simple-grid-single-column-cell" [attr.colspan]="headerColumnsCopy.length">
9783
+ <co-simple-grid-cell
9784
+ [column]="columns[singleColumnIndex(row)]"
9785
+ [row]="row"
9786
+ [editMode]="false"
9787
+ ></co-simple-grid-cell>
9788
+ </td>
9789
+ </ng-container>
9790
+ <ng-container *ngIf="!isSingleColumnRow(row)">
9791
+ <ng-container *ngFor="let column of headerColumnsCopy; let columnIndex = index">
9792
+ <td class="simple-grid-column-cell" *ngIf="columnIndex !== singleColumnIndex(row)">
9638
9793
  <co-simple-grid-cell
9639
- [column]="columns[singleColumnIndex(row)]"
9794
+ [column]="column"
9640
9795
  [row]="row"
9641
- [editMode]="false"
9796
+ [editMode]="inlineEdit && editing && rowIndex === editRowIndex"
9797
+ [fieldEditMode]="editCellIndex === columnIndex && rowIndex === editRowIndex"
9798
+ (cellClick)="handleCellClick($event, row, rowIndex, columnIndex)"
9642
9799
  ></co-simple-grid-cell>
9800
+ <div *ngIf="column.resizable" class="simple-grid-column-sizer-placeholder"></div>
9643
9801
  </td>
9644
9802
  </ng-container>
9645
- <ng-container *ngIf="!isSingleColumnRow(row)">
9646
- <ng-container *ngFor="let column of headerColumns; let columnIndex = index">
9647
- <td class="simple-grid-column-cell" *ngIf="columnIndex !== singleColumnIndex(row)">
9648
- <co-simple-grid-cell
9649
- [column]="column"
9650
- [row]="row"
9651
- [editMode]="inlineEdit && editing && rowIndex === editRowIndex"
9652
- [fieldEditMode]="editCellIndex === columnIndex && rowIndex === editRowIndex"
9653
- (cellClick)="handleCellClick($event, row, rowIndex, columnIndex)"
9654
- ></co-simple-grid-cell>
9655
- <div *ngIf="column.resizable" class="simple-grid-column-sizer-placeholder"></div>
9656
- </td>
9657
- </ng-container>
9658
- </ng-container>
9659
- </co-form>
9660
- </tr>
9803
+ </ng-container>
9804
+ <td></td>
9805
+ </co-form>
9806
+ </tr>
9661
9807
  </tbody>
9662
9808
  </table>
9663
9809
  <co-pagination-bar *ngIf="data?.length > rowsPerPage" class="pagination-bar"
@@ -9668,7 +9814,7 @@ SimpleGridComponent.decorators = [
9668
9814
  (previousClick)="goToPreviousPage()"
9669
9815
  (nextClick)="goToNextPage()"
9670
9816
  (pageClick)="setCurrentPage($event)"
9671
- ></co-pagination-bar>
9817
+ ></co-pagination-bar>
9672
9818
  `,
9673
9819
  providers: [
9674
9820
  FormMasterService
@@ -9678,6 +9824,7 @@ SimpleGridComponent.decorators = [
9678
9824
  },] }
9679
9825
  ];
9680
9826
  SimpleGridComponent.ctorParameters = () => [
9827
+ { type: IconCacheService },
9681
9828
  { type: ChangeDetectorRef },
9682
9829
  { type: FormMasterService }
9683
9830
  ];
@@ -10436,7 +10583,9 @@ SimpleGridModule.decorators = [
10436
10583
  ObserveVisibilityModule,
10437
10584
  PaginationModule,
10438
10585
  PaginationBarModule,
10439
- ClickoutsideModule
10586
+ ClickoutsideModule,
10587
+ ButtonModule,
10588
+ CoreComponentsTranslationModule
10440
10589
  ],
10441
10590
  declarations: [
10442
10591
  SimpleGridComponent,