easy-mat-ui 0.0.3 → 0.0.5
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/easy-mat-ui-0.0.4.tgz +0 -0
- package/ng-package.json +19 -0
- package/package.json +19 -18
- package/src/lib/easy-mat-ui.component.spec.ts +23 -0
- package/src/lib/easy-mat-ui.component.ts +16 -0
- package/src/lib/easy-mat-ui.service.spec.ts +16 -0
- package/src/lib/easy-mat-ui.service.ts +9 -0
- package/src/lib/easy-multi-select/easy-multi-select.css +102 -0
- package/src/lib/easy-multi-select/easy-multi-select.html +51 -0
- package/src/lib/easy-multi-select/easy-multi-select.spec.ts +23 -0
- package/src/lib/easy-multi-select/easy-multi-select.ts +181 -0
- package/src/lib/easy-table/easy-table.component.css +117 -0
- package/src/lib/easy-table/easy-table.component.html +221 -0
- package/src/lib/easy-table/easy-table.component.spec.ts +23 -0
- package/src/lib/easy-table/easy-table.component.ts +568 -0
- package/src/lib/model/dictionary.model.ts +4 -0
- package/src/lib/model/mat-column-typed.model.ts +41 -0
- package/src/lib/model/mat-column.model.ts +35 -0
- package/src/lib/model/tuple.model.ts +8 -0
- package/src/lib/shared/table-toolbar/table-toolbar.css +26 -0
- package/src/lib/shared/table-toolbar/table-toolbar.html +80 -0
- package/src/lib/shared/table-toolbar/table-toolbar.ts +130 -0
- package/src/lib/styles/_backgrounds.scss +39 -0
- package/src/lib/styles/_buttons.scss +90 -0
- package/src/lib/styles/_colors.scss +67 -0
- package/src/lib/styles/_effects.scss +44 -0
- package/src/lib/styles/_material-overrides.scss +87 -0
- package/src/lib/styles/_spacing.scss +68 -0
- package/src/lib/styles/_tables.scss +71 -0
- package/src/lib/styles/_typography.scss +105 -0
- package/src/lib/styles.scss +30 -0
- package/src/lib/utils/enums.ts +49 -0
- package/src/lib/utils/matTabCommon.ts +59 -0
- package/src/lib/utils/utils.ts +68 -0
- package/{public-api.d.ts → src/public-api.ts} +8 -3
- package/tsconfig.lib.json +18 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/fesm2022/easy-mat-ui.mjs +0 -110
- package/fesm2022/easy-mat-ui.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/easy-mat-ui.component.d.ts +0 -5
- package/lib/easy-mat-ui.service.d.ts +0 -6
- package/lib/easy-table/easy-table.component.d.ts +0 -15
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AfterViewInit,
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
Component,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
Input,
|
|
7
|
+
OnChanges,
|
|
8
|
+
OnInit,
|
|
9
|
+
Output,
|
|
10
|
+
QueryList,
|
|
11
|
+
ViewChild,
|
|
12
|
+
ViewChildren
|
|
13
|
+
} from '@angular/core';
|
|
14
|
+
import {CommonModule} from '@angular/common';
|
|
15
|
+
import {MatTable, MatTableDataSource, MatTableModule} from '@angular/material/table';
|
|
16
|
+
import {MatPaginator, MatPaginatorModule} from '@angular/material/paginator';
|
|
17
|
+
import {MatSort, MatSortModule} from '@angular/material/sort';
|
|
18
|
+
import {MatInputModule} from '@angular/material/input';
|
|
19
|
+
import {MatFormFieldAppearance, MatFormFieldModule} from '@angular/material/form-field';
|
|
20
|
+
import {MatButtonModule} from '@angular/material/button';
|
|
21
|
+
import {MatIconModule} from '@angular/material/icon';
|
|
22
|
+
import {TranslateModule, TranslatePipe, TranslateService} from '@ngx-translate/core';
|
|
23
|
+
import {animate, state, style, transition, trigger} from '@angular/animations';
|
|
24
|
+
import {ColumnType, CRUD} from '../utils/enums';
|
|
25
|
+
import {Dictionary} from '../model/dictionary.model';
|
|
26
|
+
import {MatButtonToggleModule} from '@angular/material/button-toggle';
|
|
27
|
+
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
|
28
|
+
import {TableToolbarComponent} from '../shared/table-toolbar/table-toolbar';
|
|
29
|
+
import {MatColumnTyped} from '../model/mat-column-typed.model';
|
|
30
|
+
import {MatTabCommon} from '../utils/matTabCommon';
|
|
31
|
+
import {MatSelectModule} from '@angular/material/select';
|
|
32
|
+
import {EasyMultiSelect} from '../easy-multi-select/easy-multi-select';
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@Component({
|
|
36
|
+
selector: 'lib-easy-table',
|
|
37
|
+
standalone: true,
|
|
38
|
+
imports: [
|
|
39
|
+
CommonModule,
|
|
40
|
+
TranslatePipe,
|
|
41
|
+
TranslateModule,
|
|
42
|
+
MatTableModule,
|
|
43
|
+
MatPaginatorModule,
|
|
44
|
+
MatSortModule,
|
|
45
|
+
MatInputModule,
|
|
46
|
+
MatFormFieldModule,
|
|
47
|
+
MatButtonModule,
|
|
48
|
+
MatIconModule,
|
|
49
|
+
MatSelectModule,
|
|
50
|
+
MatButtonToggleModule,
|
|
51
|
+
ReactiveFormsModule,
|
|
52
|
+
FormsModule,
|
|
53
|
+
TableToolbarComponent,
|
|
54
|
+
EasyMultiSelect
|
|
55
|
+
],
|
|
56
|
+
|
|
57
|
+
templateUrl: './easy-table.component.html',
|
|
58
|
+
styleUrls: ['./easy-table.component.css', '../styles.scss'],
|
|
59
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
60
|
+
animations: [
|
|
61
|
+
trigger('detailExpand', [
|
|
62
|
+
state('collapsed', style({height: '0px', minHeight: '0'})),
|
|
63
|
+
state('expanded', style({height: '*'})),
|
|
64
|
+
transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
|
|
65
|
+
]),
|
|
66
|
+
],
|
|
67
|
+
})
|
|
68
|
+
export class EasyTableComponent<T extends Record<string, never>>
|
|
69
|
+
implements OnInit, AfterViewInit, OnChanges {
|
|
70
|
+
@Input({required: true}) dataSource!: MatTableDataSource<T>;
|
|
71
|
+
private _displayedColumns: MatColumnTyped[] = [];
|
|
72
|
+
public availableGroups: string[] = [];
|
|
73
|
+
|
|
74
|
+
@Input()
|
|
75
|
+
set displayedColumns(value: (string | MatColumnTyped)[]) {
|
|
76
|
+
if (!value) {
|
|
77
|
+
this._displayedColumns = [];
|
|
78
|
+
this.availableGroups = [];
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const mappedColumns = value.map((col) => {
|
|
83
|
+
if (typeof col === 'string') {
|
|
84
|
+
return new MatColumnTyped({name: col, value: col, order: 0});
|
|
85
|
+
} else {
|
|
86
|
+
return new MatColumnTyped({
|
|
87
|
+
...col,
|
|
88
|
+
order: col.order ?? 0,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const grouped = mappedColumns.filter(col => !!col.groupName);
|
|
94
|
+
const ungrouped = mappedColumns.filter(col => !col.groupName);
|
|
95
|
+
|
|
96
|
+
const groupedByGroupName = new Map<string, MatColumnTyped[]>();
|
|
97
|
+
|
|
98
|
+
grouped.forEach(col => {
|
|
99
|
+
const group = col.groupName!;
|
|
100
|
+
if (!groupedByGroupName.has(group)) {
|
|
101
|
+
groupedByGroupName.set(group, []);
|
|
102
|
+
}
|
|
103
|
+
groupedByGroupName.get(group)!.push(col);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (ungrouped.length) {
|
|
107
|
+
groupedByGroupName.set('_ungrouped', ungrouped);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const sortedGroups = [...groupedByGroupName.entries()].sort((a, b) => {
|
|
111
|
+
const aOrder = a[1][0].order ?? 0;
|
|
112
|
+
const bOrder = b[1][0].order ?? 0;
|
|
113
|
+
return aOrder - bOrder;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const finalSorted: MatColumnTyped[] = [];
|
|
117
|
+
sortedGroups.forEach(([_, cols]) => {
|
|
118
|
+
const sortedCols = cols.sort((a, b) => a.order - b.order);
|
|
119
|
+
finalSorted.push(...sortedCols);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
this._displayedColumns = finalSorted;
|
|
123
|
+
|
|
124
|
+
this.availableGroups = this.groupedColumns.map(([groupName, _]) => groupName);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
get displayedColumns(): MatColumnTyped[] {
|
|
129
|
+
return this._displayedColumns;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
searchTableField = '';
|
|
134
|
+
|
|
135
|
+
@Input() data!: any[];
|
|
136
|
+
@Output() deleteItemToEmit = new EventEmitter<object>();
|
|
137
|
+
@Output() addItemToEmit = new EventEmitter<CRUD>();
|
|
138
|
+
@Output() editItemToEmit = new EventEmitter<object>();
|
|
139
|
+
@Output() viewItemToEmit = new EventEmitter<object>();
|
|
140
|
+
@Output() overwriteToEmit = new EventEmitter<{ source: string; value: string; item: object }>();
|
|
141
|
+
@Output() logoutToEmit = new EventEmitter<String>();
|
|
142
|
+
@Output() titleIconToEmit = new EventEmitter<void>();
|
|
143
|
+
@Output() customActionToEmit = new EventEmitter<void>();
|
|
144
|
+
@Input() source: string = '';
|
|
145
|
+
@Input() btnSize: string = 'btn-small';
|
|
146
|
+
@Input() sortedBy: string = 'id';
|
|
147
|
+
@Input() readonly = false;
|
|
148
|
+
@Input() withGlobalFilter: boolean = true;
|
|
149
|
+
@Input() withTitle: boolean = true;
|
|
150
|
+
@Input() logout = false;
|
|
151
|
+
@Input() fontSize = '';
|
|
152
|
+
@Input() customActionEnable = false;
|
|
153
|
+
@Input() customActionIcon!: string;
|
|
154
|
+
@Input() customActionTitle!: string;
|
|
155
|
+
@Input() customActionClass!: string;
|
|
156
|
+
@Input() icon!: string;
|
|
157
|
+
@Input() changePageSize: number = 5;
|
|
158
|
+
@Input() sliceSize!: number;
|
|
159
|
+
@Input() isPreview = false;
|
|
160
|
+
@Input() shortHeader = false;
|
|
161
|
+
@Input() canAccess = false;
|
|
162
|
+
@Input() canCreate = false;
|
|
163
|
+
@Input() canUpdate = false;
|
|
164
|
+
@Input() canExport = false;
|
|
165
|
+
@Input() canDelete = false;
|
|
166
|
+
@Input() canOrder = false;
|
|
167
|
+
@Input() editAction = true;
|
|
168
|
+
@Input() deleteAction = true;
|
|
169
|
+
@Input() previewAction = true;
|
|
170
|
+
@Input() withHeader = true;
|
|
171
|
+
@Input() clickableIcon = true;
|
|
172
|
+
@Input() titleIcon: string = '';
|
|
173
|
+
@Input() customRowActionEnable = false;
|
|
174
|
+
@Input() customRowActionIcon: string = '';
|
|
175
|
+
@Input() customRowActionTitle: string = '';
|
|
176
|
+
@Input() customRowActionClass: string = 'bg-blue';
|
|
177
|
+
@Input() prefix = '';
|
|
178
|
+
@Input() iconClass = 'taupe';
|
|
179
|
+
@Input() withToolbar = true;
|
|
180
|
+
@Input() withFilterInHeader = false;
|
|
181
|
+
@Input() expandableGroups = false;
|
|
182
|
+
|
|
183
|
+
@Input() filterColumn!: MatColumnTyped;
|
|
184
|
+
@Input() customColumnFilter: Dictionary[] = [];
|
|
185
|
+
@ViewChild(MatPaginator, {static: true})
|
|
186
|
+
paginator: MatPaginator = new MatPaginator;
|
|
187
|
+
@ViewChild(MatSort)
|
|
188
|
+
sort: MatSort = new MatSort;
|
|
189
|
+
@ViewChild(MatTable, {static: true}) table: MatTable<any> | undefined;
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@Input() highlightChangedCells = false;
|
|
193
|
+
@Input() canAuditTrail = false;
|
|
194
|
+
@Output() auditTrailToEmit = new EventEmitter<object>();
|
|
195
|
+
|
|
196
|
+
@Input() appearance: MatFormFieldAppearance | 'none' = 'outline';
|
|
197
|
+
|
|
198
|
+
@ViewChildren('multiSelectDropdown') multiSelectDropdowns!: QueryList<EasyMultiSelect>;
|
|
199
|
+
@Input() userFilters: any = {filters: ''};
|
|
200
|
+
isAndFilterOperator = true;
|
|
201
|
+
ColumnType: typeof ColumnType = ColumnType;
|
|
202
|
+
columnFilters: { [key: string]: string } = {};
|
|
203
|
+
isPasswordVisible: Record<string, boolean> = {};
|
|
204
|
+
protected readonly MatTabCommon = MatTabCommon;
|
|
205
|
+
expandedGroups: { [key: string]: boolean } = {};
|
|
206
|
+
|
|
207
|
+
constructor(private translate: TranslateService) {
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
ngOnInit() {
|
|
211
|
+
if (this.sliceSize == null || this.sliceSize === 0) {
|
|
212
|
+
this.sliceSize = 1;
|
|
213
|
+
}
|
|
214
|
+
if (this.prefix) {
|
|
215
|
+
this.prefix = this.prefix + '.';
|
|
216
|
+
}
|
|
217
|
+
this.loadData();
|
|
218
|
+
this.groupedColumns.forEach(([groupName]) => {
|
|
219
|
+
this.expandedGroups[groupName] = true;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
getDisplayedColumnNames(): string[] {
|
|
224
|
+
const cols: string[] = [];
|
|
225
|
+
this.groupedColumns.forEach(([groupName, columns]) => {
|
|
226
|
+
if (groupName === '_ungrouped' || this.expandedGroups[groupName]) {
|
|
227
|
+
columns.forEach(col => cols.push(col.name));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
return cols;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
get groupedColumns(): [string, MatColumnTyped[]][] {
|
|
235
|
+
const groupedMap = new Map<string, MatColumnTyped[]>();
|
|
236
|
+
|
|
237
|
+
this._displayedColumns.forEach(col => {
|
|
238
|
+
const key = col.groupName || '_ungrouped';
|
|
239
|
+
if (!groupedMap.has(key)) groupedMap.set(key, []);
|
|
240
|
+
groupedMap.get(key)!.push(col);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const result = Array.from(groupedMap.entries())
|
|
244
|
+
.map(([groupName, columns]) => {
|
|
245
|
+
const groupOrder = columns[0]?.groupOrder != null ? columns[0].groupOrder.toString() : '';
|
|
246
|
+
return {groupName, columns, order: groupOrder};
|
|
247
|
+
})
|
|
248
|
+
.sort((a, b) => {
|
|
249
|
+
if (a.groupName === '_ungrouped') return -1;
|
|
250
|
+
if (b.groupName === '_ungrouped') return 1;
|
|
251
|
+
return a.order.localeCompare(b.order);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return result.map(r => [r.groupName, r.columns]);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
ngOnChanges() {
|
|
259
|
+
this.loadData();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
loadData() {
|
|
263
|
+
if (this.sortedBy) {
|
|
264
|
+
this.data?.sort((x, y) => {
|
|
265
|
+
const valX = String(x[this.sortedBy] ?? '');
|
|
266
|
+
const valY = String(y[this.sortedBy] ?? '');
|
|
267
|
+
return valX.localeCompare(valY);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
}
|
|
271
|
+
this.dataSource = new MatTableDataSource<any>(this.data);
|
|
272
|
+
this.dataSource.paginator = this.paginator;
|
|
273
|
+
this.dataSource.sort = this.sort;
|
|
274
|
+
this.dataSource.filter = this.searchTableField;
|
|
275
|
+
this.updatePageSize();
|
|
276
|
+
this.syncFiltersWithData();
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
syncFiltersWithData(): void {
|
|
280
|
+
if (!this.data?.length) return;
|
|
281
|
+
|
|
282
|
+
this.displayedColumns.forEach(column => {
|
|
283
|
+
if (!column.enableFilter) return;
|
|
284
|
+
|
|
285
|
+
const field = column.name;
|
|
286
|
+
const displayField = column.displayColumn ?? column.name;
|
|
287
|
+
|
|
288
|
+
const dataValues = this.data
|
|
289
|
+
.map(item => item[field])
|
|
290
|
+
.filter(val => val != null);
|
|
291
|
+
|
|
292
|
+
const uniqueValues = Array.from(new Set(dataValues));
|
|
293
|
+
|
|
294
|
+
if (!column.filterList || column.filterList.length === 0) {
|
|
295
|
+
column.filterList = uniqueValues.map(val => ({
|
|
296
|
+
value: val,
|
|
297
|
+
[displayField]: val
|
|
298
|
+
}));
|
|
299
|
+
} else {
|
|
300
|
+
const valueSet = new Set(uniqueValues);
|
|
301
|
+
column.filterList = column.filterList.filter(obj => valueSet.has(obj[displayField]));
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
ngAfterViewInit() {
|
|
308
|
+
this.dataSource.sort = this.sort;
|
|
309
|
+
this.dataSource.paginator = this.paginator;
|
|
310
|
+
this.updatePageSize();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
updatePageSize(): void {
|
|
314
|
+
if (this.changePageSize != null && this.dataSource.paginator) {
|
|
315
|
+
this.dataSource.paginator.pageSize = this.changePageSize;
|
|
316
|
+
this.dataSource.paginator._changePageSize(this.changePageSize);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
applyFilter(event: Event): void {
|
|
321
|
+
const input = event.target as HTMLInputElement | null;
|
|
322
|
+
const value = input?.value ?? '';
|
|
323
|
+
this.searchTableField = value.trim().toLowerCase();
|
|
324
|
+
this.setFilters();
|
|
325
|
+
this.applyCustomFilter();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
clearTableFilter() {
|
|
329
|
+
this.searchTableField = '';
|
|
330
|
+
this.columnFilters = {};
|
|
331
|
+
this.setFilters();
|
|
332
|
+
this.dataSource.filter = '';
|
|
333
|
+
this.resetDropdownSelection();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
resetDropdownSelection() {
|
|
337
|
+
this.multiSelectDropdowns.forEach((dropdown) => {
|
|
338
|
+
dropdown.resetSelection();
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
filterType() {
|
|
343
|
+
this.searchTableField = '';
|
|
344
|
+
this.dataSource.filter = '';
|
|
345
|
+
this.isAndFilterOperator = !this.isAndFilterOperator;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
deleteItem(obj: object) {
|
|
349
|
+
this.deleteItemToEmit.emit(obj);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
addItem() {
|
|
353
|
+
this.addItemToEmit.emit(CRUD.CREATE);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
editItem(element: any) {
|
|
357
|
+
this.editItemToEmit.emit(element);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
viewItem(element: any) {
|
|
361
|
+
this.viewItemToEmit.emit(element);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
onChangeOverwrite(element: any, col: MatColumnTyped, event: Event) {
|
|
365
|
+
const input = event.target as HTMLInputElement | null;
|
|
366
|
+
this.data.find(x => x[col.id] === element[col.id])[col.name] = input?.value ?? '';
|
|
367
|
+
this.dataSource = new MatTableDataSource<any>(this.data);
|
|
368
|
+
this.overwriteToEmit.emit({source: col.name, value: input?.value ?? element[col.name], item: element});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
close() {
|
|
372
|
+
this.logoutToEmit.emit('CLOSE');
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
onClickCustomAction() {
|
|
376
|
+
if (this.customActionEnable) {
|
|
377
|
+
this.customActionToEmit.emit();
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
getIconColumn(col: MatColumnTyped, item: any): string {
|
|
382
|
+
return col.isDynamic ? item[col.name] : (col.conditionFn && col.conditionFn(item, col)) ? col.enableIcon : col.disableIcon;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
getIconTitle(col: MatColumnTyped, value: string): string {
|
|
386
|
+
return col.isDynamic ? value : (value === 'true'
|
|
387
|
+
? col.enableTitle || col.disableTitle || ''
|
|
388
|
+
: col.disableTitle || '');
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
getTitleColumn(col: MatColumnTyped, item: any): string {
|
|
392
|
+
return item[col.enableTitle ?? col.name];
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
exportToCsv() {
|
|
397
|
+
console.log(' Export File')
|
|
398
|
+
// Utils.exportToCsv(this.dataSource.filteredData, this.source ?? 'FILE');
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
getHeaderName(columnName: string) {
|
|
402
|
+
return this.prefix + columnName;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
OnToggleChanged(values: Dictionary[]) {
|
|
407
|
+
this.setStatusColor(values);
|
|
408
|
+
const _data: any[] = [];
|
|
409
|
+
if (values.length > 0) {
|
|
410
|
+
values.forEach(filter => {
|
|
411
|
+
_data.push(...this.data?.filter(x => filter.key == x[this.filterColumn.name]));
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
this.getData(_data);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
setStatusColor(values: Dictionary[]) {
|
|
418
|
+
this.customColumnFilter.forEach(x => x.value = 'false');
|
|
419
|
+
values.forEach(x => x.value = 'true');
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
getData(data: any[]) {
|
|
423
|
+
this.dataSource = new MatTableDataSource<any>(data);
|
|
424
|
+
this.dataSource.paginator = this.paginator;
|
|
425
|
+
this.dataSource.sort = this.sort;
|
|
426
|
+
this.dataSource.filter = this.searchTableField;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
auditTrailItem(element: object) {
|
|
430
|
+
if (this.canAuditTrail) {
|
|
431
|
+
this.auditTrailToEmit.emit(element);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
applyFilterFromToolbar() {
|
|
436
|
+
this.dataSource.filter = this.searchTableField.trim().toLowerCase();
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
async onChangeDdl(element: any, col: MatColumnTyped, value: any) {
|
|
440
|
+
this.data.find(x => x[col.id] === element[col.id])[col.name] = value;
|
|
441
|
+
this.dataSource = new MatTableDataSource<any>(this.data);
|
|
442
|
+
this.overwriteToEmit.emit({source: col.name, value: value[col.name], item: element});
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
onChangeMultiSelect(selected: any, col: MatColumnTyped, headerFilter: boolean = true) {
|
|
446
|
+
if (headerFilter) {
|
|
447
|
+
const list = col.filterList?.filter(x => selected.includes(x[col.displayColumn ?? col.name]));
|
|
448
|
+
this.applyFilterByColumn(list.map(x => x[col.displayColumn ?? col.name]).join('+'), col);
|
|
449
|
+
} else {
|
|
450
|
+
console.log(JSON.stringify(selected));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
applyFilterByColumn(filterValue: string, column: MatColumnTyped): void {
|
|
455
|
+
this.columnFilters[column.name] = filterValue.trim().toLowerCase();
|
|
456
|
+
this.setFilters();
|
|
457
|
+
this.applyCustomFilter();
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
getSelectedData(element: any, col: MatColumnTyped) {
|
|
462
|
+
const selectedData: Dictionary[] = [];
|
|
463
|
+
selectedData.push(new Dictionary(element[col.displayColumn ?? col.name], element[col.name]));
|
|
464
|
+
return selectedData;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
getSelectedList(col: MatColumnTyped) {
|
|
468
|
+
const key = col.displayColumn ?? col.name;
|
|
469
|
+
const selected = this.columnFilters[key]?.split('+') ?? [];
|
|
470
|
+
|
|
471
|
+
return col.filterList?.filter(item => {
|
|
472
|
+
const value = item?.[key];
|
|
473
|
+
if (value == null) return false;
|
|
474
|
+
return selected.includes(String(value).toLowerCase());
|
|
475
|
+
}) || [];
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
applyCustomFilter(): void {
|
|
479
|
+
this.dataSource.filterPredicate = (data: Record<string, any>, filter: string): boolean => {
|
|
480
|
+
let parsedFilter: { global?: string; columns?: Record<string, string> } = {};
|
|
481
|
+
|
|
482
|
+
try {
|
|
483
|
+
parsedFilter = JSON.parse(filter || '{}');
|
|
484
|
+
} catch (e) {
|
|
485
|
+
parsedFilter = {global: filter};
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
const globalFilter = (parsedFilter.global ?? '').toLowerCase().trim();
|
|
489
|
+
const columnFilters = parsedFilter.columns ?? {};
|
|
490
|
+
|
|
491
|
+
if (globalFilter) {
|
|
492
|
+
const globalKeywords = globalFilter
|
|
493
|
+
.split('+')
|
|
494
|
+
.map(k => k.trim())
|
|
495
|
+
.filter(k => !!k);
|
|
496
|
+
|
|
497
|
+
const matchGlobal = globalKeywords.some(keyword =>
|
|
498
|
+
Object.values(data).some(value =>
|
|
499
|
+
String(value ?? '').toLowerCase().includes(keyword)
|
|
500
|
+
)
|
|
501
|
+
);
|
|
502
|
+
|
|
503
|
+
if (!matchGlobal) return false;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
for (const column of Object.keys(columnFilters)) {
|
|
507
|
+
const columnFilter = (columnFilters[column] ?? '').toLowerCase().trim();
|
|
508
|
+
if (!columnFilter) continue;
|
|
509
|
+
|
|
510
|
+
const columnKeywords = columnFilter
|
|
511
|
+
.split('+')
|
|
512
|
+
.map(k => k.trim())
|
|
513
|
+
.filter(k => !!k);
|
|
514
|
+
|
|
515
|
+
const cellValue = String(data[column] ?? '').toLowerCase();
|
|
516
|
+
|
|
517
|
+
const matchColumn = columnKeywords.some(keyword =>
|
|
518
|
+
cellValue.includes(keyword)
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
if (!matchColumn) return false;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return true;
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
this.updateDataSourceFilter();
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
updateDataSourceFilter(): void {
|
|
531
|
+
const filterObject = {
|
|
532
|
+
global: this.searchTableField ?? '',
|
|
533
|
+
columns: this.columnFilters ?? {},
|
|
534
|
+
};
|
|
535
|
+
this.dataSource.filter = JSON.stringify(filterObject);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
setFilters(): void {
|
|
540
|
+
this.userFilters.filters = JSON.stringify({
|
|
541
|
+
global: this.searchTableField,
|
|
542
|
+
columns: this.columnFilters,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
getMaskedValue(value: string | null): string {
|
|
548
|
+
return value ? '•'.repeat(value.length) : '';
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
togglePassword(key: string): void {
|
|
552
|
+
this.isPasswordVisible[key] = !this.isPasswordVisible[key];
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
toggleGroup(groupName: string) {
|
|
556
|
+
this.expandedGroups[groupName] = !this.expandedGroups[groupName];
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
getGroupIndex(groupName: string): number {
|
|
560
|
+
if (!this.expandableGroups || groupName === '_ungrouped') {
|
|
561
|
+
return 0;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
const index = this.availableGroups.indexOf(groupName);
|
|
565
|
+
return index !== -1 ? index + 1 : 0;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {Tuple} from './tuple.model';
|
|
2
|
+
import {ColumnSize, ColumnType, InputType} from '../utils/enums';
|
|
3
|
+
|
|
4
|
+
export class MatColumnTyped {
|
|
5
|
+
name: string = '';
|
|
6
|
+
value: string | null = null;
|
|
7
|
+
type?: ColumnType = ColumnType.TEXT;
|
|
8
|
+
enableIcon = 'thumb_up';
|
|
9
|
+
disableIcon = 'thumb_down';
|
|
10
|
+
enableColor = 'green-lih';
|
|
11
|
+
disableColor = 'red-lih';
|
|
12
|
+
enableTitle: string | null = null;
|
|
13
|
+
disableTitle: string | null = null;
|
|
14
|
+
enableTitleFromColumnName: string | null = null;
|
|
15
|
+
disableTitleFromColumnName: string | null = null;
|
|
16
|
+
mixColumnIconColor: Tuple[] = [];
|
|
17
|
+
enableFilter = false;
|
|
18
|
+
filterList: any[] = [];
|
|
19
|
+
isOverwriting = false;
|
|
20
|
+
readonly = false;
|
|
21
|
+
stickyClass = '';
|
|
22
|
+
isDynamic = false;
|
|
23
|
+
displayColumn: string | null = null;
|
|
24
|
+
id = 'id';
|
|
25
|
+
size?: ColumnSize | string = '';
|
|
26
|
+
gridSize = 6;
|
|
27
|
+
inputType?: InputType = InputType.Text;
|
|
28
|
+
order = 0;
|
|
29
|
+
compareFn?: (o1: any, o2: any) => boolean;
|
|
30
|
+
cssClass?: string = '';
|
|
31
|
+
cssClassFn?: (item: any, col: MatColumnTyped) => string;
|
|
32
|
+
conditionFn?: (item: any, col?: MatColumnTyped) => boolean;
|
|
33
|
+
groupName: string = '';
|
|
34
|
+
groupClass: string = '';
|
|
35
|
+
groupLabel: string = '';
|
|
36
|
+
groupOrder!: number;
|
|
37
|
+
|
|
38
|
+
constructor(init?: Partial<MatColumnTyped>) {
|
|
39
|
+
Object.assign(this, init);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {ColumnType} from '../utils/enums';
|
|
2
|
+
import {Tuple} from './tuple.model';
|
|
3
|
+
|
|
4
|
+
export class MatColumn {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string | null = null;
|
|
7
|
+
type: ColumnType = ColumnType.ICON;
|
|
8
|
+
|
|
9
|
+
enableIcon: string = 'thumb_up';
|
|
10
|
+
disableIcon: string = 'thumb_down';
|
|
11
|
+
|
|
12
|
+
enableColor: string = 'green-lih';
|
|
13
|
+
disableColor: string = 'red-lih';
|
|
14
|
+
|
|
15
|
+
enableTitle?: string;
|
|
16
|
+
disableTitle?: string;
|
|
17
|
+
|
|
18
|
+
enableTitleFromColumnName?: string;
|
|
19
|
+
disableTitleFromColumnName?: string;
|
|
20
|
+
|
|
21
|
+
mixColumnIconColor: Tuple[] = [];
|
|
22
|
+
|
|
23
|
+
enableFilter: boolean = false;
|
|
24
|
+
|
|
25
|
+
filterList: Array<any | Tuple | unknown> = [];
|
|
26
|
+
|
|
27
|
+
filterDisplayColumn?: string;
|
|
28
|
+
|
|
29
|
+
constructor(name: string, options?: Partial<Omit<MatColumn, 'name' | 'constructor'>>) {
|
|
30
|
+
this.name = name;
|
|
31
|
+
if (options) {
|
|
32
|
+
Object.assign(this, options);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.card-pricing .card-icon i {
|
|
2
|
+
font-size: 33px;
|
|
3
|
+
border: 1px solid #E5E5E5;
|
|
4
|
+
border-radius: 50%;
|
|
5
|
+
width: 45px !important;
|
|
6
|
+
line-height: 45px !important;
|
|
7
|
+
height: 45px !important;
|
|
8
|
+
text-align: center;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.card-pricing .card-icon {
|
|
12
|
+
padding: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.min-width-200 {
|
|
16
|
+
min-width: 200px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.min-width-250 {
|
|
20
|
+
min-width: 250px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.min-width-300 {
|
|
24
|
+
min-width: 300px;
|
|
25
|
+
}
|
|
26
|
+
|