@acorex/data-grid 6.5.23 → 6.5.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/karma.conf.js +32 -0
  2. package/ng-package.json +12 -0
  3. package/package.json +16 -36
  4. package/src/lib/data-grid/columns/check-column.component.ts +113 -0
  5. package/src/lib/data-grid/columns/column.component.ts +182 -0
  6. package/src/lib/data-grid/columns/command-column.component.ts +101 -0
  7. package/src/lib/data-grid/columns/date-column.component.ts +118 -0
  8. package/src/lib/data-grid/columns/row-number-column.component.ts +36 -0
  9. package/src/lib/data-grid/columns/selection-column.component.ts +39 -0
  10. package/src/lib/data-grid/columns/text-column.component.ts +92 -0
  11. package/src/lib/data-grid/datagrid.component.html +27 -0
  12. package/src/lib/data-grid/datagrid.component.ts +769 -0
  13. package/{lib/data-grid/datagrid.events.d.ts → src/lib/data-grid/datagrid.events.ts} +4 -1
  14. package/src/lib/data-grid/datagrid.module.ts +81 -0
  15. package/src/lib/data-grid/filters/filter.component.ts +21 -0
  16. package/src/lib/data-grid/templates/cell-template.component.ts +47 -0
  17. package/src/lib/data-grid/templates/detail-template.component.ts +43 -0
  18. package/src/lib/data-grid/templates/row-template.component.ts +41 -0
  19. package/src/lib/data-lov/data-lov-popup/data-lov-popup.component.html +16 -0
  20. package/src/lib/data-lov/data-lov-popup/data-lov-popup.component.ts +130 -0
  21. package/src/lib/data-lov/data-lov.component.html +61 -0
  22. package/src/lib/data-lov/data-lov.component.ts +184 -0
  23. package/src/lib/data-lov/data-lov.module.ts +16 -0
  24. package/{public-api.d.ts → src/public-api.ts} +3 -0
  25. package/src/test.ts +28 -0
  26. package/tsconfig.lib.json +23 -0
  27. package/tsconfig.lib.prod.json +6 -0
  28. package/tsconfig.spec.json +17 -0
  29. package/tslint.json +17 -0
  30. package/acorex-data-grid.d.ts +0 -5
  31. package/esm2020/acorex-data-grid.mjs +0 -5
  32. package/esm2020/lib/data-grid/columns/check-column.component.mjs +0 -117
  33. package/esm2020/lib/data-grid/columns/column.component.mjs +0 -164
  34. package/esm2020/lib/data-grid/columns/command-column.component.mjs +0 -115
  35. package/esm2020/lib/data-grid/columns/date-column.component.mjs +0 -111
  36. package/esm2020/lib/data-grid/columns/row-number-column.component.mjs +0 -37
  37. package/esm2020/lib/data-grid/columns/selection-column.component.mjs +0 -42
  38. package/esm2020/lib/data-grid/columns/text-column.component.mjs +0 -89
  39. package/esm2020/lib/data-grid/datagrid.component.mjs +0 -667
  40. package/esm2020/lib/data-grid/datagrid.events.mjs +0 -2
  41. package/esm2020/lib/data-grid/datagrid.module.mjs +0 -145
  42. package/esm2020/lib/data-grid/filters/filter.component.mjs +0 -39
  43. package/esm2020/lib/data-grid/templates/cell-template.component.mjs +0 -53
  44. package/esm2020/lib/data-grid/templates/detail-template.component.mjs +0 -46
  45. package/esm2020/lib/data-grid/templates/row-template.component.mjs +0 -43
  46. package/esm2020/lib/data-lov/data-lov-popup/data-lov-popup.component.mjs +0 -114
  47. package/esm2020/lib/data-lov/data-lov.component.mjs +0 -165
  48. package/esm2020/lib/data-lov/data-lov.module.mjs +0 -23
  49. package/esm2020/public-api.mjs +0 -18
  50. package/fesm2015/acorex-data-grid.mjs +0 -1881
  51. package/fesm2015/acorex-data-grid.mjs.map +0 -1
  52. package/fesm2020/acorex-data-grid.mjs +0 -1881
  53. package/fesm2020/acorex-data-grid.mjs.map +0 -1
  54. package/lib/data-grid/columns/check-column.component.d.ts +0 -37
  55. package/lib/data-grid/columns/column.component.d.ts +0 -32
  56. package/lib/data-grid/columns/command-column.component.d.ts +0 -27
  57. package/lib/data-grid/columns/date-column.component.d.ts +0 -32
  58. package/lib/data-grid/columns/row-number-column.component.d.ts +0 -10
  59. package/lib/data-grid/columns/selection-column.component.d.ts +0 -12
  60. package/lib/data-grid/columns/text-column.component.d.ts +0 -25
  61. package/lib/data-grid/datagrid.component.d.ts +0 -142
  62. package/lib/data-grid/datagrid.module.d.ts +0 -23
  63. package/lib/data-grid/filters/filter.component.d.ts +0 -5
  64. package/lib/data-grid/templates/cell-template.component.d.ts +0 -22
  65. package/lib/data-grid/templates/detail-template.component.d.ts +0 -21
  66. package/lib/data-grid/templates/row-template.component.d.ts +0 -20
  67. package/lib/data-lov/data-lov-popup/data-lov-popup.component.d.ts +0 -33
  68. package/lib/data-lov/data-lov.component.d.ts +0 -43
  69. package/lib/data-lov/data-lov.module.d.ts +0 -12
@@ -5,16 +5,19 @@ export interface AXGridRowEvent {
5
5
  }
6
6
  export interface AXGridRowCommandEvent extends AXGridRowEvent {
7
7
  command: string;
8
- htmlEvent: UIEvent;
8
+ htmlEvent:UIEvent
9
9
  }
10
10
  export interface AXGridCellEvent extends AXGridRowEvent {
11
11
  column: any;
12
12
  value: any;
13
13
  }
14
+
15
+
14
16
  export interface AXGridRowParams extends AXGridRowEvent {
15
17
  }
16
18
  export interface AXGridCellParams extends AXGridCellEvent {
17
19
  }
20
+
18
21
  export interface AXGridRowSelectionEvent {
19
22
  items: AXGridRowEvent[];
20
23
  }
@@ -0,0 +1,81 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { AXDataGridComponent } from './datagrid.component';
4
+ import { FormsModule } from '@angular/forms';
5
+ import { AgGridModule } from 'ag-grid-angular';
6
+ import { AXDataSourceModule } from '@acorex/components';
7
+ import { AXGridTextColumn, TextFilterRenderer } from './columns/text-column.component';
8
+ import { AXGridCheckColumn, BooleanRenderer, BooleanFilterRenderer } from './columns/check-column.component';
9
+ import { AXCoreModule } from '@acorex/core';
10
+ import { AXGridSelectionColumn } from './columns/selection-column.component';
11
+ import { CommandRenderer, AXGridCommandColumn } from './columns/command-column.component';
12
+ import { AXDataGridFilterComponent } from './filters/filter.component';
13
+ import { AXGridDateColumn, AXDatePickerFilterComponent } from './columns/date-column.component';
14
+ import { AXDataGridRowTemplateComponent, AXDataGridRowTemplateRenderer } from './templates/row-template.component';
15
+ import { AXDataGridCellTemplateComponent, AXDataGridCellTemplateRenderer } from './templates/cell-template.component';
16
+ import { AXDataGridDetailTemplateComponent, AXDataGridDetailTemplateRenderer } from './templates/detail-template.component';
17
+ import { AXTextBoxModule } from '@acorex/components';
18
+ import { AXCheckBoxModule } from '@acorex/components';
19
+ import { AXSelectBoxModule } from '@acorex/components';
20
+ import { AXButtonModule } from '@acorex/components';
21
+ import { AXDatePickerModule } from '@acorex/components';
22
+ import 'ag-grid-enterprise';
23
+ import { AXGridRowNumberColumn } from './columns/row-number-column.component';
24
+
25
+ @NgModule({
26
+ declarations: [
27
+ AXDataGridComponent,
28
+ AXGridTextColumn,
29
+ AXGridCheckColumn,
30
+ AXGridSelectionColumn,
31
+ AXGridDateColumn,
32
+ AXGridRowNumberColumn,
33
+ AXGridCommandColumn,
34
+ BooleanRenderer,
35
+ BooleanFilterRenderer,
36
+ TextFilterRenderer,
37
+ AXDataGridFilterComponent,
38
+ AXDataGridRowTemplateComponent,
39
+ AXDataGridDetailTemplateComponent,
40
+ AXDataGridRowTemplateRenderer,
41
+ AXDataGridDetailTemplateRenderer,
42
+ AXDataGridCellTemplateComponent,
43
+ AXDataGridCellTemplateRenderer,
44
+ AXDatePickerFilterComponent,
45
+ CommandRenderer
46
+ ],
47
+ imports: [
48
+ CommonModule,
49
+ AXCoreModule,
50
+ FormsModule,
51
+ //AgGridModule,
52
+ AXTextBoxModule,
53
+ AXCheckBoxModule,
54
+ AXSelectBoxModule,
55
+ AXDataSourceModule,
56
+ AXButtonModule,
57
+ AXDatePickerModule,
58
+ AgGridModule.withComponents([AXDatePickerFilterComponent])
59
+ ],
60
+ exports: [
61
+ AXDataGridComponent,
62
+ AXDataGridFilterComponent,
63
+ AXDataGridRowTemplateComponent,
64
+ AXDataGridDetailTemplateComponent,
65
+ AXDataGridRowTemplateRenderer,
66
+ AXDataGridDetailTemplateRenderer,
67
+ AXDataGridCellTemplateComponent,
68
+ AXDataGridCellTemplateRenderer,
69
+ AXGridTextColumn,
70
+ AXGridRowNumberColumn,
71
+ AXGridCheckColumn,
72
+ AXGridDateColumn,
73
+ AXGridSelectionColumn,
74
+ AXGridCommandColumn,
75
+ BooleanRenderer,
76
+ BooleanFilterRenderer,
77
+ CommandRenderer
78
+ ],
79
+ providers: []
80
+ })
81
+ export class AXDataGridModule {}
@@ -0,0 +1,21 @@
1
+ import { Component, ViewEncapsulation } from '@angular/core';
2
+
3
+
4
+ @Component({
5
+ selector: 'ax-data-grid-filter',
6
+ template: `
7
+ <div class='ax-grid-filter-container'>
8
+ <ng-content></ng-content>
9
+ <div class='btn-group' role='group'>
10
+ <button type='button' class='btn btn-primary btn-sm'>
11
+ <i class='fas fa-filter'></i>
12
+ </button>
13
+ <button type='button' class='btn btn-danger btn-sm'>
14
+ <i class='fas fa-trash-alt'></i>
15
+ </button>
16
+ </div>
17
+ </div>
18
+ `,
19
+ encapsulation: ViewEncapsulation.None
20
+ })
21
+ export class AXDataGridFilterComponent {}
@@ -0,0 +1,47 @@
1
+ import { Component, ContentChild, TemplateRef, ChangeDetectionStrategy } from '@angular/core';
2
+ import { ICellRendererAngularComp } from 'ag-grid-angular';
3
+ import { ICellRendererParams } from 'ag-grid-community';
4
+
5
+ @Component({
6
+ selector: 'ax-cell-template',
7
+ template: `<ng-content></ng-content>
8
+ `
9
+ })
10
+
11
+ export class AXDataGridCellTemplateComponent {
12
+ @ContentChild(TemplateRef, { static: true }) templateRef: TemplateRef<any>;
13
+ renderer: any;
14
+ params: any;
15
+ constructor() {
16
+ this.renderer = AXDataGridCellTemplateRenderer;
17
+ }
18
+ ngOnInit(): void {
19
+ this.params = {
20
+ templateRef: this.templateRef
21
+ }
22
+ }
23
+ }
24
+
25
+ @Component({
26
+ template: `
27
+ <ng-container *ngTemplateOutlet='templateRef; context: { $implicit: rowData }'>
28
+ </ng-container>
29
+ `
30
+ })
31
+
32
+ export class AXDataGridCellTemplateRenderer implements ICellRendererAngularComp {
33
+ rowData: any;
34
+ templateRef: TemplateRef<any>;
35
+
36
+ constructor() { }
37
+
38
+ agInit(params: ICellRendererParams): void {
39
+ this.rowData = params.data;
40
+ this.templateRef = (params as any).templateRef;
41
+ }
42
+
43
+ refresh(params: ICellRendererParams): boolean {
44
+ this.rowData = params.data;
45
+ return true;
46
+ }
47
+ }
@@ -0,0 +1,43 @@
1
+ import { Component, ContentChild, TemplateRef, Input, ChangeDetectorRef } from '@angular/core';
2
+ import { ICellRendererAngularComp } from 'ag-grid-angular';
3
+
4
+ @Component({
5
+ selector: 'ax-grid-detail-template',
6
+ template: `<ng-content></ng-content>`
7
+ })
8
+
9
+ export class AXDataGridDetailTemplateComponent {
10
+ @ContentChild(TemplateRef, { static: true }) templateRef: TemplateRef<any>;
11
+ renderer: any;
12
+ params: any;
13
+ constructor() {
14
+ this.renderer = AXDataGridDetailTemplateRenderer;
15
+ }
16
+ ngOnInit(): void {
17
+ this.params = {
18
+ templateRef: this.templateRef
19
+ }
20
+ }
21
+
22
+ @Input()
23
+ height: number = 100;
24
+ }
25
+
26
+ @Component({
27
+ template: `<ng-container *ngTemplateOutlet='templateRef; context: { $implicit: data }'></ng-container>`
28
+ })
29
+
30
+ export class AXDataGridDetailTemplateRenderer implements ICellRendererAngularComp {
31
+
32
+ refresh(params: any): boolean {
33
+ return false;
34
+ }
35
+
36
+ templateRef: TemplateRef<any>;
37
+ data: any;
38
+
39
+ agInit(params: any): void {
40
+ this.data = params.data;
41
+ this.templateRef = params.templateRef;
42
+ }
43
+ }
@@ -0,0 +1,41 @@
1
+ import { Component, ContentChild, TemplateRef, Input } from '@angular/core';
2
+ import { ICellRendererAngularComp } from 'ag-grid-angular';
3
+
4
+ @Component({
5
+ selector: 'ax-row-template',
6
+ template: `<ng-content></ng-content>`
7
+ })
8
+
9
+ export class AXDataGridRowTemplateComponent {
10
+ @ContentChild(TemplateRef, { static: true }) templateRef: TemplateRef<any>;
11
+ renderer: any;
12
+ params: any;
13
+ constructor() {
14
+ this.renderer = AXDataGridRowTemplateRenderer;
15
+ }
16
+ ngOnInit(): void {
17
+ this.params = {
18
+ templateRef: this.templateRef
19
+ }
20
+ }
21
+ }
22
+
23
+ @Component({
24
+ template: `<ng-container *ngTemplateOutlet='templateRef; context: { $implicit: data }'></ng-container>`
25
+ })
26
+
27
+ export class AXDataGridRowTemplateRenderer implements ICellRendererAngularComp {
28
+
29
+ templateRef: TemplateRef<any>;
30
+
31
+ data: any;
32
+
33
+ refresh(params: any): boolean {
34
+ return false;
35
+ }
36
+
37
+ agInit(params: any): void {
38
+ this.data = params.data.callRecords;
39
+ this.templateRef = params.templateRef;
40
+ }
41
+ }
@@ -0,0 +1,16 @@
1
+ <div style="height: 70vh; padding: 0.5em;">
2
+ <div style="height: calc(100%);">
3
+
4
+ <ax-data-grid [pagination]="pagination" [rtl]="rtl" [suppressRowClickSelection]="false" [keyField]="keyField"
5
+ [hasChildField]="hasChildField" [selectRow]="selectedItems" #grid [columns]="columns"
6
+ [remoteOperation]="true" [selectionMode]="selectionMode" (rowDbClick)="rowDoubleClicked($event)"
7
+ (rowSelectionChange)="rowSelectionChange($event)" [dataSource]="dataSource">
8
+ <ax-toolbar>
9
+ <ax-toolbar-search #searchBox style="width: 100%;"></ax-toolbar-search>
10
+ </ax-toolbar>
11
+ <ax-selection-column *ngIf="selectionMode== 'single'? false : true"></ax-selection-column>
12
+ <!-- <ax-data-source [provideData]="dataSource.provideData">
13
+ </ax-data-source> -->
14
+ </ax-data-grid>
15
+ </div>
16
+ </div>
@@ -0,0 +1,130 @@
1
+ import { Component, ViewChild, ChangeDetectorRef, ElementRef } from '@angular/core';
2
+ import { AXDataGridComponent, AXDataGridSelectionChangeEvent } from '../../data-grid/datagrid.component';
3
+ import { AXGridDataColumn } from '../../data-grid/columns/column.component';
4
+ import { AXTranslator, AXButtonItem, AXConfig } from '@acorex/core';
5
+ import {
6
+ AXToolbarSearchComponent,
7
+ AXBasePopupPageComponent,
8
+ AXMenuItemClickEvent,
9
+ AXDataSourceComponent,
10
+ AXDataSourceReadParams
11
+ } from '@acorex/components';
12
+
13
+ @Component({
14
+ templateUrl: './data-lov-popup.component.html'
15
+ })
16
+ export class AXDataLovPopupComponent extends AXBasePopupPageComponent {
17
+ @ViewChild('grid', { static: true })
18
+ grid: AXDataGridComponent;
19
+
20
+ @ViewChild('searchBox')
21
+ searchBox: AXToolbarSearchComponent;
22
+
23
+ columns: AXGridDataColumn[] = [];
24
+
25
+ selectedItems: any[] = [];
26
+
27
+ keyField: string = '';
28
+ allowNull: boolean = true;
29
+
30
+ hasChildField: string;
31
+ rtl: boolean = AXConfig.get('layout.rtl');
32
+
33
+ selectedRows: any[] = [];
34
+ pagination:boolean =true;
35
+ constructor(private cdr: ChangeDetectorRef, private ref: ElementRef) {
36
+ super();
37
+ }
38
+
39
+ dataSource: AXDataSourceComponent;
40
+
41
+ selectionMode: string;
42
+
43
+ ngOnInit(): void {
44
+ if (this.rtl == null) {
45
+ this.rtl = window.getComputedStyle(this.ref.nativeElement, null).getPropertyValue('direction') === 'rtl';
46
+ }
47
+ }
48
+
49
+ onDoneClick() {
50
+ if (this.selectedItems) {
51
+ this.close(this.selectedItems);
52
+ } else {
53
+ this.close();
54
+ }
55
+ }
56
+
57
+ rowDoubleClicked(e) {
58
+ if (this.selectionMode == 'single') {
59
+ this.selectedItems = [];
60
+ }
61
+
62
+ this.selectedItems = this.selectedItems.filter((c) => c[this.keyField] != e.data.data[this.keyField]);
63
+ this.selectedItems.push(e.data.data);
64
+
65
+ this.onDoneClick();
66
+ }
67
+
68
+ onCancelClick() {
69
+ this.close();
70
+ }
71
+
72
+ rowSelectionChange(e) {
73
+ if (e.data.node.selected == true) {
74
+ this.selectedItems = this.selectedItems.filter((c) => c[this.keyField] != e.data.node.data[this.keyField]);
75
+ this.selectedItems.push(e.data.node.data);
76
+ } else {
77
+ if (this.allowNull == true || (this.allowNull == false && this.selectedItems.length > 1)) {
78
+ this.selectedItems = this.selectedItems.filter((c) => c[this.keyField] != e.data.node.data[this.keyField]);
79
+ }
80
+ }
81
+ }
82
+
83
+ ngAfterViewInit() {
84
+ this.selectedItems.forEach((ele) => {
85
+ this.selectedRows.push(ele);
86
+ });
87
+ this.searchBox.focus();
88
+ if (this.dataSource.onDataReceived) {
89
+ this.dataSource.onDataReceived.subscribe((arg) => {
90
+ this.cdr.markForCheck();
91
+ this.cdr.detectChanges();
92
+ });
93
+ }
94
+ }
95
+
96
+ // onValueSearchChanged(e) {
97
+
98
+ // const params: AXDataSourceReadParams = {}
99
+ // params.searchText = e.value;
100
+ // // params.take = 100;
101
+ // // params.skip = 0
102
+ // this.dataSource.fetch(params);
103
+ // }
104
+
105
+ getFooterButtons(): AXButtonItem[] {
106
+ return [
107
+ {
108
+ text: AXTranslator.get('common.confirm'),
109
+ name: 'confirm',
110
+ style: 'ax primary',
111
+ icon: 'far fa-check-circle'
112
+ },
113
+ {
114
+ text: AXTranslator.get('common.cancel'),
115
+ name: 'cancel',
116
+ style: 'ax light',
117
+ icon: 'far fa-times'
118
+ }
119
+ ];
120
+ }
121
+
122
+ onFooterButtonClick(e: AXMenuItemClickEvent) {
123
+ if (e.name === 'confirm') {
124
+ this.onDoneClick();
125
+ }
126
+ if (e.name === 'cancel') {
127
+ this.onCancelClick();
128
+ }
129
+ }
130
+ }
@@ -0,0 +1,61 @@
1
+ <ax-select-box [rowInputTemplate]="rowTemplate" [rtl]="rtl" [allowSearch]="allowSearch" #selectBox [showDropDownButton]="false" [allowNull]="allowNull"
2
+ [remoteOperation]="true" [placeholder]="placeholder" [size]="size" [textField]="textField" [valueField]="valueField"
3
+ [disabled]="disabled" [mode]="mode" [(selectedItems)]="selectedItems"
4
+ (selectionChanged)="handleSelectChange($event)" [dataSource]="dataSource">
5
+ <ng-container start>
6
+ <ng-content select="[start]">
7
+ </ng-content>
8
+ </ng-container>
9
+ <ng-container end>
10
+ <ax-button icon="far fa-bars icon" [disabled]="disabled" type="light blank" (click)="handleButtonClick()" end
11
+ [tabIndex]="-1">
12
+ </ax-button>
13
+ <ng-content select="[end]">
14
+ </ng-content>
15
+ </ng-container>
16
+ </ax-select-box>
17
+
18
+
19
+ <!-- <ax-select-box2 [rtl]="rtl" [allowSearch]="allowSearch" #selectBox [showDropDownButton]="false" [allowNull]="allowNull"
20
+ [remoteOperation]="true" [placeholder]="placeholder" [size]="size" [textField]="textField" [valueField]="valueField"
21
+ [disabled]="disabled" [selectionMode]="mode" (onValueChanged)="handleSelectChange($event)" [dataSource]="dataSource"
22
+ [(value)]="selectedItems" selectionDataMode="item">
23
+ <ng-container start>
24
+ <ng-content select="[start]">
25
+ </ng-content>
26
+ </ng-container>
27
+ <ng-container end>
28
+ <ax-button icon="far fa-bars icon" [disabled]="disabled" type="primary blank" (click)="handleButtonClick()" end
29
+ [tabIndex]="-1">
30
+ </ax-button>
31
+ <ng-content select="[end]">
32
+ </ng-content>
33
+ </ng-container>
34
+ </ax-select-box2> -->
35
+
36
+
37
+ <!-- <div class="ax-lov-box" [style.display]="mode=='hidden' ? 'none':'unset'">
38
+ <div class="ax-field-set">
39
+ <div class="ax-field-set-wrapper" [ngClass]="{ 'no-label': !label }">
40
+ <fieldset [ngClass]="{ 'input-focused': isFocused, 'input-error': errorText }">
41
+ <legend *ngIf="label">
42
+ {{ label }}
43
+ </legend>
44
+ </fieldset>
45
+ <input type="text" [(ngModel)]="text" [placeholder]="placeholder" (keyup)="handleKeyEvent($event)"
46
+ (blur)="handleBlurEvent($event)" (focus)="handleFocusEvent($event)" class="ax-text-box" disabled />
47
+ <div class="ax-field-set-button">
48
+ <button *ngIf="text && allowClear" type="button" class="btn btn-light" (click)="clearText()">
49
+ <i class="far fa-times"></i>
50
+ </button>
51
+ <button type="button" class=" btn btn-primary" (click)="handleButtonClick($event)">
52
+ <i class="far fa-check-circle"></i>
53
+ </button>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ <div class="validation-text" *ngIf="errorText">
58
+ {{ errorText }}
59
+ </div>
60
+
61
+ </div> -->
@@ -0,0 +1,184 @@
1
+ import {
2
+ Component,
3
+ Input,
4
+ ContentChildren,
5
+ QueryList,
6
+ Output,
7
+ EventEmitter,
8
+ ContentChild,
9
+ ViewChild,
10
+ ViewEncapsulation,
11
+ ElementRef,
12
+ TemplateRef
13
+ } from '@angular/core';
14
+ import { AXPopupService, AXBaseInputComponent, AXBaseSizableComponent, AXElementSize, AXValidation } from '@acorex/components';
15
+ import { AXDataSourceComponent, AXSelectBoxComponent, AXDataEvent, AXValidatableComponent } from '@acorex/components';
16
+ import { AXDataLovPopupComponent } from './data-lov-popup/data-lov-popup.component';
17
+ import { AXGridDataColumn } from '../data-grid/columns/column.component';
18
+ import { AXConfig } from '@acorex/core';
19
+
20
+ @Component({
21
+ selector: 'ax-lov',
22
+ templateUrl: './data-lov.component.html',
23
+ encapsulation: ViewEncapsulation.None,
24
+ host: { style: 'width: 100%' },
25
+ providers: [{ provide: AXValidatableComponent, useExisting: AXLOVComponent }]
26
+ })
27
+ export class AXLOVComponent extends AXValidatableComponent implements AXBaseSizableComponent, AXBaseInputComponent {
28
+ @ContentChild(AXValidation, { static: true })
29
+ private _contentValidation: AXValidation;
30
+ private _validation: AXValidation;
31
+
32
+ @Input()
33
+ public get validation(): AXValidation {
34
+ return this._validation ? this._validation : this._contentValidation;
35
+ }
36
+ public set validation(v: AXValidation) {
37
+ this._validation = v;
38
+ }
39
+
40
+ constructor(private popup: AXPopupService, private ref: ElementRef) {
41
+ super();
42
+ }
43
+
44
+ @ViewChild('selectBox', { static: true })
45
+ selectBox: AXSelectBoxComponent;
46
+
47
+ @ContentChild(AXDataSourceComponent, { static: true })
48
+ dataSource: AXDataSourceComponent;
49
+
50
+ @ContentChildren(AXGridDataColumn)
51
+ private columns: QueryList<AXGridDataColumn>;
52
+
53
+ @ContentChild('itemTemplate', { static: true })
54
+ rowTemplate: TemplateRef<any>;
55
+
56
+ @Input()
57
+ textField: string = '';
58
+
59
+ @Input()
60
+ allowSearch: boolean = true;
61
+
62
+ @Input()
63
+ valueField: string = '';
64
+
65
+ @Input()
66
+ hasChildField: string = 'null';
67
+
68
+ @Input()
69
+ allowNull: boolean = true;
70
+
71
+ @Input()
72
+ popupSize: 'sm' | 'md' | 'lg' | 'full' = 'md';
73
+
74
+ @Input()
75
+ pagination:boolean =true;
76
+ @Input()
77
+ selectedItems: any[] = [];
78
+
79
+ // @Input()
80
+ // selectedValues: any[] = [];
81
+
82
+ @Input()
83
+ readonly: boolean = false;
84
+
85
+ @Input()
86
+ disabled: boolean = false;
87
+
88
+ @Input()
89
+ chipsWidth: string = '';
90
+
91
+ @Input()
92
+ size: AXElementSize = 'md';
93
+
94
+ @Input()
95
+ caption: string;
96
+
97
+ @Input()
98
+ mode: 'single' | 'multiple' = 'single';
99
+
100
+ @Input()
101
+ placeholder: string;
102
+
103
+ @Output()
104
+ onSelectionChange: EventEmitter<AXDataEvent<any>> = new EventEmitter<AXDataEvent<any>>();
105
+
106
+ @Input()
107
+ rtl: boolean = AXConfig.get('layout.rtl');
108
+
109
+ focus(): void {
110
+ this.selectBox.focus();
111
+ }
112
+
113
+ refresh() {
114
+ this.selectBox.refresh();
115
+ }
116
+
117
+ handleButtonClick() {
118
+ this.open();
119
+ }
120
+
121
+ ngOnInit(): void {
122
+ if (this.rtl == null) {
123
+ this.rtl = window.getComputedStyle(this.ref.nativeElement, null).getPropertyValue('direction') === 'rtl';
124
+ }
125
+ // this.selectVal = this.selectedValues;
126
+ this.onSelectionChange.subscribe((c) => {
127
+ this.clearValidationStyle(this.ref.nativeElement);
128
+ });
129
+ }
130
+
131
+ ngAfterContentInit(): void {
132
+ this.initValidation(this.ref, 'selectedItems', this.validation);
133
+ }
134
+
135
+ handleSelectChange(e) {
136
+ this.onSelectionChange.emit({ data: this.selectedItems, component: this, htmlElement: this.ref.nativeElement });
137
+ }
138
+
139
+ public open(): Promise<any> {
140
+ return new Promise((resolve) => {
141
+ this.selectBox.dropdown.close();
142
+ this.popup
143
+ .open(AXDataLovPopupComponent, {
144
+ size: this.popupSize,
145
+ // closable: false,
146
+ data: {
147
+ dataSource: this.dataSource,
148
+ selectionMode: this.mode,
149
+ columns: this.columns.toArray(),
150
+ // selectedItems: this.selectedValues,
151
+ selectedItems: this.selectedItems,
152
+ keyField: this.valueField,
153
+ allowNull: this.allowNull,
154
+ hasChildField: this.hasChildField,
155
+ rtl: this.rtl,
156
+ pagination:this.pagination
157
+ },
158
+ title: this.caption
159
+ // size: this.size,
160
+ })
161
+ .then((c) => {
162
+ if (c.data) {
163
+ // this.selectedValues = [];
164
+ this.selectedItems = [];
165
+ c.data.forEach((elm) => {
166
+ this.selectedItems.push(elm);
167
+ });
168
+ // this.selectedItems = c.data;
169
+ // this.selectBox.refresh();
170
+ this.onSelectionChange.emit({ data: this.selectedItems, component: this, htmlElement: this.ref.nativeElement });
171
+ if (resolve) {
172
+ resolve(c.data);
173
+ }
174
+ } else {
175
+ if (resolve) {
176
+ resolve(this.selectedItems);
177
+ }
178
+ }
179
+
180
+ this.selectBox.refresh();
181
+ });
182
+ });
183
+ }
184
+ }
@@ -0,0 +1,16 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { AXLOVComponent } from './data-lov.component';
4
+ import { FormsModule } from '@angular/forms';
5
+ import { AXDataLovPopupComponent } from './data-lov-popup/data-lov-popup.component';
6
+ import { AXDataGridModule } from '../data-grid/datagrid.module';
7
+ import { AXDataSourceModule, AXButtonModule, AXToolbarModule, AXSearchBoxModule, AXSelectBoxModule } from '@acorex/components';
8
+
9
+
10
+ @NgModule({
11
+ declarations: [AXLOVComponent, AXDataLovPopupComponent],
12
+ imports: [CommonModule, FormsModule, AXDataGridModule, AXDataSourceModule, AXButtonModule, AXToolbarModule, AXSelectBoxModule, AXSearchBoxModule],
13
+ exports: [AXLOVComponent, AXDataLovPopupComponent],
14
+ providers: []
15
+ })
16
+ export class AXLOVModule { }
@@ -5,13 +5,16 @@ export * from './lib/data-grid/columns/date-column.component';
5
5
  export * from './lib/data-grid/columns/selection-column.component';
6
6
  export * from './lib/data-grid/columns/text-column.component';
7
7
  export * from './lib/data-grid/columns/row-number-column.component';
8
+
8
9
  export * from './lib/data-grid/datagrid.component';
9
10
  export * from './lib/data-grid/datagrid.events';
10
11
  export * from './lib/data-grid/datagrid.module';
12
+
11
13
  export * from './lib/data-grid/filters/filter.component';
12
14
  export * from './lib/data-grid/templates/cell-template.component';
13
15
  export * from './lib/data-grid/templates/row-template.component';
14
16
  export * from './lib/data-grid/templates/detail-template.component';
17
+
15
18
  export * from './lib/data-lov/data-lov-popup/data-lov-popup.component';
16
19
  export * from './lib/data-lov/data-lov.component';
17
20
  export * from './lib/data-lov/data-lov.module';