Skip to content

Commit

Permalink
#8 Use same naming as in generated frontend services
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Strittmatter <[email protected]>
  • Loading branch information
Weltraumschaf committed May 31, 2022
1 parent 3f34185 commit 08eab4b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/webapp/app/custom/teams/teams-skills.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TeamsSkillsService {
.pipe(
map(res => {
if (res.body) {
return this.convertItemFromServer(res.body);
return this.convertDateFromServer(res.body);
}

return new AchievableSkill();
Expand Down Expand Up @@ -56,30 +56,30 @@ export class TeamsSkillsService {
}

updateAchievableSkill(teamId: number, skill: IAchievableSkill): Observable<EntityResponseType> {
const copy = this.convert(skill);
const copy = this.convertDateFromClient(skill);
return this.http
.put<IAchievableSkill>(`${this.resourceUrl}/${teamId}/achievable-skills`, copy, { observe: 'response' })
.pipe(map((res: EntityResponseType) => this.convertResponse(res)));
}

private convertResponse(res: EntityResponseType): EntityResponseType {
const body: IAchievableSkill = res.body ? this.convertItemFromServer(res.body) : new AchievableSkill();
const body: IAchievableSkill = res.body ? this.convertDateFromServer(res.body) : new AchievableSkill();
return res.clone({ body });
}

private convertArrayResponse(res: EntityArrayResponseType): EntityArrayResponseType {
const jsonResponse: IAchievableSkill[] = res.body ? res.body : [];
const body: IAchievableSkill[] = [];
for (let i = 0; i < jsonResponse.length; i++) {
body.push(this.convertItemFromServer(jsonResponse[i]));
body.push(this.convertDateFromServer(jsonResponse[i]));
}
return res.clone({ body });
}

/**
* Convert a returned JSON object to Skill.
*/
private convertItemFromServer(achievableSkill: IAchievableSkill): IAchievableSkill {
private convertDateFromServer(achievableSkill: IAchievableSkill): IAchievableSkill {
return Object.assign({}, achievableSkill, {
achievedAt: achievableSkill.achievedAt != null ? moment(achievableSkill.achievedAt) : achievableSkill.achievedAt,
verifiedAt: achievableSkill.verifiedAt != null ? moment(achievableSkill.verifiedAt) : achievableSkill.verifiedAt,
Expand All @@ -89,7 +89,7 @@ export class TeamsSkillsService {
/**
* Convert a Skill to a JSON which can be sent to the server.
*/
private convert(achievableSkill: IAchievableSkill): IAchievableSkill {
private convertDateFromClient(achievableSkill: IAchievableSkill): IAchievableSkill {
return Object.assign({}, achievableSkill, {
completedAt: achievableSkill.achievedAt?.isValid() ? achievableSkill.achievedAt.toJSON() : null,
verifiedAt: achievableSkill.verifiedAt?.isValid() ? achievableSkill.verifiedAt.toJSON() : null,
Expand Down

0 comments on commit 08eab4b

Please sign in to comment.