Skip to content

Commit

Permalink
Bugfix/arpa 937 put project body overload (#297)
Browse files Browse the repository at this point in the history
* ARPA-937 Fixed put project body overload
* introduced interface for project participation graphql query
* interface for project parent query
  • Loading branch information
VILLAN3LL3 authored Jan 4, 2024
1 parent de560bb commit aaabd74
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 89 deletions.
3 changes: 2 additions & 1 deletion src/@arpa/models/projectCreateDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export interface ProjectCreateDto {
endDate?: Date;
status?: ProjectStatus;
parentId?: string;
isCompleted?: boolean;
isCompleted: boolean;
isHiddenToPerformers: boolean;
}
9 changes: 4 additions & 5 deletions src/@arpa/models/projectDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ export interface ProjectDto {
modifiedBy?: string;
modifiedAt?: Date;
title: string;
shortTitle?: string;
shortTitle: string;
description?: string;
code?: string;
code: string;
type?: SelectValueDto;
genre?: SelectValueDto;
startDate?: Date;
endDate?: Date;
urls?: Array<UrlDto>;
status?: ProjectStatus;
parentId?: string;
isCompleted?: boolean;
parentProject?: string;
children: ReducedProjectDto[];
isCompleted: boolean;
isHiddenToPerformers: boolean;
}
3 changes: 2 additions & 1 deletion src/@arpa/models/projectModifyBodyDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export interface ProjectModifyBodyDto {
endDate?: Date;
status?: ProjectStatus;
parentId?: string;
isCompleted?: boolean;
isCompleted: boolean;
isHiddenToPerformers: boolean;
}
3 changes: 0 additions & 3 deletions src/@arpa/models/reducedProjectDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,4 @@ export interface ReducedProjectDto {
shortTitle?: string;
description?: string;
code?: string;
parentProjectId?: string;
parentProject?: { title: string; id: string };
children?: { title: string; id: string }[];
}
8 changes: 5 additions & 3 deletions src/@arpa/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
UrlCreateBodyDto,
ProjectDto,
ProjectParticipationDto,
ProjectModifyBodyDto,
ProjectCreateDto,
} from '@arpa/models';
import { first, map, shareReplay } from 'rxjs/operators';
import { HttpParams } from '@angular/common/http';
Expand Down Expand Up @@ -35,12 +37,12 @@ export class ProjectService {
return this.apiService.get<ProjectDto[]>(this.baseUrl).pipe(shareReplay());
}

public create(project: ProjectDto): Observable<ProjectDto> {
public create(project: ProjectCreateDto): Observable<ProjectDto> {
return this.apiService.post<ProjectDto>(this.baseUrl, project);
}

public update(project: ProjectDto): Observable<any> {
return this.apiService.put(`${this.baseUrl}/${project.id}`, project).pipe(shareReplay());
public update(id: string, project: ProjectModifyBodyDto): Observable<any> {
return this.apiService.put(`${this.baseUrl}/${id}`, project).pipe(shareReplay());
}

public getParticipations(id: string): Observable<ProjectParticipationDto[]> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="p-fluid p-grid p-formgrid">
<div class="p-field p-col-12 p-md-6">
<arpa-form-field label="projects.TITLE">
<input formControlName="title" id="title" maxlength="100" pInputText type="text"/>
<input formControlName="title" id="title" maxlength="100" pInputText type="text" />
</arpa-form-field>
</div>
<div class="p-field p-col-12 p-md-3">
Expand All @@ -22,7 +22,7 @@
</div>
<div class="p-field p-col-12 p-md-3">
<arpa-form-field label="projects.CODE">
<input formControlName="code" id="code" maxlength="15" pInputText type="text" />
<input formControlName="code" id="code" maxlength="15" pInputText type="text" />
</arpa-form-field>
</div>
<div class="p-field p-col-12 p-md-6">
Expand All @@ -33,12 +33,12 @@
(onFilter)="parentProjects.onFilter($event)"
[autoDisplayFirst]="false"
[filter]="true"
[options]="(transformFeedResult(feed) | async) || []"
[options]="(mapFeedResultToSelectItem(feed) | async) || []"
[showClear]="true"
appendTo="body"
filterBy="label"
formControlName="parentId"
id="parent"
id="parentId"
></p-dropdown>
</arpa-form-field>
</ng-template>
Expand All @@ -47,23 +47,23 @@
<arpa-form-field label="projects.TYPE" type="select">
<p-dropdown
[autoDisplayFirst]="false"
[options]="type || []"
[options]="typeOptions || []"
[showClear]="true"
appendTo="body"
formControlName="typeId"
id="type"
id="typeId"
></p-dropdown>
</arpa-form-field>
</div>
<div class="p-field p-col-12 p-md-6">
<arpa-form-field label="projects.GENRE" type="select">
<p-dropdown
[autoDisplayFirst]="false"
[options]="genre || []"
[options]="genreOptions || []"
[showClear]="true"
appendTo="body"
formControlName="genreId"
id="genre"
id="genreId"
></p-dropdown>
</arpa-form-field>
</div>
Expand All @@ -85,7 +85,7 @@
></p-dropdown>
</arpa-form-field>
</div>
<div class="p-field p-col-12 p-md-2" >
<div class="p-field p-col-12 p-md-2">
<arpa-form-field label="projects.COMPLETED" type="select">
<p-dropdown
[autoDisplayFirst]="false"
Expand All @@ -100,12 +100,7 @@
</div>
<div class="p-field p-col-12 p-md-6">
<arpa-form-field label="projects.IS_HIDDEN_FOR_PERFORMERS" type="checkbox" style="text-align: right">
<p-checkbox
ngDefaultControl
[binary]="true"
formControlName="isHiddenForPerformers"
id="isHiddenForPerformers"
></p-checkbox>
<p-checkbox ngDefaultControl [binary]="true" formControlName="isHiddenForPerformers" id="isHiddenForPerformers"></p-checkbox>
</arpa-form-field>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { BehaviorSubject, Observable } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
import { map } from 'rxjs/operators';
import { ProjectDto } from '@arpa/models';
import { ParentProjectsQuery } from './projectParents.graphql';
import { ParentProjectsQuery, ParentProjectsQueryResponse } from './projectParents.graphql';
import { FeedScope } from '../../../../../@arpa/components/graph-ql-feed/graph-ql-feed.component';
import { EnumService } from '@arpa/services';
import { ProjectsQueryResponse } from '../../project-list/projects.graphql';

@Component({
selector: 'arpa-edit-project',
Expand All @@ -17,10 +18,9 @@ import { EnumService } from '@arpa/services';
})
export class EditProjectComponent implements OnInit {
parentProjectsQuery = ParentProjectsQuery;
@Input() project: ProjectDto;
@Input() venues: SelectItem[];
@Input() type: SelectItem[];
@Input() genre: SelectItem[];
@Input() project: ProjectsQueryResponse;
@Input() typeOptions: SelectItem[];
@Input() genreOptions: SelectItem[];
projectStatusOptions$: Observable<SelectItem[]>;

// Info: In this component "translate.instant" is used. This will not update the translations on language change
Expand Down Expand Up @@ -69,9 +69,9 @@ export class EditProjectComponent implements OnInit {
}
}

public transformFeedResult(feed: FeedScope): Observable<SelectItem[]> {
public mapFeedResultToSelectItem(feed: FeedScope): Observable<SelectItem[]> {
return feed.values.pipe(
map((projects) =>
map((projects: ParentProjectsQueryResponse[]) =>
projects
.filter(({ id }) => (!this.project ? true : id !== this.project.id))
.map((project) => ({ label: project.title, value: project.id } as SelectItem))
Expand All @@ -83,7 +83,7 @@ export class EditProjectComponent implements OnInit {
if (this.form.invalid || this.form.pristine) {
return;
}
this.ref.close({ ...this.project, ...this.form.value } as ProjectDto);
this.ref.close({ ...this.form.value } as ProjectDto);
}

public cancel(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { gql } from 'apollo-angular';

export interface ParentProjectsQueryResponse {
id: string;
title: string;
shortTitle: string;
children: { id: string; title: string }[];
parent: { title: string };
}

export const ParentProjectsQuery = gql`
query Projects($orderTitle: SortEnumType = DESC, $orderShortTitle: SortEnumType = DESC, $searchQuery: String = "") {
projects(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ <h4>{{ child.title }}</h4>
<p-tabPanel leftIcon="pi pi-cog" header="{{ 'projects.BASICDATA' | translate }}" tooltip="{{ 'projects.BASICDATA_TOOLTIP' | translate }}">
<arpa-edit-project
[project]="project"
[venues]="(venues | async)!"
[type]="(type | async)!"
[genre]="(genre | async)!"
[typeOptions]="(typeOptions$ | async)!"
[genreOptions]="(genreOptions$ | async)!"
></arpa-edit-project>
</p-tabPanel>
</p-tabView>
Original file line number Diff line number Diff line change
@@ -1,45 +1,19 @@
import { Component, Input } from '@angular/core';
import { Component } from '@angular/core';
import { DynamicDialogConfig } from 'primeng/dynamicdialog';
import { Observable } from 'rxjs';
import { ProjectDto } from '@arpa/models';
import { VenueDto } from '@arpa/models';
import { SelectItem } from 'primeng/api';
import { map } from 'rxjs/operators';
import { ReducedProjectDto } from '../../../../@arpa/models/reducedProjectDto';
import { ProjectsQueryResponse } from '../project-list/projects.graphql';

@Component({
selector: 'arpa-project-layout',
templateUrl: './project-layout.component.html',
styleUrls: ['./project-layout.component.scss'],
})
export class ProjectLayoutComponent {
project: ProjectDto = this.config.data.project;
venues: Observable<SelectItem[]> = this.config.data.venues.pipe(
map((venues: VenueDto[]) =>
venues.map(
(v) =>
({
label: this.getAddress(v),
value: v.id,
} as SelectItem)
)
)
);
type: Observable<SelectItem[]> = this.config.data.type;
genre: Observable<SelectItem[]> = this.config.data.genre;
children: Observable<ReducedProjectDto[]> = this.config.data.children;
parent: Observable<ReducedProjectDto[]> = this.config.data.parent;
project: ProjectsQueryResponse = this.config.data.project;
typeOptions$: Observable<SelectItem[]> = this.config.data.type;
genreOptions$: Observable<SelectItem[]> = this.config.data.genre;
public index = 0;

constructor(public config: DynamicDialogConfig) {}

private getAddress(venue: VenueDto): string {
if (venue.address) {
const { city, urbanDistrict } = venue.address;
const comb = `${city ? city : ''}${city && urbanDistrict ? ' ' : ''}${urbanDistrict ? urbanDistrict : ''}`;
return `${comb}${comb ? ' | ' : ''}${venue.name}`;
} else {
return venue?.name || '';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { BehaviorSubject, Subscription } from 'rxjs';
import { DynamicDialogConfig, DialogService } from 'primeng/dynamicdialog';
import { ColumnDefinition } from '../../../../../@arpa/components/table/table.component';
import { DocumentNode } from 'graphql';
import { ProjectsQuery } from './projectparticipations.graphql';
import { ProjectParticipationDto } from '@arpa/models';
import { ProjectParticipationsQuery, ProjectParticipationsQueryResponse } from './projectparticipations.graphql';
import { first, map } from 'rxjs/operators';
import { ProjectService } from '@arpa/services';
import { ParticipationDialogComponent } from '../../../participation-dialog/participation-dialog.component';
Expand All @@ -23,8 +22,8 @@ export class ProjectParticipantsComponent implements OnInit, OnDestroy {

ready = false;

query: DocumentNode = ProjectsQuery;
columns: ColumnDefinition<ProjectParticipationDto>[] = [
query: DocumentNode = ProjectParticipationsQuery;
columns: ColumnDefinition<ProjectParticipationsQueryResponse>[] = [
{ label: 'projects.PARTICIPANTS', property: 'musicianProfile.person.displayName', type: 'text' },
{ label: 'projects.INSTRUMENT', property: 'musicianProfile.instrument.name', type: 'text' },
{ label: 'projects.EMAIL', property: 'musicianProfile.person.user.normalizedEmail', type: 'text' },
Expand Down Expand Up @@ -76,7 +75,7 @@ export class ProjectParticipantsComponent implements OnInit, OnDestroy {
{ label: 'MODIFIED_BY', property: 'modifiedBy', type: 'text' },
];

tableData = new BehaviorSubject<ProjectParticipationDto[]>([]);
tableData = new BehaviorSubject<ProjectParticipationsQueryResponse[]>([]);
totalReplies = 0;
totalInvited = 0;
innerStatsCount: Record<string, number> = {};
Expand All @@ -87,7 +86,7 @@ export class ProjectParticipantsComponent implements OnInit, OnDestroy {
finalResultsKeys: string[] = [];
personId: string | undefined;
project: any;
participations: ProjectParticipationDto[] = [];
participations: ProjectParticipationsQueryResponse[] = [];

constructor(
private config: DynamicDialogConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
import { gql } from 'apollo-angular';

export const ProjectsQuery = gql`
export interface ProjectParticipationsQueryResponse {
id: string;
title: string;
children: {
title: string;
id: string;
}[];
parent: {
title: string;
id: string;
};
projectParticipations: {
participationStatusInner: string;
participationStatusInternal: string;
participationStatusResult: string;
invitationStatus: string;
commentByStaffInner: string;
commentTeam: string;
modifiedAt: Date;
modifiedBy: string;
musicianProfile: {
id: string;
instrument: {
name: string;
};
qualification: {
selectValue: {
name: string;
};
};
person: {
id: string;
surname: string;
givenName: string;
displayName: string;
user: {
id: string;
normalizedEmail: string;
};
};
};
}[];
}

export const ProjectParticipationsQuery = gql`
query Projects($projectId: UUID) {
projects(where: { id: { equals: $projectId } }) {
pageInfo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import { UrlDto, RoleDto, UrlRoleDto } from '@arpa/models';
import { ProjectService, NotificationsService, RoleService } from '@arpa/services';
import { first, map } from 'rxjs/operators';
import { cloneDeep } from 'lodash-es';
import { ProjectsQueryUrlResponse } from '../../project-list/projects.graphql';

@Component({
selector: 'arpa-project-urls',
templateUrl: './project-urls.component.html',
styleUrls: ['./project-urls.component.scss'],
})
export class ProjectUrlsComponent implements OnInit {
@Input() urls: UrlDto[];
@Input() urls: ProjectsQueryUrlResponse[];
@Input() projectId: string;

form: UntypedFormGroup;
Expand Down
Loading

0 comments on commit aaabd74

Please sign in to comment.