From 19b7b721c836c24a96b0eeb8a51d5ef8a03b3bf8 Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Fri, 17 Nov 2023 09:43:47 +0100 Subject: [PATCH 01/12] change structure of checkIn form --- .../check-in-base-informations.component.html | 34 ----- .../check-in-base-informations.component.ts | 10 -- .../check-in-form-metric.component.html | 6 - .../check-in-form.component.html | 142 ++++++++++-------- .../check-in-form/check-in-form.component.ts | 34 ++++- 5 files changed, 110 insertions(+), 116 deletions(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html index 358d08b966..e1fcb4478d 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html +++ b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html @@ -1,39 +1,5 @@
- Veränderungen seit letztem Check-in (optional) - -
- - {{ errorMessages[errorKey.toUpperCase()] }} - -
- Massnahmen (optional) - -
- - {{ errorMessages[errorKey.toUpperCase()] }} - -
- -
- Action Plan -
- -
- {{ action.action }} -
-
-
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts index c3b981a0b6..8a26d99874 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts @@ -23,14 +23,4 @@ export class CheckInBaseInformationsComponent { const errors = this.dialogForm.get(name)?.errors; return errors == null ? [] : Object.keys(errors); } - - changeIsChecked(event: any, index: number) { - const actions = this.dialogForm.value.actionList; - actions[index] = { ...actions[index], isChecked: event.checked }; - this.dialogForm.patchValue({ actionList: actions }); - } - - getActions(): Action[] { - return this.dialogForm.controls['actionList'].value; - } } diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.html index e9269f4519..e366c4c1b8 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.html +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.html @@ -22,10 +22,4 @@ -
- Confidence um Target ({{ calculateTarget() | unitValueTransformation: keyResult.unit }}) zu erreichen - -
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html index 12b188273a..6f2f98c781 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html @@ -1,75 +1,97 @@ -
- - - -
-

Key Result

-

{{ keyResult.title }}

-
- - - -
-
- -
- -
- +
+ + + +

Key Result

+

{{ keyResult.title }}

+ +
+ Action Plan +
+ +
+ {{ action.action }} +
+
+
+ +
+ Veränderungen seit letztem Check-in (optional) + +
+ + {{ errorMessages[errorKey.toUpperCase()] }} + +
+
+ +
+ + +
+ +
+ Massnahmen (optional) + +
+ + {{ errorMessages[errorKey.toUpperCase()] }} + +
+
+ +
+ Confidence um Target + + ({{ calculateTarget(kr) | unitValueTransformation: kr.unit }} + + zu erreichen + + +
+
- -
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.ts index e674f9bec2..0ad2f22caf 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.ts @@ -10,6 +10,8 @@ import { CheckInService } from '../../../services/check-in.service'; import { Action } from '../../../types/model/Action'; import { DATE_FORMAT } from '../../../constantLibary'; import { ActionService } from '../../../services/action.service'; +import { formInputCheck } from '../../../common'; +import errorMessages from '../../../../../assets/errors/error-messages.json'; @Component({ selector: 'app-check-in-form', @@ -22,7 +24,8 @@ export class CheckInFormComponent implements OnInit { checkIn!: CheckInMin; currentDate: Date; continued: boolean = false; - protected readonly DATE_FORMAT = DATE_FORMAT; + protected readonly formInputCheck = formInputCheck; + protected readonly errorMessages: { [key: string]: string } = errorMessages; dialogForm = new FormGroup({ value: new FormControl('', [Validators.required]), @@ -48,6 +51,14 @@ export class CheckInFormComponent implements OnInit { this.dialogForm.patchValue({ actionList: this.keyResult.actionList }); } + isTouchedOrDirty(name: string) { + return this.dialogForm.get(name)?.dirty || this.dialogForm.get(name)?.touched; + } + getErrorKeysOfFormField(name: string): string[] { + const errors = this.dialogForm.get(name)?.errors; + return errors == null ? [] : Object.keys(errors); + } + setDefaultValues() { this.dialogForm.controls.actionList.setValue(this.keyResult.actionList); if (this.data.checkIn != null) { @@ -69,6 +80,10 @@ export class CheckInFormComponent implements OnInit { this.checkIn = { confidence: 5 } as CheckInMin; } + calculateTarget(keyResult: KeyResultMetric): number { + return keyResult.stretchGoal - (keyResult.stretchGoal - keyResult.baseline) * 0.3; + } + saveCheckIn() { this.dialogForm.controls.confidence.setValue(this.checkIn.confidence); let checkIn: any = { @@ -102,10 +117,17 @@ export class CheckInFormComponent implements OnInit { return this.keyResult as KeyResultOrdinal; } - getStepLabel(): string { - if (this.continued) { - return '(2/2)'; - } - return '(1/2)'; + getActions(): Action[] | null { + return this.dialogForm.controls['actionList'].value; + } + + changeIsChecked(event: any, index: number) { + const actions = this.dialogForm.value.actionList!; + actions[index] = { ...actions[index], isChecked: event.checked }; + this.dialogForm.patchValue({ actionList: actions }); + } + + convertToMetric(keyResult: KeyResult) { + return keyResult as KeyResultMetric; } } From 78260d2f89c0d5895662209653276601791123d2 Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Fri, 17 Nov 2023 11:53:13 +0100 Subject: [PATCH 02/12] remove unused files --- frontend/src/app/app.module.ts | 2 - .../check-in-base-informations.component.html | 5 - .../check-in-base-informations.component.scss | 7 -- ...eck-in-base-informations.component.spec.ts | 102 ------------------ .../check-in-base-informations.component.ts | 26 ----- .../check-in-form-ordinal.component.html | 4 - 6 files changed, 146 deletions(-) delete mode 100644 frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html delete mode 100644 frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.scss delete mode 100644 frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.spec.ts delete mode 100644 frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 7a6b98b188..0ac15b4dd3 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -50,7 +50,6 @@ import { MatCheckboxModule } from '@angular/material/checkbox'; import { CheckInFormMetricComponent } from './shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component'; import { UnitValueTransformationPipe } from './shared/pipes/unit-value-transformation/unit-value-transformation.pipe'; import { CheckInFormOrdinalComponent } from './shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component'; -import { CheckInBaseInformationsComponent } from './shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component'; import { CustomInputComponent } from './shared/custom/custom-input/custom-input.component'; import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; import { CheckInFormComponent } from './shared/dialog/checkin/check-in-form/check-in-form.component'; @@ -121,7 +120,6 @@ export const MY_FORMATS = { CheckInFormMetricComponent, UnitValueTransformationPipe, CheckInFormOrdinalComponent, - CheckInBaseInformationsComponent, CustomInputComponent, CheckInFormComponent, UnitLabelTransformationPipe, diff --git a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html deleted file mode 100644 index e1fcb4478d..0000000000 --- a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html +++ /dev/null @@ -1,5 +0,0 @@ -
- - - -
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.scss deleted file mode 100644 index f5e4d40cc7..0000000000 --- a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.scss +++ /dev/null @@ -1,7 +0,0 @@ -.action-list-item { - background-color: #f5f5f5; - height: 40px; - padding: 10px; - margin: auto; - color: black; -} diff --git a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.spec.ts deleted file mode 100644 index 037947b4d2..0000000000 --- a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.spec.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { CheckInBaseInformationsComponent } from './check-in-base-informations.component'; -import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; -import { HarnessLoader } from '@angular/cdk/testing'; -import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; -import { MatInputHarness } from '@angular/material/input/testing'; -import { By } from '@angular/platform-browser'; -// @ts-ignore -import * as errorData from '../../../../../assets/errors/error-messages.json'; -import { MatInputModule } from '@angular/material/input'; -import { MatDialogModule } from '@angular/material/dialog'; -import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { MatSelectModule } from '@angular/material/select'; -import { MatRadioModule } from '@angular/material/radio'; -import { Action } from '../../../types/model/Action'; -import { action1, action2 } from '../../../testData'; - -describe('CheckInBaseInformationsComponent', () => { - let component: CheckInBaseInformationsComponent; - let fixture: ComponentFixture; - let loader: HarnessLoader; - let errors = errorData; - - let changeInfoText = 'ChangeInfo'; - let initiativesText = 'Initiatives'; - - let action3: Action = { id: 3, version: 1, action: '', priority: 3, isChecked: true, keyResultId: 1 }; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - MatDialogModule, - NoopAnimationsModule, - MatSelectModule, - MatInputModule, - MatRadioModule, - ReactiveFormsModule, - ], - declarations: [CheckInBaseInformationsComponent], - }); - fixture = TestBed.createComponent(CheckInBaseInformationsComponent); - component = fixture.componentInstance; - component.dialogForm = new FormGroup({ - changeInfo: new FormControl('', [Validators.maxLength(4096)]), - initiatives: new FormControl('', [Validators.maxLength(4096)]), - actionList: new FormControl([action1, action2, action3]), - }); - fixture.detectChanges(); - loader = TestbedHarnessEnvironment.loader(fixture); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should save given text in input to form-group in typescript', async () => { - const changeInfoTextbox = fixture.debugElement.query(By.css('[data-testId="changeInfo"]')).nativeElement; - const initiativesTextbox = fixture.debugElement.query(By.css('[data-testId="initiatives"]')).nativeElement; - changeInfoTextbox.value = changeInfoText; - initiativesTextbox.value = initiativesText; - - //Update values in form - initiativesTextbox.dispatchEvent(new Event('input')); - changeInfoTextbox.dispatchEvent(new Event('input')); - - expect(component.dialogForm.controls['changeInfo'].value).toBe(changeInfoText); - expect(component.dialogForm.controls['initiatives'].value).toBe(initiativesText); - }); - - it('should display error message if text input too long', () => { - //Insert values into name input which don't match length validator - loader.getAllHarnesses(MatInputHarness).then(async (inputs) => { - const changeInfoTextbox = inputs[0]; - const initiativesTextbox = inputs[1]; - await changeInfoTextbox.setValue('x'.repeat(4097)); - await initiativesTextbox.setValue('x'.repeat(4097)); - - //Verify error message - const errorMessage = fixture.debugElement.query(By.css('mat-error')); - expect(errorMessage.nativeElement.textContent).toContain(errors.MAXLENGTH); - }); - }); - - it('should display action list', async () => { - const checkboxes = fixture.nativeElement.querySelectorAll('mat-checkbox'); - expect(checkboxes.length).toEqual(3); - expect(checkboxes[0].checked!).toBe(action1.isChecked); - expect(checkboxes[1].checked!).toBe(action2.isChecked); - }); - - it('should change state of action isChecked', async () => { - expect(component.dialogForm.value.actionList[0].isChecked).toBeFalsy(); - let event = { checked: true }; - component.changeIsChecked(event, 0); - expect(component.dialogForm.value.actionList[0].isChecked).toBeTruthy(); - - event = { checked: false }; - component.changeIsChecked(event, 0); - expect(component.dialogForm.value.actionList[0].isChecked).toBeFalsy(); - }); -}); diff --git a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts deleted file mode 100644 index 8a26d99874..0000000000 --- a/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { FormGroup } from '@angular/forms'; -import errorMessages from '../../../../../assets/errors/error-messages.json'; -import { formInputCheck } from '../../../common'; -import { Action } from '../../../types/model/Action'; - -@Component({ - selector: 'app-check-in-base-informations', - templateUrl: './check-in-base-informations.component.html', - styleUrls: ['./check-in-base-informations.component.scss'], -}) -export class CheckInBaseInformationsComponent { - @Input() - dialogForm!: FormGroup; - protected readonly errorMessages: any = errorMessages; - protected readonly formInputCheck = formInputCheck; - - isTouchedOrDirty(name: string) { - return this.dialogForm.get(name)?.dirty || this.dialogForm.get(name)?.touched; - } - - getErrorKeysOfFormField(name: string): string[] { - const errors = this.dialogForm.get(name)?.errors; - return errors == null ? [] : Object.keys(errors); - } -} diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.html b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.html index cf9f33687d..753a5b164e 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.html +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.html @@ -22,8 +22,4 @@
-
- Confidence um Target zu erreichen - -
From 90d7cef475a7fb584f48df547d6a0c2b43d301ef Mon Sep 17 00:00:00 2001 From: Yanick Minder Date: Fri, 17 Nov 2023 11:54:20 +0100 Subject: [PATCH 03/12] change bootstrap vars --- .../keyresult-detail.component.html | 6 +- .../keyresult-detail.component.scss | 2 +- .../check-in-form.component.html | 125 +++++++++--------- .../check-in-form.component.scss | 22 +-- frontend/src/style/_variables.scss | 2 +- frontend/src/style/custom_bootstrap.scss | 2 +- 6 files changed, 73 insertions(+), 86 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.html b/frontend/src/app/keyresult-detail/keyresult-detail.component.html index 76e39fbbea..5bf14a866c 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.html +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.html @@ -24,11 +24,7 @@ Confidence - + diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.scss b/frontend/src/app/keyresult-detail/keyresult-detail.component.scss index 31ca3e363f..c986515fcd 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.scss +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.scss @@ -1,7 +1,7 @@ @import "_variables"; .keyResult-detail-attribute-show { - background-color: $keyResult-detail-attribute-bg; + background-color: $show-element; height: 100%; font-size: 0.85rem; } diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html index 6f2f98c781..47bb7b53e6 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html @@ -3,73 +3,74 @@

Key Result

-

{{ keyResult.title }}

+

{{ keyResult.title }}

-
- Action Plan -
- -
- {{ action.action }} +
+
+ Action Plan + + + + {{ action.action }} + + +
+
+ Veränderungen seit letztem Check-in (optional) + +
+ + {{ errorMessages[errorKey.toUpperCase()] }} +
-
-
- -
- Veränderungen seit letztem Check-in (optional) - -
- - {{ errorMessages[errorKey.toUpperCase()] }} - -
-
+ -
- - -
+
+ + +
-
- Massnahmen (optional) - -
- - {{ errorMessages[errorKey.toUpperCase()] }} - -
-
+
+ Massnahmen (optional) + +
+ + {{ errorMessages[errorKey.toUpperCase()] }} + +
+
-
- Confidence um Target - - ({{ calculateTarget(kr) | unitValueTransformation: kr.unit }} - - zu erreichen - - -
+
+ Confidence um Target + + ({{ calculateTarget(kr) | unitValueTransformation: kr.unit }}) + + zu erreichen + + +
+