Skip to content

Commit 1b9bba7

Browse files
committed
feat(profile): allow filtering by name and sorting on profile groups page
* name filter for each of the tables on the page was added * the membership table can now be sorted by name * added translation
1 parent fa4680e commit 1b9bba7

File tree

6 files changed

+27
-8
lines changed

6 files changed

+27
-8
lines changed

apps/user-profile/src/app/components/membership-list/membership-list.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</td>
2828
</ng-container>
2929
<ng-container matColumnDef="name">
30-
<th *matHeaderCellDef mat-header-cell>
30+
<th *matHeaderCellDef mat-header-cell mat-sort-header>
3131
{{'MEMBERSHIP_LIST.NAME' | customTranslate | translate}}
3232
</th>
3333
<td *matCellDef="let member" class="static-column-size" mat-cell>{{member.entity.name}}</td>
@@ -43,15 +43,15 @@
4343
{{'MEMBERSHIP_LIST.EXPIRATION' | customTranslate | translate}}
4444
</th>
4545
<td *matCellDef="let membership" mat-cell>
46-
{{membership.expirationAttribute | validateExpiration}}
46+
{{membership.expirationAttribute | validateExpiration | customTranslate | translate}}
4747
</td>
4848
</ng-container>
4949
<ng-container matColumnDef="extend">
5050
<th *matHeaderCellDef mat-header-cell></th>
5151
<td *matCellDef="let membership" mat-cell>
5252
<button
5353
(click)="extend(membership)"
54-
[disabled]="(membership.expirationAttribute | validateExpiration) === 'never'"
54+
[disabled]="(membership.expirationAttribute | validateExpiration) === 'MEMBERSHIP_LIST.NEVER'"
5555
color="accent"
5656
mat-flat-button>
5757
{{'MEMBERSHIP_LIST.EXTEND' | customTranslate | translate}}

apps/user-profile/src/app/pages/groups-page/groups-page.component.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,29 @@ <h1 class="page-title pt-2">{{'GROUPS.TITLE' | customTranslate | translate}}</h1
2323
<mat-spinner *ngIf="initialLoading" class="me-auto ms-auto"></mat-spinner>
2424

2525
<h4 class="page-subtitle">{{'GROUPS.MEMBER_GROUPS' | customTranslate | translate}}</h4>
26+
<perun-web-apps-debounce-filter
27+
[placeholder]="'ORGANIZATIONS.FILTER'"
28+
(filter)="applyFilter($event)"></perun-web-apps-debounce-filter>
2629
<div class="position-relative">
2730
<perun-web-apps-membership-list
2831
*perunWebAppsLoader="loading; indicator: spinner"
2932
[members]="userMemberships"
3033
[selection]="selection"
34+
[filterValue]="filterValue"
3135
[noMembershipFoundAlert]="'GROUPS.NO_GROUPS'"
3236
[displayedColumns]="['name', 'description', 'expirationAttribute', 'extend']"
3337
(extendMembership)="extendMembership($event)"></perun-web-apps-membership-list>
3438
</div>
3539

3640
<h4 class="page-subtitle mt-5">{{'GROUPS.ADMINS_GROUPS' | customTranslate | translate}}</h4>
41+
<perun-web-apps-debounce-filter
42+
[placeholder]="'ORGANIZATIONS.FILTER'"
43+
(filter)="applyAdminFilter($event)"></perun-web-apps-debounce-filter>
3744
<div class="position-relative">
3845
<perun-web-apps-membership-list
3946
*perunWebAppsLoader="loading; indicator: spinner"
4047
[members]="adminMemberships"
48+
[filterValue]="adminFilterValue"
4149
[noMembershipFoundAlert]="'GROUPS.NO_GROUPS'"
4250
[displayedColumns]="['name', 'description']"></perun-web-apps-membership-list>
4351
</div>

apps/user-profile/src/app/pages/groups-page/groups-page.component.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
MembersManagerService,
77
UsersManagerService,
88
Vo,
9-
VosManagerService,
109
} from '@perun-web-apps/perun/openapi';
1110
import { StoreService } from '@perun-web-apps/perun/services';
1211
import { UntypedFormControl } from '@angular/forms';
@@ -36,13 +35,14 @@ export class GroupsPageComponent implements OnInit {
3635
adminMemberships: Membership[] = [];
3736
userMembershipsTemp: Membership[] = [];
3837
adminMembershipsTemp: Membership[] = [];
38+
filterValue = '';
39+
adminFilterValue = '';
3940

4041
constructor(
4142
private usersService: UsersManagerService,
4243
private memberService: MembersManagerService,
4344
private groupService: GroupsManagerService,
4445
private store: StoreService,
45-
private vosManagerService: VosManagerService,
4646
private attributesManagerService: AttributesManagerService
4747
) {}
4848

@@ -171,9 +171,18 @@ export class GroupsPageComponent implements OnInit {
171171
window.location.href = `${registrarUrl}?vo=${voShortname}&group=${membership.entity.shortName}`;
172172
}
173173

174+
applyFilter(filterValue: string): void {
175+
this.filterValue = filterValue;
176+
}
177+
178+
applyAdminFilter(filterValue: string): void {
179+
this.adminFilterValue = filterValue;
180+
}
181+
174182
private _filter(value: string | Vo): Vo[] {
175-
const filterValue = typeof value === 'string' ? value.toLowerCase() : value.name.toLowerCase();
176-
return this.vos.filter((option) => option.name.toLowerCase().includes(filterValue));
183+
const voFilterValue =
184+
typeof value === 'string' ? value.toLowerCase() : value.name.toLowerCase();
185+
return this.vos.filter((option) => option.name.toLowerCase().includes(voFilterValue));
177186
}
178187

179188
private addToLists(): void {

apps/user-profile/src/app/pipes/validate-expiration.pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import { Attribute } from '@perun-web-apps/perun/openapi';
77
})
88
export class ValidateExpirationPipe implements PipeTransform {
99
transform(expirationAttribute: Attribute): string {
10-
return (expirationAttribute?.value as string) ?? 'never';
10+
return (expirationAttribute?.value as string) ?? 'MEMBERSHIP_LIST.NEVER';
1111
}
1212
}

apps/user-profile/src/assets/i18n/cs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
},
9191
"MEMBERSHIP_LIST": {
9292
"NAME": "Jméno",
93+
"NEVER": "nikdy",
9394
"DESCRIPTION": "Popis",
9495
"EXPIRATION": "Expirace členství",
9596
"EXTEND": "Prodloužit členství"

apps/user-profile/src/assets/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
},
9393
"MEMBERSHIP_LIST": {
9494
"NAME": "Name",
95+
"NEVER": "never",
9596
"DESCRIPTION": "Description",
9697
"EXPIRATION": "Expiration",
9798
"EXTEND": "Extend"

0 commit comments

Comments
 (0)