From 6916021ca310b83611d96721321e4784f0b2542b Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Thu, 20 Feb 2025 09:14:49 +0100 Subject: [PATCH 1/6] add version to item --- .../components/action-plan/action-plan.component.ts | 4 +++- .../checkin/check-in-form/check-in-form.component.ts | 12 ++---------- frontend/src/app/shared/common.ts | 6 ++++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/frontend/src/app/components/action-plan/action-plan.component.ts b/frontend/src/app/components/action-plan/action-plan.component.ts index 8a839b7e4b..c7489bd177 100644 --- a/frontend/src/app/components/action-plan/action-plan.component.ts +++ b/frontend/src/app/components/action-plan/action-plan.component.ts @@ -24,13 +24,15 @@ export interface Item { id: number | undefined; item: string; isChecked: boolean; + version: number; } export function initFormGroupFromItem(item?: Item): FormGroup> { return new FormGroup({ item: new FormControl(item?.item || '', [Validators.minLength(2)]), id: new FormControl(item?.id || undefined), - isChecked: new FormControl(item?.isChecked || false) + isChecked: new FormControl(item?.isChecked || false), + version: new FormControl(item?.version || 1) } as FormControlsOf); } diff --git a/frontend/src/app/components/checkin/check-in-form/check-in-form.component.ts b/frontend/src/app/components/checkin/check-in-form/check-in-form.component.ts index 3f8be9f524..a0b1aa563c 100644 --- a/frontend/src/app/components/checkin/check-in-form/check-in-form.component.ts +++ b/frontend/src/app/components/checkin/check-in-form/check-in-form.component.ts @@ -19,7 +19,7 @@ import { CheckInOrdinalMin } from '../../../shared/types/model/check-in-ordinal- import { Zone } from '../../../shared/types/enums/zone'; import { numberValidator } from '../../../shared/constant-library'; -import { FormControlsOf, Item } from '../../action-plan/action-plan.component'; +import { FormControlsOf, initFormGroupFromItem, Item } from '../../action-plan/action-plan.component'; import { Observable } from 'rxjs'; @Component({ selector: 'app-check-in-form', @@ -169,7 +169,7 @@ export class CheckInFormComponent implements OnInit { addNewItem(item?: Item) { this.getFormControlArray() - ?.push(this.initFormGroupFromItem(item)); + ?.push(initFormGroupFromItem(item)); } setValidators(type: string) { @@ -178,12 +178,4 @@ export class CheckInFormComponent implements OnInit { this.dialogForm.get(this.checkInTypes.filter((formName) => formName.includes(type))) ?.enable({ emitEvent: false }); } - - initFormGroupFromItem(item?: Item): FormGroup> { - return new FormGroup({ - item: new FormControl(item?.item || '', [Validators.minLength(2)]), - id: new FormControl(item?.id || undefined), - isChecked: new FormControl(item?.isChecked || false) - } as FormControlsOf); - } } diff --git a/frontend/src/app/shared/common.ts b/frontend/src/app/shared/common.ts index 718166601f..3623cb8967 100644 --- a/frontend/src/app/shared/common.ts +++ b/frontend/src/app/shared/common.ts @@ -151,7 +151,8 @@ export function actionListToItemList(actionList: Action[]): Item[] { return (actionList || []).map((action) => { return { id: action.id, item: action.action, - isChecked: action.isChecked } as Item; + isChecked: action.isChecked, + version: action.version || 1 } as Item; }); } @@ -163,7 +164,8 @@ export function itemListToActionList(itemList: Item[], keyResultId: number | nul action: item.item, priority: index, keyResultId: keyResultId, - isChecked: item.isChecked + isChecked: item.isChecked, + version: item.version } as Action; }); } From d90db4cbab89a08f81b3f3132d52d31356d3ed3a Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Thu, 20 Feb 2025 09:23:17 +0100 Subject: [PATCH 2/6] add e2e to ensure behavior --- .run/OkrApplication-E2E.run.xml | 2 +- frontend/cypress/e2e/check-in.cy.ts | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.run/OkrApplication-E2E.run.xml b/.run/OkrApplication-E2E.run.xml index aa7706165a..d14babf764 100644 --- a/.run/OkrApplication-E2E.run.xml +++ b/.run/OkrApplication-E2E.run.xml @@ -1,7 +1,7 @@