mat-table-ext 0.0.9 → 0.0.11
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.
- package/esm2020/lib/components/column-pinning/column-pinning.component.mjs +58 -0
- package/esm2020/lib/components/editing/editing.component.mjs +122 -0
- package/esm2020/lib/components/filter-columns-component/filter-columns-component.component.mjs +68 -0
- package/esm2020/lib/directives/resize-column.directive.mjs +99 -0
- package/esm2020/lib/mat-table-ext.component.mjs +1020 -0
- package/esm2020/lib/mat-table-ext.module.mjs +237 -0
- package/esm2020/lib/mat-table-ext.service.mjs +20 -0
- package/esm2020/lib/models/tableExtModels.mjs +2 -0
- package/esm2020/mat-table-ext.mjs +5 -0
- package/esm2020/public-api.mjs +11 -0
- package/fesm2015/mat-table-ext.mjs +1584 -0
- package/fesm2015/mat-table-ext.mjs.map +1 -0
- package/fesm2020/mat-table-ext.mjs +1581 -0
- package/fesm2020/mat-table-ext.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/components/column-pinning/column-pinning.component.d.ts +27 -0
- package/lib/components/editing/editing.component.d.ts +42 -0
- package/lib/components/filter-columns-component/filter-columns-component.component.d.ts +26 -0
- package/lib/directives/resize-column.directive.d.ts +27 -0
- package/lib/mat-table-ext.component.d.ts +348 -0
- package/lib/mat-table-ext.module.d.ts +58 -0
- package/lib/mat-table-ext.service.d.ts +11 -0
- package/lib/models/tableExtModels.d.ts +76 -0
- package/package.json +58 -46
- package/{projects/mat-table-ext/src/public-api.ts → public-api.d.ts} +1 -5
- package/.editorconfig +0 -16
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/tasks.json +0 -42
- package/LICENSE +0 -21
- package/angular.json +0 -150
- package/projects/mat-table-ext/.browserslistrc +0 -16
- package/projects/mat-table-ext/README.md +0 -57
- package/projects/mat-table-ext/karma.conf.js +0 -44
- package/projects/mat-table-ext/ng-package.json +0 -9
- package/projects/mat-table-ext/package.json +0 -38
- package/projects/mat-table-ext/src/lib/components/column-pinning/column-pinning.component.html +0 -7
- package/projects/mat-table-ext/src/lib/components/column-pinning/column-pinning.component.scss +0 -9
- package/projects/mat-table-ext/src/lib/components/column-pinning/column-pinning.component.spec.ts +0 -23
- package/projects/mat-table-ext/src/lib/components/column-pinning/column-pinning.component.ts +0 -48
- package/projects/mat-table-ext/src/lib/components/editing/editing.component.html +0 -55
- package/projects/mat-table-ext/src/lib/components/editing/editing.component.scss +0 -19
- package/projects/mat-table-ext/src/lib/components/editing/editing.component.spec.ts +0 -23
- package/projects/mat-table-ext/src/lib/components/editing/editing.component.ts +0 -110
- package/projects/mat-table-ext/src/lib/components/filter-columns-component/filter-columns-component.component.html +0 -26
- package/projects/mat-table-ext/src/lib/components/filter-columns-component/filter-columns-component.component.scss +0 -0
- package/projects/mat-table-ext/src/lib/components/filter-columns-component/filter-columns-component.component.spec.ts +0 -23
- package/projects/mat-table-ext/src/lib/components/filter-columns-component/filter-columns-component.component.ts +0 -54
- package/projects/mat-table-ext/src/lib/directives/resize-column.directive.ts +0 -103
- package/projects/mat-table-ext/src/lib/mat-table-ext.component.html +0 -285
- package/projects/mat-table-ext/src/lib/mat-table-ext.component.spec.ts +0 -25
- package/projects/mat-table-ext/src/lib/mat-table-ext.component.ts +0 -985
- package/projects/mat-table-ext/src/lib/mat-table-ext.module.ts +0 -127
- package/projects/mat-table-ext/src/lib/mat-table-ext.scss +0 -181
- package/projects/mat-table-ext/src/lib/mat-table-ext.service.spec.ts +0 -16
- package/projects/mat-table-ext/src/lib/mat-table-ext.service.ts +0 -12
- package/projects/mat-table-ext/src/lib/models/tableExtModels.ts +0 -85
- package/projects/mat-table-ext/src/test.ts +0 -27
- package/projects/mat-table-ext/tsconfig.lib.json +0 -15
- package/projects/mat-table-ext/tsconfig.lib.prod.json +0 -10
- package/projects/mat-table-ext/tsconfig.spec.json +0 -17
- package/projects/mat-table-ext-example/.browserslistrc +0 -16
- package/projects/mat-table-ext-example/karma.conf.js +0 -44
- package/projects/mat-table-ext-example/src/app/app.component.html +0 -576
- package/projects/mat-table-ext-example/src/app/app.component.scss +0 -0
- package/projects/mat-table-ext-example/src/app/app.component.spec.ts +0 -31
- package/projects/mat-table-ext-example/src/app/app.component.ts +0 -173
- package/projects/mat-table-ext-example/src/app/app.module.ts +0 -40
- package/projects/mat-table-ext-example/src/app/service/custom-table.service.spec.ts +0 -16
- package/projects/mat-table-ext-example/src/app/service/custom-table.service.ts +0 -18
- package/projects/mat-table-ext-example/src/assets/.gitkeep +0 -0
- package/projects/mat-table-ext-example/src/assets/data.json +0 -100003
- package/projects/mat-table-ext-example/src/environments/environment.prod.ts +0 -3
- package/projects/mat-table-ext-example/src/environments/environment.ts +0 -16
- package/projects/mat-table-ext-example/src/favicon.ico +0 -0
- package/projects/mat-table-ext-example/src/index.html +0 -14
- package/projects/mat-table-ext-example/src/main.ts +0 -12
- package/projects/mat-table-ext-example/src/polyfills.ts +0 -53
- package/projects/mat-table-ext-example/src/styles.scss +0 -23
- package/projects/mat-table-ext-example/src/test.ts +0 -26
- package/projects/mat-table-ext-example/tsconfig.app.json +0 -15
- package/projects/mat-table-ext-example/tsconfig.spec.json +0 -18
- package/tsconfig.json +0 -38
- /package/{projects/mat-table-ext/assets → assets}/_theming.scss +0 -0
- /package/{projects/mat-table-ext/assets → assets}/pinIcon.svg +0 -0
- /package/{projects/mat-table-ext/assets → assets}/pinLeft.svg +0 -0
- /package/{projects/mat-table-ext/assets → assets}/pinNone.svg +0 -0
- /package/{projects/mat-table-ext/assets → assets}/pinRight.svg +0 -0
- /package/{projects/mat-table-ext/assets → assets}/pinned.svg +0 -0
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { Component, Inject, OnInit, TemplateRef } from '@angular/core';
|
|
2
|
-
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
|
3
|
-
import { MTExColumn } from '../../models/tableExtModels';
|
|
4
|
-
import { MatTableExtService } from '../../mat-table-ext.service';
|
|
5
|
-
|
|
6
|
-
@Component({
|
|
7
|
-
selector: 'app-editing',
|
|
8
|
-
templateUrl: './editing.component.html',
|
|
9
|
-
styleUrls: ['./editing.component.scss'],
|
|
10
|
-
})
|
|
11
|
-
export class EditingComponent implements OnInit {
|
|
12
|
-
public templateRef!: TemplateRef<any>;
|
|
13
|
-
public keys: string[] = [];
|
|
14
|
-
public templateKeys: string[] = [];
|
|
15
|
-
public types: any = {};
|
|
16
|
-
public templateTypes: any = {};
|
|
17
|
-
public columns: MTExColumn[] = [];
|
|
18
|
-
public templateRow: any = {};
|
|
19
|
-
|
|
20
|
-
constructor(
|
|
21
|
-
public dialogRef: MatDialogRef<EditingComponent>,
|
|
22
|
-
@Inject(MAT_DIALOG_DATA) public dialogData: any,
|
|
23
|
-
public service: MatTableExtService
|
|
24
|
-
) { }
|
|
25
|
-
|
|
26
|
-
ngOnInit(): void {
|
|
27
|
-
this.setData(this.dialogData);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* @description This method is used to set data for editing.
|
|
31
|
-
* @param value dialog Data
|
|
32
|
-
*/
|
|
33
|
-
setData(value: any) {
|
|
34
|
-
let row = value.row;
|
|
35
|
-
let types: any = {};
|
|
36
|
-
this.keys = [];
|
|
37
|
-
this.columns = value.columns;
|
|
38
|
-
this.columns.forEach((column) => {
|
|
39
|
-
this.keys.push(column.field);
|
|
40
|
-
if (column.type == 'selection') {
|
|
41
|
-
types[column.field] = column.type;
|
|
42
|
-
let temp = row[column.field];
|
|
43
|
-
row[column.field] = {
|
|
44
|
-
value: temp,
|
|
45
|
-
options: column.options,
|
|
46
|
-
};
|
|
47
|
-
} else {
|
|
48
|
-
types[column.field] = column.type;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
this.types = types;
|
|
52
|
-
this.setTemplateRef(value);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* @description This method is used to set the data when data comes in from cus template.
|
|
56
|
-
* @param value template value
|
|
57
|
-
*/
|
|
58
|
-
setTemplateRef(value: any) {
|
|
59
|
-
if (value.templateRef !== undefined) {
|
|
60
|
-
this.templateRow = { ...value.row };
|
|
61
|
-
let types: any = {};
|
|
62
|
-
this.templateKeys = [];
|
|
63
|
-
this.columns.forEach((column) => {
|
|
64
|
-
this.templateKeys.push(column.field);
|
|
65
|
-
if (column.type == 'selection') {
|
|
66
|
-
types[column.field] = column.type;
|
|
67
|
-
let temp = this.templateRow[column.field];
|
|
68
|
-
this.templateRow[column.field] = {
|
|
69
|
-
value: temp,
|
|
70
|
-
options: column.options,
|
|
71
|
-
};
|
|
72
|
-
} else {
|
|
73
|
-
types[column.field] = column.type;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
this.templateTypes = types;
|
|
77
|
-
this.templateRef = value.templateRef;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* @description This method is triggered when dialog is closed and also emits the dialog closed event data.
|
|
82
|
-
*/
|
|
83
|
-
closeDialog() {
|
|
84
|
-
let rowData = { ...this.dialogData.row };
|
|
85
|
-
this.keys.forEach((key: any) => {
|
|
86
|
-
if (this.types[key] === 'selection') {
|
|
87
|
-
let temp = rowData[key].value;
|
|
88
|
-
rowData[key] = temp;
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
this.dialogRef.close(rowData);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @description This method is called when the dialog is closed custom template action.
|
|
96
|
-
* @param row row to be edited.
|
|
97
|
-
* @param keys keys of columns
|
|
98
|
-
* @param types column types
|
|
99
|
-
*/
|
|
100
|
-
closeTemplateDialog(row: any, keys: string[], types: string[]) {
|
|
101
|
-
let rowData = { ...row };
|
|
102
|
-
keys.forEach((key: any) => {
|
|
103
|
-
if (types[key] === 'selection') {
|
|
104
|
-
let temp = rowData[key].value;
|
|
105
|
-
rowData[key] = temp;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
this.dialogRef.close(rowData);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<ng-container *ngIf="obj">
|
|
3
|
-
<!-- Number Type -->
|
|
4
|
-
<mat-form-field *ngIf="obj.type == 'number'" appearance="outline" class="inline-editing-field" >
|
|
5
|
-
<input matInput type="number" [formControl]="numberCtrl">
|
|
6
|
-
</mat-form-field>
|
|
7
|
-
|
|
8
|
-
<!-- String Type -->
|
|
9
|
-
<mat-form-field *ngIf="obj.type == 'string'" appearance="outline" class="inline-editing-field">
|
|
10
|
-
<input matInput type="text" [formControl]="stringCtrl">
|
|
11
|
-
</mat-form-field>
|
|
12
|
-
<mat-form-field *ngIf="obj.type == 'date'" appearance="outline" class="inline-editing-field">
|
|
13
|
-
<input matInput type="date" [formControl]="dateCtrl">
|
|
14
|
-
</mat-form-field>
|
|
15
|
-
<!-- Selection Type -->
|
|
16
|
-
<mat-form-field *ngIf="obj.type == 'selection'" appearance="outline" class="inline-editing-field">
|
|
17
|
-
<mat-select [value]="" [formControl]="selectionCtrl">
|
|
18
|
-
<mat-option *ngFor="let option of obj.options" [value]="option">
|
|
19
|
-
{{option}}
|
|
20
|
-
</mat-option>
|
|
21
|
-
</mat-select>
|
|
22
|
-
</mat-form-field>
|
|
23
|
-
<!-- Boolean Type -->
|
|
24
|
-
<mat-checkbox (click)="$event.stopPropagation()" *ngIf="obj.type == 'boolean'" color="primary" [formControl]="booleanCtrl"></mat-checkbox>
|
|
25
|
-
|
|
26
|
-
</ng-container>
|
|
File without changes
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { FilterColumnsComponentComponent } from './filter-columns-component.component';
|
|
4
|
-
|
|
5
|
-
describe('FilterColumnsComponentComponent', () => {
|
|
6
|
-
let component: FilterColumnsComponentComponent;
|
|
7
|
-
let fixture: ComponentFixture<FilterColumnsComponentComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
declarations: [ FilterColumnsComponentComponent ]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
|
|
15
|
-
fixture = TestBed.createComponent(FilterColumnsComponentComponent);
|
|
16
|
-
component = fixture.componentInstance;
|
|
17
|
-
fixture.detectChanges();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should create', () => {
|
|
21
|
-
expect(component).toBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
2
|
-
import { FormControl } from '@angular/forms';
|
|
3
|
-
|
|
4
|
-
@Component({
|
|
5
|
-
selector: 'app-filter-columns-component',
|
|
6
|
-
templateUrl: './filter-columns-component.component.html',
|
|
7
|
-
styleUrls: ['./filter-columns-component.component.scss'],
|
|
8
|
-
})
|
|
9
|
-
export class FilterColumnsComponentComponent implements OnInit {
|
|
10
|
-
@Input() obj!: any;
|
|
11
|
-
@Output() filterOutput: EventEmitter<any> = new EventEmitter<any>();
|
|
12
|
-
stringCtrl: FormControl = new FormControl();
|
|
13
|
-
numberCtrl: FormControl = new FormControl();
|
|
14
|
-
dateCtrl: FormControl = new FormControl();
|
|
15
|
-
booleanCtrl: FormControl = new FormControl();
|
|
16
|
-
selectionCtrl: FormControl = new FormControl();
|
|
17
|
-
constructor() {}
|
|
18
|
-
ngOnInit(): void {
|
|
19
|
-
this.stringCtrl.valueChanges.subscribe((value) => {
|
|
20
|
-
this.checkValue(value);
|
|
21
|
-
});
|
|
22
|
-
this.dateCtrl.valueChanges.subscribe((value) => {
|
|
23
|
-
this.checkValue(value);
|
|
24
|
-
});
|
|
25
|
-
this.numberCtrl.valueChanges.subscribe((value) => {
|
|
26
|
-
this.checkValue(value);
|
|
27
|
-
});
|
|
28
|
-
this.booleanCtrl.valueChanges.subscribe((value) => {
|
|
29
|
-
this.checkValue(value);
|
|
30
|
-
});
|
|
31
|
-
this.selectionCtrl.valueChanges.subscribe((value) => {
|
|
32
|
-
this.checkValue(value);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @description This method is make value is valid and not null.
|
|
37
|
-
* @param value value to check its type.
|
|
38
|
-
*/
|
|
39
|
-
checkValue(value: any) {
|
|
40
|
-
if (value || value == '') {
|
|
41
|
-
this.emitOutput(value);
|
|
42
|
-
} else if (value == null) {
|
|
43
|
-
this.emitOutput('');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @description This method will emit seach value to parent component.
|
|
48
|
-
* @param value value on which base table rows are filtered.
|
|
49
|
-
*/
|
|
50
|
-
emitOutput(value: any) {
|
|
51
|
-
let obj = { [this.obj.field]: value };
|
|
52
|
-
this.filterOutput.emit(obj);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { Directive, OnInit, Renderer2, Input, ElementRef, OnChanges } from "@angular/core";
|
|
2
|
-
|
|
3
|
-
@Directive({
|
|
4
|
-
selector: "[columnsResizable]"
|
|
5
|
-
})
|
|
6
|
-
export class ResizeColumnDirective implements OnInit, OnChanges {
|
|
7
|
-
columnsResizable$: boolean = false;
|
|
8
|
-
@Input() set columnsResizable(val: boolean) {
|
|
9
|
-
this.columnsResizable$ = val;
|
|
10
|
-
}
|
|
11
|
-
get columnsResizable() {
|
|
12
|
-
return this.columnsResizable$;
|
|
13
|
-
}
|
|
14
|
-
@Input() index!: number;
|
|
15
|
-
private startX!: number;
|
|
16
|
-
private startWidth!: number;
|
|
17
|
-
private column: HTMLElement;
|
|
18
|
-
private table!: HTMLElement;
|
|
19
|
-
private pressed!: boolean;
|
|
20
|
-
|
|
21
|
-
constructor(private renderer: Renderer2, private el: ElementRef) {
|
|
22
|
-
this.column = this.el.nativeElement;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
ngOnInit() {
|
|
26
|
-
if (this.columnsResizable$) {
|
|
27
|
-
const row = this.renderer.parentNode(this.column);
|
|
28
|
-
const thead = this.renderer.parentNode(row);
|
|
29
|
-
this.table = this.renderer.parentNode(thead);
|
|
30
|
-
|
|
31
|
-
const resizer = this.renderer.createElement("span");
|
|
32
|
-
this.renderer.addClass(resizer, "resize-holder");
|
|
33
|
-
this.renderer.setAttribute(resizer, 'id', "resizeHolderSpan");
|
|
34
|
-
this.renderer.appendChild(this.column, resizer);
|
|
35
|
-
this.renderer.listen(resizer, "mousedown", this.onMouseDown);
|
|
36
|
-
this.renderer.listen(this.table, "mousemove", this.onMouseMove);
|
|
37
|
-
this.renderer.listen("document", "mouseup", this.onMouseUp);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this.removeDragElementFromDom();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
ngOnChanges() {
|
|
44
|
-
if (this.columnsResizable$) {
|
|
45
|
-
const row = this.renderer.parentNode(this.column);
|
|
46
|
-
const thead = this.renderer.parentNode(row);
|
|
47
|
-
const resizer = this.renderer.createElement("span");
|
|
48
|
-
this.table = this.renderer.parentNode(thead);
|
|
49
|
-
this.renderer.addClass(resizer, "resize-holder");
|
|
50
|
-
this.renderer.setAttribute(resizer, 'id', "resizeHolderSpan");
|
|
51
|
-
this.renderer.appendChild(this.column, resizer);
|
|
52
|
-
this.renderer.listen(resizer, "mousedown", this.onMouseDown);
|
|
53
|
-
this.renderer.listen(this.table, "mousemove", this.onMouseMove);
|
|
54
|
-
this.renderer.listen("document", "mouseup", this.onMouseUp);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
this.removeDragElementFromDom();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
onMouseDown = (event: MouseEvent) => {
|
|
62
|
-
this.pressed = true;
|
|
63
|
-
this.startX = event.pageX;
|
|
64
|
-
this.startWidth = this.column.offsetWidth;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
onMouseMove = (event: MouseEvent) => {
|
|
68
|
-
const offset = 5;
|
|
69
|
-
if (this.pressed && event.buttons) {
|
|
70
|
-
this.renderer.addClass(this.table, "resizing");
|
|
71
|
-
// Calculate width of column
|
|
72
|
-
let width =
|
|
73
|
-
this.startWidth + (event.pageX - this.startX - offset);
|
|
74
|
-
const tableCells = Array.from(this.table.querySelectorAll(".mat-row")).map(
|
|
75
|
-
(row: any) => row.querySelectorAll(".mat-cell").item(this.index)
|
|
76
|
-
);
|
|
77
|
-
// Set table header width
|
|
78
|
-
this.renderer.setStyle(this.column, "width", `${width}px`);
|
|
79
|
-
// Set table cells width
|
|
80
|
-
for (const cell of tableCells) {
|
|
81
|
-
if (cell && cell !== null)
|
|
82
|
-
this.renderer.setStyle(cell, "width", `${width}px`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
onMouseUp = (event: MouseEvent) => {
|
|
88
|
-
if (this.pressed) {
|
|
89
|
-
this.pressed = false;
|
|
90
|
-
this.renderer.removeClass(this.table, "resizing");
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* @description This method is used remove resizing handlers from the table headers when column resizing is disabled.
|
|
95
|
-
*/
|
|
96
|
-
removeDragElementFromDom() {
|
|
97
|
-
let ele = document.getElementById('resizeHolderSpan')
|
|
98
|
-
if (ele && ele !== null && ele !== undefined) {
|
|
99
|
-
this.renderer.removeChild(this.column, ele);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
<div [style.width]="tableWidth">
|
|
2
|
-
<mat-form-field class="global-search-field" appearance="fill" *ngIf="globalSearch">
|
|
3
|
-
<mat-label>Search</mat-label>
|
|
4
|
-
<input matInput [ngModel]="globalFilter" (ngModelChange)="applyGlobalFilter($event)" placeholder="Ex. Mia" #input>
|
|
5
|
-
</mat-form-field>
|
|
6
|
-
<mat-toolbar class="toolbar-container" *ngIf="showToolbar" [style.height]="toolbarHeight?toolbarHeight:'50px'">
|
|
7
|
-
<span class="toolbar-title" *ngIf="toolbarTitle">{{toolbarTitle}}</span>
|
|
8
|
-
<ng-container *ngIf="toolbarTemplateRef" [ngTemplateOutlet]="toolbarTemplateRef"></ng-container>
|
|
9
|
-
<span class="example-spacer"></span>
|
|
10
|
-
<ng-container *ngIf="rowSelection || multiRowSelection">
|
|
11
|
-
<button class="hide-button" mat-stroked-button color="primary" (click)="hideSelectedRows()">
|
|
12
|
-
Hide Rows
|
|
13
|
-
</button>
|
|
14
|
-
<button class="hide-button" mat-stroked-button color="primary" (click)="showHiddenRows()">
|
|
15
|
-
Show All Rows
|
|
16
|
-
</button>
|
|
17
|
-
</ng-container>
|
|
18
|
-
<button *ngIf="columnHidable" class="hide-button" mat-stroked-button color="primary"
|
|
19
|
-
(click)="openMenu('hideShow',$event)" matTooltip="Column Visibility" matTooltipPosition="above">
|
|
20
|
-
<mat-icon>visibility</mat-icon>
|
|
21
|
-
</button>
|
|
22
|
-
<button *ngIf="columnPinnable" class="pin-button" mat-stroked-button color="primary"
|
|
23
|
-
(click)="openMenu('columnPin',$event)" matTooltip="Column Pinning">
|
|
24
|
-
<mat-icon svgIcon="pinIcon"></mat-icon>
|
|
25
|
-
</button>
|
|
26
|
-
<button *ngIf="exportButtonEnable" class="export-button" mat-stroked-button color="primary"
|
|
27
|
-
(click)="openMenu('export',$event)" matTooltip="Table Data Export">
|
|
28
|
-
<mat-icon>import_export</mat-icon> <span>Export</span>
|
|
29
|
-
<mat-icon>expand_more</mat-icon>
|
|
30
|
-
</button>
|
|
31
|
-
<div style="visibility: hidden; position:fixed" [matMenuTriggerFor]="menu" [style.left.px]="menuX"
|
|
32
|
-
[style.top.px]="menuY"></div>
|
|
33
|
-
</mat-toolbar>
|
|
34
|
-
<mat-menu #menu="matMenu" (closed)="menuClosed()" id="exportMenu">
|
|
35
|
-
<ng-container *ngIf="exportMenuCtrl">
|
|
36
|
-
<mat-option (click)="exportTable('xlsx')">Export to Excel</mat-option>
|
|
37
|
-
<mat-option (click)="exportTable('csv')">Export to CSV</mat-option>
|
|
38
|
-
</ng-container>
|
|
39
|
-
</mat-menu>
|
|
40
|
-
<div style="visibility: hidden; position:fixed" #columnMenuTrigger="matMenuTrigger" [matMenuTriggerFor]="columnMenu"
|
|
41
|
-
[style.left.px]="menuX" [style.top.px]="menuY">
|
|
42
|
-
</div>
|
|
43
|
-
<mat-menu #columnMenu="matMenu" (closed)="resetMenuChecks()">
|
|
44
|
-
<div class="toolbar-menu-container" *ngIf="hideShowMenuCtrl" [formGroup]="hideShowMenuGroup"
|
|
45
|
-
(click)="$event.stopPropagation()">
|
|
46
|
-
<h4 class="column-headers">Visible Columns</h4>
|
|
47
|
-
<mat-form-field appearance="fill" style="width: -webkit-fill-available;">
|
|
48
|
-
<mat-label>Filter Columns</mat-label>
|
|
49
|
-
<input matInput [(ngModel)]="showHideFilter" (ngModelChange)="filterColumns($event)"
|
|
50
|
-
[ngModelOptions]="{standalone: true}">
|
|
51
|
-
</mat-form-field>
|
|
52
|
-
<div class="showHide-menu-columns-list">
|
|
53
|
-
<div class="toolbar-menu-item" *ngFor="let column of showHideColumnsArray">
|
|
54
|
-
<mat-checkbox color="primary" class="toolbar-menu-checkbox" style="width: max-content;"
|
|
55
|
-
[formControlName]="column.field" (change)="setColumnHideShow()">{{column.header}}</mat-checkbox>
|
|
56
|
-
</div>
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
<div class="toolbar-menu-container" *ngIf="columnPinMenuCtrl" (click)="$event.stopPropagation()">
|
|
60
|
-
<h4 class="column-headers">Pin Columns</h4>
|
|
61
|
-
<form class="example-form">
|
|
62
|
-
<mat-form-field appearance="fill" style="width: -webkit-fill-available;">
|
|
63
|
-
<mat-label>Filter Columns</mat-label>
|
|
64
|
-
<input matInput [(ngModel)]="showHideFilter" (ngModelChange)="filterColumns($event)"
|
|
65
|
-
[ngModelOptions]="{standalone: true}">
|
|
66
|
-
</mat-form-field>
|
|
67
|
-
</form>
|
|
68
|
-
<div class="showHide-menu-columns-list">
|
|
69
|
-
<app-column-pinning [columns]="showHideColumnsArray"></app-column-pinning>
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
</mat-menu>
|
|
73
|
-
|
|
74
|
-
<mat-progress-bar *ngIf="loadingIndicator" mode="indeterminate"></mat-progress-bar>
|
|
75
|
-
<section id="tableContainer" class="mat-table-ext-container" (scroll)="onScroll($event)"
|
|
76
|
-
[style.height]="tableHeight ? tableHeight :'max-content'">
|
|
77
|
-
<table mat-table [id]="'matTableExt'+tableID" [dataSource]="dataSource" matSort cdkDropList
|
|
78
|
-
cdkDropListOrientation="horizontal" multiTemplateDataRows (cdkDropListDropped)="onDrop($event)"
|
|
79
|
-
(click)="saveCellEditing()" [style.width]="scrollbarH?'max-content':'100%'">
|
|
80
|
-
<!-- Row selection column -->
|
|
81
|
-
<ng-container matColumnDef="select">
|
|
82
|
-
<th mat-header-cell *matHeaderCellDef cdkDragLockAxis="x" cdkDrag [cdkDragDisabled]="!dndColumns">
|
|
83
|
-
<mat-checkbox (change)="$event ? toggleAllRows() : null"
|
|
84
|
-
[checked]="selection.hasValue() && isAllSelected()"
|
|
85
|
-
[indeterminate]="selection.hasValue() && !isAllSelected()" [aria-label]="checkboxLabel()">
|
|
86
|
-
</mat-checkbox>
|
|
87
|
-
</th>
|
|
88
|
-
<td mat-cell *matCellDef="let row;let i = dataIndex">
|
|
89
|
-
<mat-checkbox (click)="$event.stopPropagation()" (change)="$event ? setSelectedRows(row,i) : null"
|
|
90
|
-
[checked]="selection.isSelected(row)" [aria-label]="checkboxLabel(row)">
|
|
91
|
-
</mat-checkbox>
|
|
92
|
-
</td>
|
|
93
|
-
<ng-container *ngIf="showFooterRow">
|
|
94
|
-
<td mat-footer-cell *matFooterCellDef></td>
|
|
95
|
-
</ng-container>
|
|
96
|
-
</ng-container>
|
|
97
|
-
<!--dynamic columns are being generated here-->
|
|
98
|
-
<div matColumnDef="{{column['field']}}" [sticky]="column.pinned == 'left' ? true:false"
|
|
99
|
-
[stickyEnd]="column.pinned == 'right' ? true:false" *ngFor="let column of columnsArray; let i = index">
|
|
100
|
-
<th mat-header-cell *matHeaderCellDef [style.width]="column.width" [style.maxWidth]="column.maxWidth"
|
|
101
|
-
[style.minWidth]="column.minWidth" cdkDragLockAxis="x" cdkDrag [cdkDragDisabled]="!dndColumns"
|
|
102
|
-
[columnsResizable]="columnResizable" [index]="i">
|
|
103
|
-
<span *ngIf="!headerTemplateRef" matTooltip="{{column.headerTooltip?.value}}"
|
|
104
|
-
[matTooltipPosition]="column?.headerTooltip?.tooltipPosition!" mat-sort-header
|
|
105
|
-
[disabled]="!sorting || column.disabled === true">{{column.header}}</span>
|
|
106
|
-
<ng-container *ngIf="headerTemplateRef" [ngTemplateOutlet]="headerTemplateRef"
|
|
107
|
-
[ngTemplateOutletContext]="{data:column}"></ng-container>
|
|
108
|
-
<ng-container *ngIf="column.headerTemplate" [ngTemplateOutlet]="column.headerTemplate"
|
|
109
|
-
[ngTemplateOutletContext]="{data:column}"></ng-container>
|
|
110
|
-
</th>
|
|
111
|
-
<td mat-cell *matCellDef="let row ;let i=dataIndex">
|
|
112
|
-
<div *ngIf="!row.editable && !cellEditing[i +'_'+column.field]"
|
|
113
|
-
(dblclick)="cellEditing[i +'_'+column.field] = inCellEditing;setCellData(row,i)"
|
|
114
|
-
matTooltip="{{column.cellTooltip?.value}}"
|
|
115
|
-
[matTooltipPosition]="column?.cellTooltip?.tooltipPosition!">
|
|
116
|
-
<span
|
|
117
|
-
*ngIf="!cellTemplateRef && !column?.cellTemplate && !cellTemplateRefMap[column.field]">{{row[column.field]}}</span>
|
|
118
|
-
<ng-container *ngIf="cellTemplateRefMap[column.field]"
|
|
119
|
-
[ngTemplateOutlet]="cellTemplateRefMap[column.field]"
|
|
120
|
-
[ngTemplateOutletContext]="{row:row,column:column,index:i}">
|
|
121
|
-
</ng-container>
|
|
122
|
-
<ng-container
|
|
123
|
-
*ngIf="cellTemplateRef && column.cellTemplate && !cellTemplateRefMap[column.field]"
|
|
124
|
-
[ngTemplateOutlet]="column.cellTemplate"
|
|
125
|
-
[ngTemplateOutletContext]="{row:row,column:column,index:i}">
|
|
126
|
-
</ng-container>
|
|
127
|
-
<ng-container
|
|
128
|
-
*ngIf="!cellTemplateRef && column.cellTemplate && !cellTemplateRefMap[column.field]"
|
|
129
|
-
[ngTemplateOutlet]="column.cellTemplate"
|
|
130
|
-
[ngTemplateOutletContext]="{row:row,column:column,index:i}">
|
|
131
|
-
</ng-container>
|
|
132
|
-
<ng-container
|
|
133
|
-
*ngIf="cellTemplateRef && !column.cellTemplate && !cellTemplateRefMap[column.field]"
|
|
134
|
-
[ngTemplateOutlet]="cellTemplateRef"
|
|
135
|
-
[ngTemplateOutletContext]="{row:row,column:column,index:i}">
|
|
136
|
-
</ng-container>
|
|
137
|
-
</div>
|
|
138
|
-
<div *ngIf="row.editable || cellEditing[i +'_'+column.field]" (click)="$event.stopPropagation()">
|
|
139
|
-
<ng-container *ngIf="inlineEditingTemplateRef && !cellEditing[i +'_'+column.field]"
|
|
140
|
-
[ngTemplateOutlet]="inlineEditingTemplateRef"
|
|
141
|
-
[ngTemplateOutletContext]="{data:getInlineEditingData(row,i,column)}"></ng-container>
|
|
142
|
-
<ng-container *ngIf="cellEditingTemplateRef && !(row.editable)"
|
|
143
|
-
[ngTemplateOutlet]="cellEditingTemplateRef"
|
|
144
|
-
[ngTemplateOutletContext]="{data:getInlineEditingData(row,i,column)}"></ng-container>
|
|
145
|
-
<ng-container *ngIf="!inlineEditingTemplateRef && (row.editable) && rowDataTemp['e'+i]">
|
|
146
|
-
<mat-form-field *ngIf="column.type == 'number'" appearance="outline"
|
|
147
|
-
class="inline-editing-field">
|
|
148
|
-
<input matInput type="number" [(ngModel)]="rowDataTemp['e'+i][column.field]"
|
|
149
|
-
[ngModelOptions]="{standalone: true}">
|
|
150
|
-
</mat-form-field>
|
|
151
|
-
<mat-form-field style="width: 100%;" *ngIf="column.type == 'string'" appearance="outline"
|
|
152
|
-
class="inline-editing-field">
|
|
153
|
-
<input matInput type="text" [(ngModel)]="rowDataTemp['e'+i][column.field]"
|
|
154
|
-
[ngModelOptions]="{standalone: true}">
|
|
155
|
-
</mat-form-field>
|
|
156
|
-
<mat-form-field *ngIf="column.type == 'date'" appearance="outline"
|
|
157
|
-
class="inline-editing-field">
|
|
158
|
-
<input matInput type="date" [(ngModel)]="rowDataTemp['e'+i][column.field]"
|
|
159
|
-
[ngModelOptions]="{standalone: true}">
|
|
160
|
-
</mat-form-field>
|
|
161
|
-
<mat-form-field *ngIf="column.type == 'selection'" appearance="outline"
|
|
162
|
-
class="inline-editing-field">
|
|
163
|
-
<mat-select [value]="rowDataTemp['e'+i][column.field]"
|
|
164
|
-
[(ngModel)]="rowDataTemp['e'+i][column.field]">
|
|
165
|
-
<mat-option *ngFor="let option of column.options" [value]="option">
|
|
166
|
-
{{option}}
|
|
167
|
-
</mat-option>
|
|
168
|
-
</mat-select>
|
|
169
|
-
</mat-form-field>
|
|
170
|
-
<mat-checkbox (click)="$event.stopPropagation()" *ngIf="column.type == 'boolean'"
|
|
171
|
-
color="primary" [(ngModel)]="row[column.field]"></mat-checkbox>
|
|
172
|
-
</ng-container>
|
|
173
|
-
<ng-container *ngIf="!cellEditingTemplateRef && cellEditing[i +'_'+column.field]">
|
|
174
|
-
<mat-form-field *ngIf="column.type == 'number'" appearance="outline"
|
|
175
|
-
class="inline-editing-field">
|
|
176
|
-
<input matInput type="number" [(ngModel)]="rowDataTemp['e'+i][column.field]"
|
|
177
|
-
[ngModelOptions]="{standalone: true}">
|
|
178
|
-
</mat-form-field>
|
|
179
|
-
<mat-form-field *ngIf="column.type == 'string'" appearance="outline"
|
|
180
|
-
class="inline-editing-field">
|
|
181
|
-
<input matInput type="text" [(ngModel)]="rowDataTemp['e'+i][column.field]"
|
|
182
|
-
[ngModelOptions]="{standalone: true}">
|
|
183
|
-
</mat-form-field>
|
|
184
|
-
<mat-form-field *ngIf="column.type == 'date'" appearance="outline"
|
|
185
|
-
class="inline-editing-field">
|
|
186
|
-
<input matInput type="date" [(ngModel)]="rowDataTemp['e'+i][column.field]"
|
|
187
|
-
[ngModelOptions]="{standalone: true}">
|
|
188
|
-
</mat-form-field>
|
|
189
|
-
<mat-form-field *ngIf="column.type == 'selection'" appearance="outline"
|
|
190
|
-
class="inline-editing-field">
|
|
191
|
-
<mat-select [value]="rowDataTemp['e'+i][column.field]"
|
|
192
|
-
[(ngModel)]="rowDataTemp['e'+i][column.field]">
|
|
193
|
-
<mat-option *ngFor="let option of column.options" [value]="option">
|
|
194
|
-
{{option}}
|
|
195
|
-
</mat-option>
|
|
196
|
-
</mat-select>
|
|
197
|
-
</mat-form-field>
|
|
198
|
-
<mat-checkbox (click)="$event.stopPropagation()" *ngIf="column.type == 'boolean'"
|
|
199
|
-
color="primary" [(ngModel)]="row[column.field]"></mat-checkbox>
|
|
200
|
-
</ng-container>
|
|
201
|
-
</div>
|
|
202
|
-
</td>
|
|
203
|
-
<ng-container *ngIf="showFooterRow">
|
|
204
|
-
<td mat-footer-cell *matFooterCellDef> {{column.footerText}} </td>
|
|
205
|
-
</ng-container>
|
|
206
|
-
</div>
|
|
207
|
-
<ng-container matColumnDef="edit" stickyEnd="false">
|
|
208
|
-
<th mat-header-cell cdkDragLockAxis="x" cdkDrag [cdkDragDisabled]="true" *matHeaderCellDef
|
|
209
|
-
class="action-column-cells"> Edit </th>
|
|
210
|
-
<td mat-cell *matCellDef="let row; let i = dataIndex" class="inline-edit-column-cell">
|
|
211
|
-
<mat-icon class="edit-column-icons" *ngIf="!row.editable && !row.editmodal" aria-hidden="false"
|
|
212
|
-
(click)="enableInlineEditing(row,i)" fontIcon="edit_note">
|
|
213
|
-
</mat-icon>
|
|
214
|
-
<div class="inline-editing-controls" *ngIf="row.editable && !row.editmodal">
|
|
215
|
-
<mat-icon class="edit-column-icons" aria-hidden="false" (click)="saveInlineEditing(row,i)"
|
|
216
|
-
fontIcon="done"></mat-icon>
|
|
217
|
-
<mat-icon class="edit-column-icons" aria-hidden="false" (click)="cancelInlineEditing(row,i)"
|
|
218
|
-
fontIcon="close"></mat-icon>
|
|
219
|
-
</div>
|
|
220
|
-
</td>
|
|
221
|
-
<td mat-footer-cell *matFooterCellDef> edit </td>
|
|
222
|
-
</ng-container>
|
|
223
|
-
<ng-container matColumnDef="popup" stickyEnd="false">
|
|
224
|
-
<th mat-header-cell cdkDragLockAxis="x" cdkDrag [cdkDragDisabled]="true" *matHeaderCellDef
|
|
225
|
-
class="action-column-cells"> Popup
|
|
226
|
-
</th>
|
|
227
|
-
<td mat-cell *matCellDef="let row; let i = index">
|
|
228
|
-
<mat-icon aria-hidden="false" (click)="openEditingDialog(row)" fontIcon="edit">
|
|
229
|
-
</mat-icon>
|
|
230
|
-
</td>
|
|
231
|
-
<td mat-footer-cell *matFooterCellDef></td>
|
|
232
|
-
</ng-container>
|
|
233
|
-
|
|
234
|
-
<ng-container matColumnDef="delete">
|
|
235
|
-
<th mat-header-cell cdkDragLockAxis="x" cdkDrag [cdkDragDisabled]="true" *matHeaderCellDef
|
|
236
|
-
class="action-column-cells"> Delete
|
|
237
|
-
</th>
|
|
238
|
-
<td mat-cell *matCellDef="let row;let i=dataIndex">
|
|
239
|
-
<mat-icon (click)="deleteRow(row,i)" aria-hidden="false" aria-label="Example home icon"
|
|
240
|
-
fontIcon="delete">
|
|
241
|
-
</mat-icon>
|
|
242
|
-
</td>
|
|
243
|
-
<td mat-footer-cell *matFooterCellDef></td>
|
|
244
|
-
</ng-container>
|
|
245
|
-
<!-- Expanded Content Column - The detail row is made up of this one column that spans across all columns -->
|
|
246
|
-
<ng-container *ngIf="expandRows" matColumnDef="expandedDetail">
|
|
247
|
-
<td mat-cell *matCellDef="let element;let i=dataIndex "
|
|
248
|
-
[attr.colspan]="columnsToDisplayWithExpand.length">
|
|
249
|
-
<div class="example-element-detail"
|
|
250
|
-
[@detailExpand]="element == expandedElement ? 'expanded' : 'collapsed'">
|
|
251
|
-
<ng-container *ngIf="expansionTemplateRef" [ngTemplateOutlet]="expansionTemplateRef"
|
|
252
|
-
[ngTemplateOutletContext]="{$explicit:element,row:element,index:i}">
|
|
253
|
-
</ng-container>
|
|
254
|
-
</div>
|
|
255
|
-
</td>
|
|
256
|
-
</ng-container>
|
|
257
|
-
<ng-container *ngFor="let ids of headersFiltersIds; let i=index" [matColumnDef]="ids">
|
|
258
|
-
<th mat-header-cell *matHeaderCellDef>
|
|
259
|
-
<div class="filters-container" [class.animate]="toggleFilters">
|
|
260
|
-
<app-filter-columns-component [obj]="columnsArray[returnIndex(ids)]"
|
|
261
|
-
(filterOutput)="applyColumnFilter($event,columnsArray[returnIndex(ids)])"></app-filter-columns-component>
|
|
262
|
-
</div>
|
|
263
|
-
</th>
|
|
264
|
-
</ng-container>
|
|
265
|
-
<tr mat-header-row *matHeaderRowDef=" getDisplayedColumns(); sticky: stickyHeader"></tr>
|
|
266
|
-
<tr mat-row *matRowDef="let row; columns:getDisplayedColumns(); let i=dataIndex;" class="data-row"
|
|
267
|
-
[ngClass]="{'data-row':expandRows,'stripedRows':(stripedRows && i % 2 == 1),'hoverClass':rowHover, 'hidden':hiddenCtrl.isSelected(row) && hideRows,'example-expanded-row':expandedElement === row}"
|
|
268
|
-
(click)="expandRow(row, row !== expandedElement,i)">
|
|
269
|
-
</tr>
|
|
270
|
-
<tr style="height: 0px;" mat-header-row class="no-default-height" *matHeaderRowDef="headersFiltersIds">
|
|
271
|
-
</tr>
|
|
272
|
-
<ng-container *ngIf="expandRows">
|
|
273
|
-
<tr style="height: 0px;" mat-row *matRowDef="let row; columns: ['expandedDetail']"
|
|
274
|
-
[ngClass]="{'example-detail-row': (expandRows && row === expandedElement),'expand-row':row !== expandedElement}">
|
|
275
|
-
</tr>
|
|
276
|
-
</ng-container>
|
|
277
|
-
<ng-container *ngIf="showFooterRow">
|
|
278
|
-
<tr mat-footer-row *matFooterRowDef="getDisplayedColumns(); sticky: stickyFooter"></tr>
|
|
279
|
-
</ng-container>
|
|
280
|
-
</table>
|
|
281
|
-
</section>
|
|
282
|
-
<mat-paginator *ngIf="showPaginator" [pageSizeOptions]="pageSizeOptions"
|
|
283
|
-
[showFirstLastButtons]="showFirstLastButtons">
|
|
284
|
-
</mat-paginator>
|
|
285
|
-
</div>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { MatTableExtComponent } from './mat-table-ext.component';
|
|
4
|
-
|
|
5
|
-
describe('MatTableExtComponent', () => {
|
|
6
|
-
let component: MatTableExtComponent;
|
|
7
|
-
let fixture: ComponentFixture<MatTableExtComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async () => {
|
|
10
|
-
await TestBed.configureTestingModule({
|
|
11
|
-
declarations: [ MatTableExtComponent ]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
fixture = TestBed.createComponent(MatTableExtComponent);
|
|
18
|
-
component = fixture.componentInstance;
|
|
19
|
-
fixture.detectChanges();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should create', () => {
|
|
23
|
-
expect(component).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
});
|