Skip to content

Commit 7b0d55d

Browse files
xflordHejdaJakub
authored andcommitted
fix: bug fixes after angular 15 migration
* fixed a bug where user could skip to second step of the add member org dialog without actually picking a VO * removed "No filter" dummy objects from resource assigned users page filters * fixed a bug where the bans table for the member wouldn't load if the user had no bans, also added Vo object to the EnrichedBanForVo object to avoid exceptions in ban on entity list * fixed a bug where user could try to add a group inclusion without a VO selected, resulting in an empty dialog
1 parent a29e5c0 commit 7b0d55d

File tree

5 files changed

+58
-50
lines changed

5 files changed

+58
-50
lines changed

apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<div>
22
<h1 class="page-subtitle">{{'FACILITY_DETAIL.ALLOWED_USERS.TITLE' | translate}}</h1>
33
<div class="filters">
4-
<perun-web-apps-refresh-button (refresh)="refreshPage()" class="mr-2">
4+
<perun-web-apps-refresh-button (refresh)="refreshPage()" class="me-2">
55
</perun-web-apps-refresh-button>
66
<perun-web-apps-debounce-filter
77
(filter)="applyFilter($event)"
88
[placeholder]="'FACILITY_DETAIL.ALLOWED_USERS.FILTER'"
9-
class="mr-2 filter"></perun-web-apps-debounce-filter>
9+
class="me-2 filter"></perun-web-apps-debounce-filter>
1010
<perun-web-apps-advanced-filter
1111
(changeAdvancedFilter)="advancedFilter=$event"
1212
[advancedFilter]="advancedFilter"
@@ -19,7 +19,7 @@ <h1 class="page-subtitle">{{'FACILITY_DETAIL.ALLOWED_USERS.TITLE' | translate}}<
1919
<mat-slide-toggle
2020
[(ngModel)]="allowed"
2121
(change)="changeFilter()"
22-
class="mr-2"
22+
class="me-2"
2323
labelPosition="before">
2424
{{'FACILITY_DETAIL.ALLOWED_USERS.FILTER_ALLOWED' | translate}}
2525
</mat-slide-toggle>
@@ -30,19 +30,22 @@ <h1 class="page-subtitle">{{'FACILITY_DETAIL.ALLOWED_USERS.TITLE' | translate}}<
3030
[vos]="vos"
3131
(voSelected)="voSelected($event)"
3232
[vo]="selectedVo"
33+
[disableAutoSelect]="true"
3334
class="search-select">
3435
</perun-web-apps-vo-search-select>
3536
<perun-web-apps-resource-search-select
3637
[resources]="filteredResources"
3738
(resourceSelected)="resourceSelected($event)"
3839
[displayStatus]="false"
3940
[resource]="selectedResource"
41+
[disableAutoSelect]="true"
4042
class="search-select">
4143
</perun-web-apps-resource-search-select>
4244
<perun-web-apps-service-search-select
4345
[services]="filteredServices"
4446
(serviceSelected)="serviceSelected($event)"
4547
[service]="selectedService"
48+
[disableAutoSelect]="true"
4649
class="search-select">
4750
</perun-web-apps-service-search-select>
4851
<mat-form-field class="search-select" *ngIf="globalForceConsents && facilityForceConsents">

apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.ts

Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,14 @@ export class FacilityAllowedUsersComponent implements OnInit {
4040

4141
allowed = true;
4242

43-
emptyResource: Resource = { id: -1, beanName: 'Resource', name: 'No filter' };
44-
resources: Resource[] = [this.emptyResource];
45-
filteredResources: Resource[] = [this.emptyResource];
46-
selectedResource: Resource = this.emptyResource;
47-
48-
emptyVo: Vo = { id: -1, beanName: 'Vo', name: 'No filter' };
49-
vos: Vo[] = [this.emptyVo];
50-
selectedVo: Vo = this.emptyVo;
51-
52-
emptyService: Service = { id: -1, beanName: 'Service', name: 'No filter' };
53-
services: Service[] = [this.emptyService];
54-
filteredServices: Service[] = [this.emptyService];
55-
selectedService: Service = this.emptyService;
43+
resources: Resource[] = [];
44+
filteredResources: Resource[] = [];
45+
selectedResource: Resource;
46+
vos: Vo[] = [];
47+
selectedVo: Vo;
48+
services: Service[] = [];
49+
filteredServices: Service[] = [];
50+
selectedService: Service;
5651

5752
globalForceConsents: boolean;
5853
facilityForceConsents: boolean;
@@ -102,13 +97,13 @@ export class FacilityAllowedUsersComponent implements OnInit {
10297

10398
changeFilter(): void {
10499
this.filtersCount = this.allowed ? 1 : 0;
105-
if (this.selectedVo.id !== -1) {
100+
if (this.selectedVo) {
106101
this.filtersCount += 1;
107102
}
108-
if (this.selectedResource.id !== -1) {
103+
if (this.selectedResource) {
109104
this.filtersCount += 1;
110105
}
111-
if (this.selectedService.id !== -1) {
106+
if (this.selectedService) {
112107
this.filtersCount += 1;
113108
}
114109
if (this.selectedConsentStatuses.length > 0) {
@@ -119,26 +114,29 @@ export class FacilityAllowedUsersComponent implements OnInit {
119114

120115
clearFilters(): void {
121116
this.allowed = false;
122-
this.selectedVo = this.emptyVo;
123-
this.selectedResource = this.emptyResource;
124-
this.selectedService = this.emptyService;
117+
this.selectedVo = undefined;
118+
this.selectedResource = undefined;
119+
this.selectedService = undefined;
125120
this.selectedConsentStatuses = [];
126121
this.statuses.setValue(this.selectedConsentStatuses);
127122
this.filtersCount = 0;
123+
this.voSelected(this.selectedVo);
124+
this.resourceSelected(this.selectedResource);
125+
this.serviceSelected(this.selectedService);
128126
this.cd.detectChanges();
129127
}
130128

131129
refreshPage(): void {
132130
this.facilityService
133131
.getAssignedResourcesForFacility(this.facility.id)
134132
.subscribe((resources) => {
135-
this.resources = [this.emptyResource].concat(resources);
133+
this.resources = resources;
136134
this.filteredResources = this.resources;
137135

138136
this.facilityService.getAllowedVos(this.facility.id).subscribe((vos) => {
139-
this.vos = [this.emptyVo].concat(vos);
137+
this.vos = vos;
140138
this.serviceService.getAssignedServices(this.facility.id).subscribe((services) => {
141-
this.services = [this.emptyService].concat(services);
139+
this.services = services;
142140
this.filteredServices = this.services;
143141
this.update = !this.update;
144142
this.cd.detectChanges();
@@ -152,43 +150,31 @@ export class FacilityAllowedUsersComponent implements OnInit {
152150
}
153151

154152
voSelected(vo: Vo): void {
155-
// prevents "fake" triggers
156-
if (this.selectedVo.id === vo.id) {
157-
return;
158-
}
159-
160153
this.selectedVo = vo;
161-
this.selectedResource = this.emptyResource;
162-
this.selectedService = this.emptyService;
154+
this.selectedResource = undefined;
155+
this.selectedService = undefined;
163156

164-
if (vo.id === -1) {
157+
if (!vo) {
165158
this.filteredResources = this.resources;
166159
this.filteredServices = this.services;
167160
} else {
168161
this.filteredResources = this.resources.filter((res) => res.voId === vo.id);
169162
this.serviceService.getAssignedServicesVo(this.facility.id, vo.id).subscribe((services) => {
170-
this.filteredServices = [this.emptyService].concat(services);
163+
this.filteredServices = services;
171164
});
172-
173-
this.filteredResources = [this.emptyResource].concat(this.filteredResources);
174165
}
175166
this.changeFilter();
176167
}
177168

178169
resourceSelected(resource: Resource): void {
179-
// prevents "fake" triggers
180-
if (this.selectedResource.id === resource.id) {
181-
return;
182-
}
183-
184170
this.selectedResource = resource;
185-
this.selectedService = this.emptyService;
171+
this.selectedService = undefined;
186172

187-
if (resource.id === -1) {
173+
if (resource === undefined) {
188174
this.filteredServices = this.services;
189175
} else {
190176
this.resourceService.getAssignedServicesToResource(resource.id).subscribe((services) => {
191-
this.filteredServices = [this.emptyService].concat(services);
177+
this.filteredServices = services;
192178
});
193179
}
194180
this.changeFilter();

apps/admin-gui/src/app/vos/pages/member-detail-page/member-bans/member-bans.component.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { EnrichedBanOnVo, Member, VosManagerService } from '@perun-web-apps/perun/openapi';
2+
import {
3+
EnrichedBanOnVo,
4+
Member,
5+
RichMember,
6+
VosManagerService,
7+
} from '@perun-web-apps/perun/openapi';
38
import { EntityStorageService } from '@perun-web-apps/perun/services';
49
import { BanOnEntityListColumn } from '@perun-web-apps/perun/components';
510
import { getDefaultDialogConfig } from '@perun-web-apps/perun/utils';
@@ -34,7 +39,15 @@ export class MemberBansComponent implements OnInit {
3439
this.loading = true;
3540
this.voService.getVoBanForMember(this.member.id).subscribe({
3641
next: (ban) => {
37-
this.bans = ban === null ? [] : [{ ban: ban, member: null, vo: null }];
42+
if (ban) {
43+
this.bans = [
44+
{
45+
ban: ban,
46+
member: this.member as RichMember,
47+
vo: { id: this.member.voId, beanName: 'Vo' },
48+
},
49+
];
50+
}
3851
this.loading = false;
3952
},
4053
error: () => (this.loading = false),

apps/admin-gui/src/app/vos/pages/vo-detail-page/vo-settings/vo-settings-hierarchical-inclusion/vo-settings-hierarchical-inclusion.component.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
<h1 class="page-subtitle">{{'VO_DETAIL.SETTINGS.HIERARCHICAL_INCLUSION.TITLE' | translate}}</h1>
22
<div class="display-flex">
33
<perun-web-apps-refresh-button (click)="loadAllowedGroups()"></perun-web-apps-refresh-button>
4-
<button (click)="addGroupsInclusion()" mat-flat-button class="mr-2 action-button" color="accent">
4+
<button
5+
[disabled]="!selectedParentVo"
6+
(click)="addGroupsInclusion()"
7+
mat-flat-button
8+
class="me-2 action-button"
9+
color="accent">
510
{{'VO_DETAIL.SETTINGS.HIERARCHICAL_INCLUSION.ADD' | translate}}
611
</button>
712
<button
813
[disabled]="selected.selected.length === 0"
914
(click)="removeGroupsInclusion()"
1015
mat-flat-button
1116
color="warn"
12-
class="mr-2">
17+
class="me-2">
1318
{{'VO_DETAIL.SETTINGS.HIERARCHICAL_INCLUSION.REMOVE' | translate}}
1419
</button>
1520
<div class="vo-search-select">
1621
<perun-web-apps-vo-search-select
1722
*ngIf="parentVos.length > 0"
1823
[vos]="parentVos"
19-
(voSelected)="voSelected($event)">
24+
(voSelected)="voSelected($event)"
25+
[disableAutoSelect]="true">
2026
</perun-web-apps-vo-search-select>
2127
</div>
2228
</div>

apps/admin-gui/src/app/vos/pages/vo-detail-page/vo-settings/vo-settings-member-organizations/add-member-organization-dialog/add-member-organization-dialog.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ <h1 mat-dialog-title>
88
</h1>
99
<div mat-dialog-content class="dialog-container">
1010
<mat-stepper #stepper [linear]="true">
11-
<mat-step>
11+
<mat-step [completed]="!(voSelection.selected.length === 0)">
1212
<ng-template
1313
matStepLabel
1414
>{{'VO_DETAIL.SETTINGS.MEMBER_ORGANIZATIONS.ADD_MEMBER_ORGANIZATION.SELECTION_STEP' | translate}}</ng-template

0 commit comments

Comments
 (0)