Skip to content

Commit

Permalink
fix bug that you couldnt edit objectives anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
nevio18324 committed Nov 26, 2024
1 parent 2096cb7 commit 80ae99e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .run/OkrApplication-Dev.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="OkrApplication-Dev" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ACTIVE_PROFILES" value="dev" />
<option name="ALTERNATIVE_JRE_PATH" value="$USER_HOME$/.sdkman/candidates/java/current" />
<option name="ALTERNATIVE_JRE_PATH" value="openjdk-21" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<module name="backend" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ch.puzzle.okr.OkrApplication" />
Expand Down
19 changes: 17 additions & 2 deletions frontend/src/app/services/objective.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { Objective } from '../shared/types/model/Objective';
import { Observable } from 'rxjs';
import { KeyResult } from '../shared/types/model/KeyResult';
import { KeyResultDTO } from '../shared/types/DTOs/KeyResultDTO';
import { User } from '../shared/types/model/User';
import { CheckIn } from '../shared/types/model/CheckIn';
import { Action } from '../shared/types/model/Action';

@Injectable({
providedIn: 'root',
Expand Down Expand Up @@ -34,8 +37,20 @@ export class ObjectiveService {
duplicateObjective(
objectiveId: number,
duplicateObjectiveDto: {
objective: Objective;
keyResults: KeyResult[];
keyResults: {
owner: User;
modifiedOn: Date | null | undefined;
keyResultType: string | undefined;
description: string;
actionList: Action[] | null;
id: undefined;
lastCheckIn: CheckIn | null | undefined;
title: string;
version: number;
createdOn: Date | null | undefined;
objective: Objective;
}[];
objective: any;
},
): Observable<Objective> {
return this.httpClient.post<Objective>(`/api/v2/objectives/${objectiveId}`, duplicateObjectiveDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,12 @@
</mat-checkbox>
</div>
</div>
<div class="col align-self-end w-100">
<div *ngIf="data.action === 'duplicate'" class="col align-self-end w-100">
<div class="okr-form-row okr-form-label-input-container w-100">
<label class="okr-form-label okr-form-col" for="keyresults">Keyresults übernehmen</label>
<label class="okr-form-label okr-form-col">Keyresults übernehmen</label>
<div class="okr-form-input pe-5 w-100">
<ng-container *ngIf="keyResults$ | async as keyResults" formArrayName="keyResults">
<mat-checkbox
*ngFor="let keyResult of keyResults; let i = index"
[formControlName]="i"
id="keyresults-{{ i }}"
>
<mat-checkbox *ngFor="let keyResult of keyResults; let i = index" [formControlName]="i">
{{ keyResult.title }}
</mat-checkbox>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,7 @@ export class ObjectiveFormComponent implements OnInit, OnDestroy {
state: state,
} as unknown as Objective;

const submitFunction = this.getSubmitFunction(this.data.objective.objectiveId!, {
objective: objectiveDTO,
keyResults: this.keyResults
.filter((keyResult, index) => value.keyResults[index])
.map((result) => ({ ...result, id: undefined })),
});
const submitFunction = this.getSubmitFunction(this.data.objective.objectiveId!, objectiveDTO);
submitFunction.subscribe((savedObjective: Objective) => {
this.closeDialog(savedObjective, false, value.createKeyResults!);
});
Expand Down Expand Up @@ -138,12 +133,21 @@ export class ObjectiveFormComponent implements OnInit, OnDestroy {
if (this.data.action == 'duplicate') {
objectiveDTO.id = null;
objectiveDTO.state = 'DRAFT' as State;
return this.objectiveService.duplicateObjective(id, objectiveDTO);
return this.objectiveService.duplicateObjective(id, {
objective: objectiveDTO,
keyResults: this.keyResults
.filter((keyResult, index) =>
this.objectiveForm.value.keyResults ? this.objectiveForm.value.keyResults[index] : false,
)
.map((result) => ({ ...result, id: undefined })),
});
} else {
if (this.data.action == 'releaseBacklog') objectiveDTO.state = 'ONGOING' as State;
return id
? this.objectiveService.updateObjective(objectiveDTO)
: this.objectiveService.createObjective(objectiveDTO);
if (this.data.objective.objectiveId) {
objectiveDTO.id = id;
return this.objectiveService.updateObjective(objectiveDTO);
}
return this.objectiveService.createObjective(objectiveDTO);
}
}

Expand Down

0 comments on commit 80ae99e

Please sign in to comment.