From 7b0d55d7fc04ebd0e3a298a6db05c3a8b827cd18 Mon Sep 17 00:00:00 2001 From: David Flor <493294@mail.muni.cz> Date: Thu, 23 Feb 2023 16:35:20 +0100 Subject: [PATCH] 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 --- .../facility-allowed-users.component.html | 9 ++- .../facility-allowed-users.component.ts | 68 ++++++++----------- .../member-bans/member-bans.component.ts | 17 ++++- ...ings-hierarchical-inclusion.component.html | 12 +++- ...-member-organization-dialog.component.html | 2 +- 5 files changed, 58 insertions(+), 50 deletions(-) diff --git a/apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.html b/apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.html index be1904e9e..39fec3b33 100644 --- a/apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.html +++ b/apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.html @@ -1,12 +1,12 @@

{{'FACILITY_DETAIL.ALLOWED_USERS.TITLE' | translate}}

- + + class="me-2 filter"> {{'FACILITY_DETAIL.ALLOWED_USERS.TITLE' | translate}}< {{'FACILITY_DETAIL.ALLOWED_USERS.FILTER_ALLOWED' | translate}} @@ -30,6 +30,7 @@

{{'FACILITY_DETAIL.ALLOWED_USERS.TITLE' | translate}}< [vos]="vos" (voSelected)="voSelected($event)" [vo]="selectedVo" + [disableAutoSelect]="true" class="search-select"> {{'FACILITY_DETAIL.ALLOWED_USERS.TITLE' | translate}}< (resourceSelected)="resourceSelected($event)" [displayStatus]="false" [resource]="selectedResource" + [disableAutoSelect]="true" class="search-select"> diff --git a/apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.ts b/apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.ts index baae0c0be..084fcc29f 100644 --- a/apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.ts +++ b/apps/admin-gui/src/app/facilities/pages/facility-detail-page/facility-allowed-users/facility-allowed-users.component.ts @@ -40,19 +40,14 @@ export class FacilityAllowedUsersComponent implements OnInit { allowed = true; - emptyResource: Resource = { id: -1, beanName: 'Resource', name: 'No filter' }; - resources: Resource[] = [this.emptyResource]; - filteredResources: Resource[] = [this.emptyResource]; - selectedResource: Resource = this.emptyResource; - - emptyVo: Vo = { id: -1, beanName: 'Vo', name: 'No filter' }; - vos: Vo[] = [this.emptyVo]; - selectedVo: Vo = this.emptyVo; - - emptyService: Service = { id: -1, beanName: 'Service', name: 'No filter' }; - services: Service[] = [this.emptyService]; - filteredServices: Service[] = [this.emptyService]; - selectedService: Service = this.emptyService; + resources: Resource[] = []; + filteredResources: Resource[] = []; + selectedResource: Resource; + vos: Vo[] = []; + selectedVo: Vo; + services: Service[] = []; + filteredServices: Service[] = []; + selectedService: Service; globalForceConsents: boolean; facilityForceConsents: boolean; @@ -102,13 +97,13 @@ export class FacilityAllowedUsersComponent implements OnInit { changeFilter(): void { this.filtersCount = this.allowed ? 1 : 0; - if (this.selectedVo.id !== -1) { + if (this.selectedVo) { this.filtersCount += 1; } - if (this.selectedResource.id !== -1) { + if (this.selectedResource) { this.filtersCount += 1; } - if (this.selectedService.id !== -1) { + if (this.selectedService) { this.filtersCount += 1; } if (this.selectedConsentStatuses.length > 0) { @@ -119,12 +114,15 @@ export class FacilityAllowedUsersComponent implements OnInit { clearFilters(): void { this.allowed = false; - this.selectedVo = this.emptyVo; - this.selectedResource = this.emptyResource; - this.selectedService = this.emptyService; + this.selectedVo = undefined; + this.selectedResource = undefined; + this.selectedService = undefined; this.selectedConsentStatuses = []; this.statuses.setValue(this.selectedConsentStatuses); this.filtersCount = 0; + this.voSelected(this.selectedVo); + this.resourceSelected(this.selectedResource); + this.serviceSelected(this.selectedService); this.cd.detectChanges(); } @@ -132,13 +130,13 @@ export class FacilityAllowedUsersComponent implements OnInit { this.facilityService .getAssignedResourcesForFacility(this.facility.id) .subscribe((resources) => { - this.resources = [this.emptyResource].concat(resources); + this.resources = resources; this.filteredResources = this.resources; this.facilityService.getAllowedVos(this.facility.id).subscribe((vos) => { - this.vos = [this.emptyVo].concat(vos); + this.vos = vos; this.serviceService.getAssignedServices(this.facility.id).subscribe((services) => { - this.services = [this.emptyService].concat(services); + this.services = services; this.filteredServices = this.services; this.update = !this.update; this.cd.detectChanges(); @@ -152,43 +150,31 @@ export class FacilityAllowedUsersComponent implements OnInit { } voSelected(vo: Vo): void { - // prevents "fake" triggers - if (this.selectedVo.id === vo.id) { - return; - } - this.selectedVo = vo; - this.selectedResource = this.emptyResource; - this.selectedService = this.emptyService; + this.selectedResource = undefined; + this.selectedService = undefined; - if (vo.id === -1) { + if (!vo) { this.filteredResources = this.resources; this.filteredServices = this.services; } else { this.filteredResources = this.resources.filter((res) => res.voId === vo.id); this.serviceService.getAssignedServicesVo(this.facility.id, vo.id).subscribe((services) => { - this.filteredServices = [this.emptyService].concat(services); + this.filteredServices = services; }); - - this.filteredResources = [this.emptyResource].concat(this.filteredResources); } this.changeFilter(); } resourceSelected(resource: Resource): void { - // prevents "fake" triggers - if (this.selectedResource.id === resource.id) { - return; - } - this.selectedResource = resource; - this.selectedService = this.emptyService; + this.selectedService = undefined; - if (resource.id === -1) { + if (resource === undefined) { this.filteredServices = this.services; } else { this.resourceService.getAssignedServicesToResource(resource.id).subscribe((services) => { - this.filteredServices = [this.emptyService].concat(services); + this.filteredServices = services; }); } this.changeFilter(); diff --git a/apps/admin-gui/src/app/vos/pages/member-detail-page/member-bans/member-bans.component.ts b/apps/admin-gui/src/app/vos/pages/member-detail-page/member-bans/member-bans.component.ts index 8598f10e6..b6cb8cc7e 100644 --- a/apps/admin-gui/src/app/vos/pages/member-detail-page/member-bans/member-bans.component.ts +++ b/apps/admin-gui/src/app/vos/pages/member-detail-page/member-bans/member-bans.component.ts @@ -1,5 +1,10 @@ import { Component, OnInit } from '@angular/core'; -import { EnrichedBanOnVo, Member, VosManagerService } from '@perun-web-apps/perun/openapi'; +import { + EnrichedBanOnVo, + Member, + RichMember, + VosManagerService, +} from '@perun-web-apps/perun/openapi'; import { EntityStorageService } from '@perun-web-apps/perun/services'; import { BanOnEntityListColumn } from '@perun-web-apps/perun/components'; import { getDefaultDialogConfig } from '@perun-web-apps/perun/utils'; @@ -34,7 +39,15 @@ export class MemberBansComponent implements OnInit { this.loading = true; this.voService.getVoBanForMember(this.member.id).subscribe({ next: (ban) => { - this.bans = ban === null ? [] : [{ ban: ban, member: null, vo: null }]; + if (ban) { + this.bans = [ + { + ban: ban, + member: this.member as RichMember, + vo: { id: this.member.voId, beanName: 'Vo' }, + }, + ]; + } this.loading = false; }, error: () => (this.loading = false), diff --git a/apps/admin-gui/src/app/vos/pages/vo-detail-page/vo-settings/vo-settings-hierarchical-inclusion/vo-settings-hierarchical-inclusion.component.html b/apps/admin-gui/src/app/vos/pages/vo-detail-page/vo-settings/vo-settings-hierarchical-inclusion/vo-settings-hierarchical-inclusion.component.html index 3ce1dcb4d..baa7f5930 100644 --- a/apps/admin-gui/src/app/vos/pages/vo-detail-page/vo-settings/vo-settings-hierarchical-inclusion/vo-settings-hierarchical-inclusion.component.html +++ b/apps/admin-gui/src/app/vos/pages/vo-detail-page/vo-settings/vo-settings-hierarchical-inclusion/vo-settings-hierarchical-inclusion.component.html @@ -1,7 +1,12 @@

{{'VO_DETAIL.SETTINGS.HIERARCHICAL_INCLUSION.TITLE' | translate}}

-
+ (voSelected)="voSelected($event)" + [disableAutoSelect]="true">
diff --git a/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 b/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 index 29d68112f..ccae6fbc1 100644 --- a/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 +++ b/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 @@ -8,7 +8,7 @@

- + {{'VO_DETAIL.SETTINGS.MEMBER_ORGANIZATIONS.ADD_MEMBER_ORGANIZATION.SELECTION_STEP' | translate}}