Skip to content

Commit

Permalink
ARPA-957 Added missing properties to graphql query (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
VILLAN3LL3 authored Dec 3, 2023
1 parent 781c6b0 commit 3aa5c5b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 34 deletions.
9 changes: 9 additions & 0 deletions src/@arpa/services/person/person.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ export const PersonQuery = gql`
id
givenName
surname
birthName
dateOfBirth
birthplace
aboutMe
contactVia {
id
givenName
surname
displayName
}
personBackgroundTeam
reliability
generalPreference
Expand Down
6 changes: 3 additions & 3 deletions src/@arpa/services/person/person.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -23,8 +23,8 @@ export class PersonService {

public getPerson(id: string): Observable<PersonDto> {
// return this.apiService.get<PersonDto>(`${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) : {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@ 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({
selector: 'arpa-person-dialog-entry',
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const routes: Routes = [
{
path: '',
component: PersonDialogEntryComponent,
resolve: {
person: PersonResolver,
},
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: [
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<PersonDto> {
const { personId } = route.params;
Expand Down
10 changes: 4 additions & 6 deletions src/app/features/persons/person-list/person-list.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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
) {}

Expand All @@ -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();
});
}
Expand All @@ -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();
}
});
Expand Down

0 comments on commit 3aa5c5b

Please sign in to comment.