From 3aa5c5bd02243a0ae083cd69caa4dbee59a14cd1 Mon Sep 17 00:00:00 2001 From: VILLAN3LL3 <39371377+VILLAN3LL3@users.noreply.github.com> Date: Sun, 3 Dec 2023 12:47:47 +0100 Subject: [PATCH] ARPA-957 Added missing properties to graphql query (#285) --- src/@arpa/services/person/person.graphql.ts | 9 +++++++++ src/@arpa/services/person/person.service.ts | 6 +++--- .../person-dialog-entry.component.ts | 11 ++--------- .../person-dialog/person-dialog-routing.module.ts | 3 --- .../persons/person-dialog/person-dialog.module.ts | 4 +--- .../person-profiles/person-profiles.component.ts | 11 +++-------- .../person-dialog/resolvers/person.resolver.ts | 4 ++-- .../persons/person-list/person-list.component.ts | 10 ++++------ 8 files changed, 24 insertions(+), 34 deletions(-) diff --git a/src/@arpa/services/person/person.graphql.ts b/src/@arpa/services/person/person.graphql.ts index bb4d232d..044370ea 100644 --- a/src/@arpa/services/person/person.graphql.ts +++ b/src/@arpa/services/person/person.graphql.ts @@ -7,7 +7,16 @@ export const PersonQuery = gql` id givenName surname + birthName + dateOfBirth + birthplace aboutMe + contactVia { + id + givenName + surname + displayName + } personBackgroundTeam reliability generalPreference diff --git a/src/@arpa/services/person/person.service.ts b/src/@arpa/services/person/person.service.ts index 3ccb8d88..5cc1c2fb 100644 --- a/src/@arpa/services/person/person.service.ts +++ b/src/@arpa/services/person/person.service.ts @@ -3,7 +3,7 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { ApiService } from '@arpa/services'; import { PersonDto, ReducedPersonDto, PersonModifyBodyDto, PersonInviteResultDto } from '@arpa/models'; -import { first, map, shareReplay } from 'rxjs/operators'; +import { map, shareReplay } from 'rxjs/operators'; import { PersonQuery } from './person.graphql'; import { cloneDeep } from 'lodash-es'; @@ -23,8 +23,8 @@ export class PersonService { public getPerson(id: string): Observable { // return this.apiService.get(`${this.baseUrl}/${id}`); - return this.apollo.query({ query: PersonQuery, variables: { id } }).pipe( - first(), + return this.apollo.query({ query: PersonQuery, variables: { id }, fetchPolicy: 'no-cache' }).pipe( + shareReplay(), map((result: any) => { const person = result.data.persons.items?.[0]; return person ? cloneDeep(person) : {}; diff --git a/src/app/features/persons/person-dialog/person-dialog-entry/person-dialog-entry.component.ts b/src/app/features/persons/person-dialog/person-dialog-entry/person-dialog-entry.component.ts index 9b0a3adf..f3d30b35 100644 --- a/src/app/features/persons/person-dialog/person-dialog-entry/person-dialog-entry.component.ts +++ b/src/app/features/persons/person-dialog/person-dialog-entry/person-dialog-entry.component.ts @@ -3,7 +3,6 @@ import { PersonLayoutComponent } from '../person-layout/person-layout.component' import { Component } from '@angular/core'; import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router'; import { DialogService } from 'primeng/dynamicdialog'; -import { TranslateService } from '@ngx-translate/core'; import { first } from 'rxjs/operators'; @Component({ @@ -11,19 +10,13 @@ import { first } from 'rxjs/operators'; template: '', }) export class PersonDialogEntryComponent { - constructor( - private router: Router, - private route: ActivatedRoute, - private dialogService: DialogService, - private translate: TranslateService - ) { + constructor(private router: Router, private route: ActivatedRoute, private dialogService: DialogService) { this.route.data.pipe(first()).subscribe((data) => { - this.openDialog(data && data.person); + this.openDialog(data?.person); }); } public openDialog(selection?: PersonDto) { - const ref = this.dialogService.open(PersonLayoutComponent, { data: { person: selection, diff --git a/src/app/features/persons/person-dialog/person-dialog-routing.module.ts b/src/app/features/persons/person-dialog/person-dialog-routing.module.ts index 658041c5..e4777bb1 100644 --- a/src/app/features/persons/person-dialog/person-dialog-routing.module.ts +++ b/src/app/features/persons/person-dialog/person-dialog-routing.module.ts @@ -14,9 +14,6 @@ const routes: Routes = [ { path: '', component: PersonDialogEntryComponent, - resolve: { - person: PersonResolver, - }, }, ]; diff --git a/src/app/features/persons/person-dialog/person-dialog.module.ts b/src/app/features/persons/person-dialog/person-dialog.module.ts index 565618d3..275f4cbf 100644 --- a/src/app/features/persons/person-dialog/person-dialog.module.ts +++ b/src/app/features/persons/person-dialog/person-dialog.module.ts @@ -2,11 +2,10 @@ import { BadgeModule } from 'primeng/badge'; import { SelectValueModule } from '../../../../@arpa/pipes/select-value/select-value.module'; import { SelectDialogModule } from '../../profile/select-dialog/select-dialog.module'; import { SelectButtonModule } from 'primeng/selectbutton'; -import { TableModule } from '@arpa/components'; +import { TableModule, ProfilePictureModule, FormFieldModule } from '@arpa/components'; import { AutoCompleteModule } from 'primeng/autocomplete'; import { CalendarModule } from 'primeng/calendar'; import { InputTextModule } from 'primeng/inputtext'; -import { FormFieldModule } from '@arpa/components'; import { ButtonModule } from 'primeng/button'; import { PersonDialogEntryComponent } from './person-dialog-entry/person-dialog-entry.component'; import { PersonLayoutComponent } from './person-layout/person-layout.component'; @@ -35,7 +34,6 @@ import { AvatarModule } from 'primeng/avatar'; import { FileUploadModule } from 'primeng/fileupload'; import { MatIconModule } from '@angular/material/icon'; import { PersonAddressesComponent } from './person-addresses/person-addresses.component'; -import { ProfilePictureModule } from '@arpa/components'; @NgModule({ declarations: [ diff --git a/src/app/features/persons/person-dialog/person-profiles/person-profiles.component.ts b/src/app/features/persons/person-dialog/person-profiles/person-profiles.component.ts index 100fcf3b..00a552fe 100644 --- a/src/app/features/persons/person-dialog/person-profiles/person-profiles.component.ts +++ b/src/app/features/persons/person-dialog/person-profiles/person-profiles.component.ts @@ -1,16 +1,11 @@ import { Component, Input } from '@angular/core'; import { PersonDto } from '@arpa/models'; - @Component({ selector: 'arpa-person-profiles', templateUrl: './person-profiles.component.html', - styleUrls: ['./person-profiles.component.scss'] + styleUrls: ['./person-profiles.component.scss'], }) -export class PersonProfilesComponent { - @Input() person: PersonDto |null; - - constructor() {} - - +export class PersonProfilesComponent { + @Input() person: PersonDto | null; } diff --git a/src/app/features/persons/person-dialog/resolvers/person.resolver.ts b/src/app/features/persons/person-dialog/resolvers/person.resolver.ts index 78b44125..ecc48e22 100644 --- a/src/app/features/persons/person-dialog/resolvers/person.resolver.ts +++ b/src/app/features/persons/person-dialog/resolvers/person.resolver.ts @@ -1,14 +1,14 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; -import { MeService, PersonService } from '@arpa/services'; +import { PersonService } from '@arpa/services'; import { PersonDto } from '@arpa/models'; @Injectable({ providedIn: 'root', }) export class PersonResolver { - constructor(private meService: MeService, private personService: PersonService) {} + constructor(private personService: PersonService) {} resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { const { personId } = route.params; diff --git a/src/app/features/persons/person-list/person-list.component.ts b/src/app/features/persons/person-list/person-list.component.ts index 8815dc98..b1362215 100644 --- a/src/app/features/persons/person-list/person-list.component.ts +++ b/src/app/features/persons/person-list/person-list.component.ts @@ -1,4 +1,4 @@ -import { SelectValueService, NotificationsService, PersonService } from '@arpa/services'; +import { SelectValueService } from '@arpa/services'; import { PersonLayoutComponent } from '../person-dialog/person-layout/person-layout.component'; import { DialogService } from 'primeng/dynamicdialog'; import { SelectItem } from 'primeng/api'; @@ -45,8 +45,6 @@ export class PersonListComponent implements OnInit { public translate: TranslateService, private router: Router, private route: ActivatedRoute, - private personService: PersonService, - private notificationsService: NotificationsService, private selectValueService: SelectValueService ) {} @@ -59,14 +57,14 @@ export class PersonListComponent implements OnInit { public openPersonDetailDialog(selection: PersonDto | null): void { const ref = this.dialogService.open(PersonLayoutComponent, { data: { - person: selection ? selection : null, + person: selection ?? null, gender: this.selectValueService.getPersonGenders(), }, header: selection ? this.translate.instant('persons.EDIT_PERSON') : this.translate.instant('persons.ADD_NEW_PERSON'), styleClass: 'form-modal', dismissableMask: true, }); - ref.onClose.pipe(first()).subscribe((person: PersonDto) => { + ref.onClose.pipe(first()).subscribe(() => { this.feedSource.refresh(); }); } @@ -78,7 +76,7 @@ export class PersonListComponent implements OnInit { map(() => this.router.getCurrentNavigation()?.extras as NavigationExtras) ) .subscribe(({ state }) => { - if (state && state.refresh) { + if (state?.refresh) { this.feedSource.refresh(); } });