@colijnit/corecomponents_v12 12.2.27 → 12.2.29

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;
@@ -9244,12 +9254,16 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
9244
9254
  this.showDelete = false;
9245
9255
  this.editOnCellClick = true;
9246
9256
  this.rightToolbar = false;
9257
+ this.showGridSettings = false;
9247
9258
  this.rowsPerPage = 1000;
9248
9259
  this.editing = false;
9260
+ this.isSettingsMenuOpen = false;
9249
9261
  this.editRowIndex = -1;
9250
9262
  this.editCellIndex = -1;
9251
9263
  this.selectedRowIndex = -1;
9252
9264
  this.currentPage = 1;
9265
+ this.sortDirection = 'asc';
9266
+ this.Icons = CoreComponentsIcon;
9253
9267
  this._doubleClicked = false;
9254
9268
  this._newRow = false;
9255
9269
  this.dataChanged.subscribe(() => {
@@ -9439,6 +9453,98 @@ class SimpleGridComponent extends BaseSimpleGridComponent {
9439
9453
  this._detectChanges();
9440
9454
  });
9441
9455
  }
9456
+ toggleSettingsMenu() {
9457
+ this.headerColumnsCopy.forEach(i => i.isSelected = false);
9458
+ this.isSettingsMenuOpen = !this.isSettingsMenuOpen;
9459
+ }
9460
+ toggleColumnMenu(col) {
9461
+ if (!this.showGridSettings) {
9462
+ return;
9463
+ }
9464
+ this.isSettingsMenuOpen = false;
9465
+ if (col.isSelected) {
9466
+ col.isSelected = false;
9467
+ }
9468
+ else {
9469
+ this.headerColumnsCopy.forEach(i => i.isSelected = false);
9470
+ col.isSelected = true;
9471
+ }
9472
+ }
9473
+ hideColumn(col) {
9474
+ col.isSelected = false;
9475
+ this.headerColumnsCopy = this.headerColumnsCopy.filter((obj) => {
9476
+ return obj !== col;
9477
+ });
9478
+ }
9479
+ // TODO Fix this sort method
9480
+ // public sortColumn(col: any, columnValue: string): void {
9481
+ // console.log(col);
9482
+ // console.log("columnValue " + columnValue);
9483
+ // col.isSelected = false;
9484
+ //
9485
+ // if (this.sortColumnValue === columnValue) {
9486
+ // this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
9487
+ // } else {
9488
+ // this.sortColumnValue = columnValue;
9489
+ // this.sortDirection = 'asc';
9490
+ // }
9491
+ //
9492
+ // console.log(this.data);
9493
+ // // this.data = this._sortData(this.data);
9494
+ //
9495
+ //
9496
+ // this.data.sort((a, b) => {
9497
+ // const sign = this.sortDirection === 'asc' ? 1 : -1;
9498
+ //
9499
+ // console.log("a " + a);
9500
+ // console.log("b " + b);
9501
+ // console.log(a[this.sortColumnValue]);
9502
+ // console.log(b[this.sortColumnValue]);
9503
+ // console.log("sign " + sign);
9504
+ //
9505
+ // if (a[this.sortColumnValue] < b[this.sortColumnValue]) {
9506
+ // return -1 * sign;
9507
+ // } else if (a[this.sortColumnValue] > b[this.sortColumnValue]) {
9508
+ // return 1 * sign;
9509
+ // }
9510
+ // return 0;
9511
+ // });
9512
+ //
9513
+ //
9514
+ //
9515
+ // this._detectChanges();
9516
+ // // this.data.sort((a, b) => a[this.sortColumnValue] - b[this.sortColumnValue]);
9517
+ // console.log(this.data);
9518
+ // }
9519
+ _sortData(tableData) {
9520
+ return tableData.sort((a, b) => {
9521
+ const sign = this.sortDirection === 'asc' ? 1 : -1;
9522
+ console.log("a " + a);
9523
+ console.log("b " + b);
9524
+ console.log(a[this.sortColumnValue]);
9525
+ console.log(b[this.sortColumnValue]);
9526
+ console.log("sign " + sign);
9527
+ if (a[this.sortColumnValue] < b[this.sortColumnValue]) {
9528
+ return -1 * sign;
9529
+ }
9530
+ else if (a[this.sortColumnValue] > b[this.sortColumnValue]) {
9531
+ return 1 * sign;
9532
+ }
9533
+ return 0;
9534
+ });
9535
+ }
9536
+ showAllColumns() {
9537
+ this.isSettingsMenuOpen = false;
9538
+ this.headerColumnsCopy = this.headerColumns;
9539
+ }
9540
+ exportToExcel() {
9541
+ this.isSettingsMenuOpen = false;
9542
+ let element = document.getElementById('simple-grid-table');
9543
+ const ws = XLSX.utils.table_to_sheet(element);
9544
+ const wb = XLSX.utils.book_new();
9545
+ XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
9546
+ XLSX.writeFile(wb, 'ExcelSheet.xlsx');
9547
+ }
9442
9548
  prepareDataRow(row, index) {
9443
9549
  this.isRowDisabled(row, index);
9444
9550
  }
@@ -9595,31 +9701,70 @@ SimpleGridComponent.decorators = [
9595
9701
  (cancelClick)="cancelEditRow()"
9596
9702
  (deleteClick)="removeRow()"
9597
9703
  ></co-grid-toolbar>
9598
- <table class="simple-grid-table" [clickOutside]="editing" (clickOutside)="handleClickOutsideRow()">
9704
+ <table
9705
+ id="simple-grid-table"
9706
+ class="simple-grid-table"
9707
+ [clickOutside]="editing"
9708
+ (clickOutside)="handleClickOutsideRow()">
9599
9709
  <colgroup>
9600
- <col *ngFor="let column of headerColumns; let index = index"
9710
+ <col *ngFor="let column of headerColumnsCopy; let index = index"
9601
9711
  [class.simple-grid-column-auto-fit]="column.autoFit"
9602
9712
  [style.width.px]="column.width"
9603
9713
  [style.min-width.px]="MIN_COLUMN_WIDTH">
9604
9714
  </colgroup>
9605
9715
  <thead>
9606
9716
  <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">
9717
+ <th
9718
+ scope="col"
9719
+ #headerCell
9720
+ class="simple-grid-column-header"
9721
+ *ngFor="let column of headerColumnsCopy; let index = index">
9722
+ <div
9723
+ class="simple-grid-column-header-wrapper"
9724
+ [class.resizable]="resizable"
9725
+ [class.selected]="column.isSelected"
9726
+ [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign">
9610
9727
  <ng-container *ngIf="column.headerTemplate; else noHeaderTemplate">
9611
9728
  <ng-container [ngTemplateOutlet]="column.headerTemplate"></ng-container>
9612
9729
  </ng-container>
9613
9730
  <ng-template #noHeaderTemplate>
9614
- <div class="simple-grid-column-header-label" [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign"
9731
+ <div class="simple-grid-column-header-label"
9732
+ [ngClass]="column.textAlign ? column.textAlign : defaultTextAlign"
9733
+ [class.with-menu]="showGridSettings"
9615
9734
  [textContent]="column.headerText || '&nbsp;'"
9616
- ></div>
9735
+ (click)="toggleColumnMenu(column)">
9736
+ </div>
9737
+
9738
+ <div class="column-menu" *ngIf="column.isSelected">
9739
+ <h3 [textContent]="'COLUMN_OPTIONS' | coreLocalize"></h3>
9740
+ <ul>
9741
+ <li (click)="hideColumn(column)">Hide Column</li>
9742
+ <!-- <li (click)="sortColumn(column, column.field)">Sort Column</li>-->
9743
+ </ul>
9744
+ </div>
9617
9745
  </ng-template>
9618
9746
  <div *ngIf="resizable && column.resizable" class="simple-grid-column-sizer"
9619
9747
  (mousedown)="handleSizerMouseDown($event, column)"
9620
9748
  ></div>
9621
9749
  </div>
9622
9750
  </th>
9751
+ <th *ngIf="showGridSettings" class="simple-grid-column-header grid-settings">
9752
+ <co-button
9753
+ [class.selected]="isSettingsMenuOpen"
9754
+ [iconData]="icons.getIcon(Icons.CogWheels)"
9755
+ (click)="toggleSettingsMenu()">
9756
+ </co-button>
9757
+
9758
+ <div class="settings-menu" *ngIf="isSettingsMenuOpen">
9759
+ <h3 [textContent]="'GRID_OPTIONS' | coreLocalize"></h3>
9760
+ <ul>
9761
+ <li (click)="exportToExcel()">Export to Excel</li>
9762
+ <li *ngIf="headerColumnsCopy.length !== headerColumns.length" (click)="showAllColumns()">Show All
9763
+ Columns
9764
+ </li>
9765
+ </ul>
9766
+ </div>
9767
+ </th>
9623
9768
  </tr>
9624
9769
  </thead>
9625
9770
  <tbody #dropList cdkDropList cdkDropListOrientation="vertical"
@@ -9628,36 +9773,42 @@ SimpleGridComponent.decorators = [
9628
9773
  [cdkDropListData]="data"
9629
9774
  [cdkDropListEnterPredicate]="handleCanDragDrop"
9630
9775
  (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">
9776
+ <tr
9777
+ class="simple-grid-row"
9778
+ [class.selected]="rowIndex === selectedRowIndex && !editing" observeVisibility
9779
+ [class.disabled]="getIsRowDisabled(rowIndex)"
9780
+ [class.editing]="rowIndex === editRowIndex"
9781
+ *ngFor="let row of (!!rowsPerPage ? (data | paginate: {itemsPerPage: rowsPerPage, currentPage: currentPage}) : data); last as last; let rowIndex = index"
9782
+ cdkDrag
9783
+ (click)="handleClickRow($event, rowIndex, row)" (dblclick)="handleDblClickRow($event, rowIndex, row)"
9784
+ (visibilityChange)="rowVisible.next(row)">
9785
+ <co-form class="simple-grid-row-form">
9786
+ <ng-container *ngIf="isSingleColumnRow(row)">
9787
+ <td class="simple-grid-single-column-cell" [attr.colspan]="headerColumnsCopy.length">
9788
+ <co-simple-grid-cell
9789
+ [column]="columns[singleColumnIndex(row)]"
9790
+ [row]="row"
9791
+ [editMode]="false"
9792
+ ></co-simple-grid-cell>
9793
+ </td>
9794
+ </ng-container>
9795
+ <ng-container *ngIf="!isSingleColumnRow(row)">
9796
+ <ng-container *ngFor="let column of headerColumnsCopy; let columnIndex = index">
9797
+ <td class="simple-grid-column-cell" *ngIf="columnIndex !== singleColumnIndex(row)">
9638
9798
  <co-simple-grid-cell
9639
- [column]="columns[singleColumnIndex(row)]"
9799
+ [column]="column"
9640
9800
  [row]="row"
9641
- [editMode]="false"
9801
+ [editMode]="inlineEdit && editing && rowIndex === editRowIndex"
9802
+ [fieldEditMode]="editCellIndex === columnIndex && rowIndex === editRowIndex"
9803
+ (cellClick)="handleCellClick($event, row, rowIndex, columnIndex)"
9642
9804
  ></co-simple-grid-cell>
9805
+ <div *ngIf="column.resizable" class="simple-grid-column-sizer-placeholder"></div>
9643
9806
  </td>
9644
9807
  </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>
9808
+ </ng-container>
9809
+ <td *ngIf="showGridSettings"></td>
9810
+ </co-form>
9811
+ </tr>
9661
9812
  </tbody>
9662
9813
  </table>
9663
9814
  <co-pagination-bar *ngIf="data?.length > rowsPerPage" class="pagination-bar"
@@ -9668,7 +9819,7 @@ SimpleGridComponent.decorators = [
9668
9819
  (previousClick)="goToPreviousPage()"
9669
9820
  (nextClick)="goToNextPage()"
9670
9821
  (pageClick)="setCurrentPage($event)"
9671
- ></co-pagination-bar>
9822
+ ></co-pagination-bar>
9672
9823
  `,
9673
9824
  providers: [
9674
9825
  FormMasterService
@@ -9678,6 +9829,7 @@ SimpleGridComponent.decorators = [
9678
9829
  },] }
9679
9830
  ];
9680
9831
  SimpleGridComponent.ctorParameters = () => [
9832
+ { type: IconCacheService },
9681
9833
  { type: ChangeDetectorRef },
9682
9834
  { type: FormMasterService }
9683
9835
  ];
@@ -9687,6 +9839,7 @@ SimpleGridComponent.propDecorators = {
9687
9839
  showDelete: [{ type: Input }],
9688
9840
  editOnCellClick: [{ type: Input }],
9689
9841
  rightToolbar: [{ type: Input }],
9842
+ showGridSettings: [{ type: Input }],
9690
9843
  rowsPerPage: [{ type: Input }],
9691
9844
  rowDisabledFn: [{ type: Input }],
9692
9845
  canRowBeEdittedFn: [{ type: Input }],
@@ -10436,7 +10589,9 @@ SimpleGridModule.decorators = [
10436
10589
  ObserveVisibilityModule,
10437
10590
  PaginationModule,
10438
10591
  PaginationBarModule,
10439
- ClickoutsideModule
10592
+ ClickoutsideModule,
10593
+ ButtonModule,
10594
+ CoreComponentsTranslationModule
10440
10595
  ],
10441
10596
  declarations: [
10442
10597
  SimpleGridComponent,