Skip to content

Commit 4271700

Browse files
Copilotrenemadsen
andcommitted
Apply same refactoring to components/reports/report-table
Co-authored-by: renemadsen <[email protected]>
1 parent 4c2d692 commit 4271700

File tree

2 files changed

+43
-50
lines changed

2 files changed

+43
-50
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,49 @@
11
<mtx-grid
22
[data]="items"
33
[columns]="mergedTableHeaders"
4+
[cellTemplate]="{
5+
actions: actionsTpl
6+
}"
47
[showPaginator]="false"
58
[pageOnFront]="false"
69
[rowStriped]="true"
710
[showToolbar]="false"
811
[showColumnMenuButton]="false"
912
>
1013
</mtx-grid>
14+
15+
<ng-template #actionsTpl let-row let-i="index">
16+
<div class="report-actions" id="action-items-{{i}}">
17+
<button id="actionMenu" mat-icon-button [matMenuTriggerFor]="menu" matTooltip="{{ 'Actions' | translate }}">
18+
<mat-icon>more_vert</mat-icon>
19+
</button>
20+
21+
<mat-menu #menu="matMenu">
22+
<button
23+
mat-menu-item
24+
*ngIf="row.imagesCount !== 0"
25+
id="viewImagesBtn-{{i}}"
26+
(click)="onClickViewPicture(row.microtingSdkCaseId)"
27+
>
28+
<mat-icon>image</mat-icon>
29+
<span>{{ 'View images' | translate }}</span>
30+
</button>
31+
<button
32+
mat-menu-item
33+
id="editCaseBtn-{{i}}"
34+
(click)="onClickEditCase(row.microtingSdkCaseId, row.eFormId, row.id)"
35+
>
36+
<mat-icon>edit</mat-icon>
37+
<span>{{ 'Edit' | translate }}</span>
38+
</button>
39+
<button
40+
mat-menu-item
41+
id="deleteCaseBtn-{{i}}"
42+
(click)="onShowDeletePlanningCaseModal(row)"
43+
>
44+
<mat-icon color="warn">delete</mat-icon>
45+
<span>{{ 'Delete' | translate }}</span>
46+
</button>
47+
</mat-menu>
48+
</div>
49+
</ng-template>

eform-client/src/app/plugins/modules/backend-configuration-pn/components/reports/report-table/report-table.component.ts

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,8 @@ export class ReportTableComponent implements OnInit, OnChanges, OnDestroy {
5454
{
5555
header: this.translateService.stream('Actions'),
5656
field: 'actions',
57-
type: 'button',
58-
buttons: [
59-
{
60-
tooltip: this.translateService.stream('View images'),
61-
type: 'icon',
62-
click: (record: ReportEformItemModel) => this.onClickViewPicture(record.microtingSdkCaseId),
63-
icon: 'image',
64-
iif: (record: ReportEformItemModel) => record.imagesCount !== 0,
65-
},
66-
{
67-
tooltip: this.translateService.stream('Edit'),
68-
type: 'icon',
69-
click: (record: ReportEformItemModel) => this.onClickEditCase(record.microtingSdkCaseId, record.eFormId, record.id),
70-
icon: 'edit',
71-
},
72-
{
73-
tooltip: this.translateService.stream('Delete'),
74-
type: 'icon',
75-
click: (record: ReportEformItemModel) => this.onShowDeletePlanningCaseModal(record),
76-
color: 'warn',
77-
icon: 'delete',
78-
}
79-
]
57+
width: '160px',
58+
pinned: 'right',
8059
},
8160
];
8261
adminTableHeaders: MtxGridColumn[] = [
@@ -96,29 +75,8 @@ export class ReportTableComponent implements OnInit, OnChanges, OnDestroy {
9675
{
9776
header: this.translateService.stream('Actions'),
9877
field: 'actions',
99-
type: 'button',
100-
buttons: [
101-
{
102-
tooltip: this.translateService.stream('View images'),
103-
type: 'icon',
104-
click: (record: ReportEformItemModel) => this.onClickViewPicture(record.microtingSdkCaseId),
105-
icon: 'image',
106-
iif: (record: ReportEformItemModel) => record.imagesCount !== 0,
107-
},
108-
{
109-
tooltip: this.translateService.stream('Edit'),
110-
type: 'icon',
111-
click: (record: ReportEformItemModel) => this.onClickEditCase(record.microtingSdkCaseId, record.eFormId, record.id),
112-
icon: 'edit',
113-
},
114-
{
115-
tooltip: this.translateService.stream('Delete'),
116-
type: 'icon',
117-
click: (record: ReportEformItemModel) => this.onShowDeletePlanningCaseModal(record),
118-
color: 'warn',
119-
icon: 'delete',
120-
}
121-
]
78+
width: '160px',
79+
pinned: 'right',
12280
},
12381
];
12482
mergedTableHeaders: MtxGridColumn[] = [];
@@ -169,12 +127,8 @@ export class ReportTableComponent implements OnInit, OnChanges, OnDestroy {
169127
};
170128
});
171129
if (this.isAdmin) {
172-
this.adminTableHeaders.find(x => x.field === 'actions').class = ((record: ReportEformItemModel, _) =>
173-
record ? `id-${record.id}` : '');//microtingSdkCaseId${record.microtingSdkCaseId}-eFormId${record.eFormId}-
174130
this.mergedTableHeaders = [...this.adminTableHeaders, ...itemHeaders];
175131
} else {
176-
this.tableHeaders.find(x => x.field === 'actions').class = ((record: ReportEformItemModel, _) =>
177-
record ? `id-${record.id}` : '');//microtingSdkCaseId${record.microtingSdkCaseId}-eFormId${record.eFormId}-
178132
this.mergedTableHeaders = [...this.tableHeaders, ...itemHeaders];
179133
}
180134
}

0 commit comments

Comments
 (0)