Skip to content

Commit 347b6c2

Browse files
Copilotrenemadsen
andcommitted
Refactor report-table Actions column to use menu dropdown pattern
Co-authored-by: renemadsen <[email protected]>
1 parent 7c8b869 commit 347b6c2

File tree

2 files changed

+44
-49
lines changed

2 files changed

+44
-49
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,50 @@
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+
color="warn"
42+
id="deleteCaseBtn-{{i}}"
43+
(click)="onShowDeletePlanningCaseModal(row)"
44+
>
45+
<mat-icon color="warn">delete</mat-icon>
46+
<span>{{ 'Delete' | translate }}</span>
47+
</button>
48+
</mat-menu>
49+
</div>
50+
</ng-template>

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

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,8 @@ export class ReportTableComponent implements OnInit, OnChanges, OnDestroy {
4949
{
5050
header: this.translateService.stream('Actions'),
5151
field: 'actions',
52-
type: 'button',
53-
buttons: [
54-
{
55-
tooltip: this.translateService.stream('View images'),
56-
type: 'icon',
57-
click: (record: ReportEformItemModel) => this.onClickViewPicture(record.microtingSdkCaseId),
58-
icon: 'image',
59-
iif: (record: ReportEformItemModel) => record.imagesCount !== 0,
60-
},
61-
{
62-
tooltip: this.translateService.stream('Edit'),
63-
type: 'icon',
64-
click: (record: ReportEformItemModel) => this.onClickEditCase(record.microtingSdkCaseId, record.eFormId, record.id),
65-
icon: 'edit',
66-
},
67-
{
68-
tooltip: this.translateService.stream('Delete'),
69-
type: 'icon',
70-
click: (record: ReportEformItemModel) => this.onShowDeletePlanningCaseModal(record),
71-
color: 'warn',
72-
icon: 'delete',
73-
}
74-
]
52+
width: '160px',
53+
pinned: 'right',
7554
},
7655
{header: this.translateService.stream('Employee no'), field: 'employeeNo'},
7756
];
@@ -87,29 +66,8 @@ export class ReportTableComponent implements OnInit, OnChanges, OnDestroy {
8766
{
8867
header: this.translateService.stream('Actions'),
8968
field: 'actions',
90-
type: 'button',
91-
buttons: [
92-
{
93-
tooltip: this.translateService.stream('View images'),
94-
type: 'icon',
95-
click: (record: ReportEformItemModel) => this.onClickViewPicture(record.microtingSdkCaseId),
96-
icon: 'image',
97-
iif: (record: ReportEformItemModel) => record.imagesCount !== 0,
98-
},
99-
{
100-
tooltip: this.translateService.stream('Edit'),
101-
type: 'icon',
102-
click: (record: ReportEformItemModel) => this.onClickEditCase(record.microtingSdkCaseId, record.eFormId, record.id),
103-
icon: 'edit',
104-
},
105-
{
106-
tooltip: this.translateService.stream('Delete'),
107-
type: 'icon',
108-
click: (record: ReportEformItemModel) => this.onShowDeletePlanningCaseModal(record),
109-
color: 'warn',
110-
icon: 'delete',
111-
}
112-
]
69+
width: '160px',
70+
pinned: 'right',
11371
},
11472
{header: this.translateService.stream('Employee no'), field: 'employeeNo'},
11573
];
@@ -161,9 +119,6 @@ export class ReportTableComponent implements OnInit, OnChanges, OnDestroy {
161119
let isAdmin = false;
162120
this.selectAuthIsAdmin$.subscribe((selectAuthIsAdmin$) => isAdmin = selectAuthIsAdmin$);
163121
const tableHeaders = [...(isAdmin ? [...this.adminTableHeaders] : [...this.tableHeaders])];
164-
const index = tableHeaders
165-
.findIndex(x => x.field === 'actions');
166-
tableHeaders[index].width = this.items.filter(x => x.imagesCount > 0).length > 0 ? '160px' : '110px';
167122

168123
this.mergedTableHeaders = [
169124
...tableHeaders,

0 commit comments

Comments
 (0)