From 947302988de18a3e880d0fde919f38ad816653d4 Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 26 Sep 2023 12:53:18 +0200 Subject: [PATCH 01/97] generate check in dialog --- frontend/src/app/app.module.ts | 2 ++ .../keyresult-detail.component.html | 2 +- .../keyresult-detail.component.ts | 9 ++++++++ .../check-in-form.component.html | 1 + .../check-in-form.component.scss | 0 .../check-in-form.component.spec.ts | 22 +++++++++++++++++++ .../check-in-form/check-in-form.component.ts | 10 +++++++++ 7 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html create mode 100644 frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss create mode 100644 frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts create mode 100644 frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 93f470d9c6..0a12765876 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -47,6 +47,7 @@ import { DrawerInterceptor } from './shared/interceptors/drawer.interceptor'; import { CheckInHistoryDialogComponent } from './shared/dialog/check-in-history-dialog/check-in-history-dialog.component'; import { MatDividerModule } from '@angular/material/divider'; import { ApplicationBannerComponent } from './application-banner/application-banner.component'; +import { CheckInFormComponent } from './shared/dialog/check-in-form/check-in-form.component'; import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog.component'; import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; @@ -95,6 +96,7 @@ export const MY_FORMATS = { ApplicationBannerComponent, KeyResultDialogComponent, ConfirmDialogComponent, + CheckInFormComponent, ], imports: [ CommonModule, diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.html b/frontend/src/app/keyresult-detail/keyresult-detail.component.html index db0bc88511..6542e035c2 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.html +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.html @@ -65,6 +65,6 @@

Beschrieb

- +
diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index d80203e110..ce4bf28c2a 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -7,6 +7,7 @@ import { CheckInHistoryDialogComponent } from '../shared/dialog/check-in-history import { MatDialog } from '@angular/material/dialog'; import { KeyResultDialogComponent } from '../key-result-dialog/key-result-dialog.component'; import { NotifierService } from '../shared/services/notifier.service'; +import { CheckInFormComponent } from '../shared/dialog/check-in-form/check-in-form.component'; @Component({ selector: 'app-keyresult-detail', @@ -79,4 +80,12 @@ export class KeyresultDetailComponent implements OnChanges { this.changeDetectorRef.markForCheck(); }); } + + openCheckInForm() { + const dialogRef = this.dialog.open(CheckInFormComponent, { + data: { + keyResultId: this.keyResult.id, + }, + }); + } } diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html new file mode 100644 index 0000000000..6c0fddf40d --- /dev/null +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html @@ -0,0 +1 @@ +

check-in-form works!

diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts new file mode 100644 index 0000000000..295b69a38d --- /dev/null +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CheckInFormComponent } from './check-in-form.component'; +import {MatDialogModule} from "@angular/material/dialog"; + +describe('CheckInFormComponent', () => { + let component: CheckInFormComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [CheckInFormComponent] + }); + fixture = TestBed.createComponent(CheckInFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts new file mode 100644 index 0000000000..32b1d392ff --- /dev/null +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-check-in-form', + templateUrl: './check-in-form.component.html', + styleUrls: ['./check-in-form.component.scss'] +}) +export class CheckInFormComponent { + +} From 5793787d825ddbf2394fe498b53d37e1abb96cbb Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 26 Sep 2023 12:53:56 +0200 Subject: [PATCH 02/97] format generated dialog --- .../dialog/check-in-form/check-in-form.component.spec.ts | 3 +-- .../shared/dialog/check-in-form/check-in-form.component.ts | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts index 295b69a38d..24eed6bd94 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts @@ -1,7 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CheckInFormComponent } from './check-in-form.component'; -import {MatDialogModule} from "@angular/material/dialog"; describe('CheckInFormComponent', () => { let component: CheckInFormComponent; @@ -9,7 +8,7 @@ describe('CheckInFormComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [CheckInFormComponent] + declarations: [CheckInFormComponent], }); fixture = TestBed.createComponent(CheckInFormComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts index 32b1d392ff..f7bed283a8 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts @@ -3,8 +3,6 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-check-in-form', templateUrl: './check-in-form.component.html', - styleUrls: ['./check-in-form.component.scss'] + styleUrls: ['./check-in-form.component.scss'], }) -export class CheckInFormComponent { - -} +export class CheckInFormComponent {} From 7091427d003444be86ff7e5bc96aab76f097a794 Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 26 Sep 2023 13:19:20 +0200 Subject: [PATCH 03/97] implement structure --- .../keyresult-detail.component.ts | 2 +- .../check-in-form.component.html | 6 ++++- .../check-in-form/check-in-form.component.ts | 24 +++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index ce4bf28c2a..3e84c0ada6 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -84,7 +84,7 @@ export class KeyresultDetailComponent implements OnChanges { openCheckInForm() { const dialogRef = this.dialog.open(CheckInFormComponent, { data: { - keyResultId: this.keyResult.id, + keyResult: this.keyResult, }, }); } diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html index 6c0fddf40d..31c2437502 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html @@ -1 +1,5 @@ -

check-in-form works!

+
+

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+

Key Result

+ +
diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts index f7bed283a8..a236b163a0 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts @@ -1,8 +1,28 @@ -import { Component } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { KeyResult } from '../../types/model/KeyResult'; +import { now } from 'moment'; @Component({ selector: 'app-check-in-form', templateUrl: './check-in-form.component.html', styleUrls: ['./check-in-form.component.scss'], }) -export class CheckInFormComponent {} +export class CheckInFormComponent implements OnInit { + keyResult: KeyResult; + currentDate: Date; + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any, + ) { + this.keyResult = data.keyResult; + this.currentDate = new Date(); + } + + ngOnInit(): void { + console.log(this.keyResult.createdOn); + } + + protected readonly now = now; + protected readonly Date = Date; +} From 435f5f3277fd354eaf289440c98b89f0af2ba09f Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 26 Sep 2023 16:11:44 +0200 Subject: [PATCH 04/97] change width of dialog and implement formgroup and corresponding methods of example-dialog --- .../keyresult-detail.component.ts | 1 + .../check-in-form.component.html | 21 ++++++++++++++++--- .../check-in-form/check-in-form.component.ts | 20 ++++++++++++++---- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 3e84c0ada6..c091b26d27 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -86,6 +86,7 @@ export class KeyresultDetailComponent implements OnChanges { data: { keyResult: this.keyResult, }, + width: '719px', }); } } diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html index 31c2437502..9d56138316 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html @@ -1,5 +1,20 @@
-

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

-

Key Result

- +
+

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+
+

Key Result

+ {{ keyResult.lastCheckIn?.changeInfo }} + +
+ + Veränderung seit letztem Check-in (optional) + +
+ + {{ errorMessages[errorKey.toUpperCase()] }} + +
+
+
+
diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts index a236b163a0..7b3c4ca183 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts @@ -1,7 +1,8 @@ import { Component, Inject, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { KeyResult } from '../../types/model/KeyResult'; -import { now } from 'moment'; +import { FormGroup } from '@angular/forms'; +import errorMessages from '../../../../assets/errors/error-messages.json'; @Component({ selector: 'app-check-in-form', @@ -11,6 +12,9 @@ import { now } from 'moment'; export class CheckInFormComponent implements OnInit { keyResult: KeyResult; currentDate: Date; + + dialogForm = new FormGroup({}); + constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, @@ -20,9 +24,17 @@ export class CheckInFormComponent implements OnInit { } ngOnInit(): void { - console.log(this.keyResult.createdOn); + console.log(this.keyResult.description); + } + + isTouchedOrDirty(name: string) { + return this.dialogForm.get(name)?.dirty || this.dialogForm.get(name)?.touched; + } + + getErrorKeysOfFormField(name: string) { + const errors = this.dialogForm.get(name)?.errors; + return errors == null ? [] : Object.keys(errors); } - protected readonly now = now; - protected readonly Date = Date; + protected readonly errorMessages: any = errorMessages; } From 6075fd7f0f8a284191f46e4d0336b63fda364b5c Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 26 Sep 2023 16:14:43 +0200 Subject: [PATCH 05/97] change size of textarea to match figma --- .../shared/dialog/check-in-form/check-in-form.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html index 9d56138316..b07afd0676 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html @@ -6,9 +6,9 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

{{ keyResult.lastCheckIn?.changeInfo }}
+ Veränderung seit letztem Check-in (optional) - Veränderung seit letztem Check-in (optional) - +
{{ errorMessages[errorKey.toUpperCase()] }} From 1d0745cbf633bb9d1b469ef43aef5f525d13e842 Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 26 Sep 2023 16:18:45 +0200 Subject: [PATCH 06/97] align content by adding all elements inside mat-dialog-content tag --- .../check-in-form/check-in-form.component.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html index b07afd0676..ec28d28ed2 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html @@ -1,11 +1,11 @@
-
-

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

-
-

Key Result

- {{ keyResult.lastCheckIn?.changeInfo }} - +
+

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+
+

Key Result

+ {{ keyResult.lastCheckIn?.changeInfo }} + Veränderung seit letztem Check-in (optional) From f16b475dccca8191d96ea157d65ea260c7772ebc Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 08:18:31 +0200 Subject: [PATCH 07/97] finish basic structure of metric and ordinal check-in --- .../check-in-form.component.html | 54 ++++++++++++------- .../check-in-form.component.scss | 15 ++++++ 2 files changed, 49 insertions(+), 20 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html index ec28d28ed2..1a1ce1115c 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html @@ -1,20 +1,34 @@ -
- -
-

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

-
-

Key Result

- {{ keyResult.lastCheckIn?.changeInfo }} - - Veränderung seit letztem Check-in (optional) - - -
- - {{ errorMessages[errorKey.toUpperCase()] }} - -
-
- -
-
+ +
+

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+
+

Key Result

+ {{ keyResult.lastCheckIn?.changeInfo }} +
+ Veränderungen seit letztem Check-in (optional) + + +
+ + {{ errorMessages[errorKey.toUpperCase()] }} + +
+
+ + Massnahmen (optional) + + +
+ + {{ errorMessages[errorKey.toUpperCase()] }} + +
+
+
+
+ + + + diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss index e69de29bb2..66f0cce297 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss +++ b/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss @@ -0,0 +1,15 @@ +@import "_variables"; + +.submit { + background-color: $pz-dark-blue; + border-radius: 8px; +} + +.cancel { + background-color: white; + color: $pz-dark-blue; +} + +mat-dialog-content { + padding-bottom: 0 !important; +} From 048de7079f86031bbcf1547bc3c128dd3c1764e8 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 08:24:09 +0200 Subject: [PATCH 08/97] rename component because we have to implement a different dialog for each type of check-in --- frontend/src/app/app.module.ts | 2 ++ .../app/keyresult-detail/keyresult-detail.component.ts | 3 ++- .../check-in-form-metric.component.html} | 0 .../check-in-form-metric.component.scss} | 0 .../check-in-form-metric.component.spec.ts} | 10 +++++----- .../check-in-form-metric.component.ts} | 10 +++++----- 6 files changed, 14 insertions(+), 11 deletions(-) rename frontend/src/app/shared/dialog/{check-in-form/check-in-form.component.html => check-in-form-metric/check-in-form-metric.component.html} (100%) rename frontend/src/app/shared/dialog/{check-in-form/check-in-form.component.scss => check-in-form-metric/check-in-form-metric.component.scss} (100%) rename frontend/src/app/shared/dialog/{check-in-form/check-in-form.component.spec.ts => check-in-form-metric/check-in-form-metric.component.spec.ts} (52%) rename frontend/src/app/shared/dialog/{check-in-form/check-in-form.component.ts => check-in-form-metric/check-in-form-metric.component.ts} (77%) diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 0a12765876..af3c2872ad 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -48,6 +48,7 @@ import { CheckInHistoryDialogComponent } from './shared/dialog/check-in-history- import { MatDividerModule } from '@angular/material/divider'; import { ApplicationBannerComponent } from './application-banner/application-banner.component'; import { CheckInFormComponent } from './shared/dialog/check-in-form/check-in-form.component'; +import { CheckInFormMetricComponent } from './shared/dialog/check-in-form-metric/check-in-form-metric.component'; import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog.component'; import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; @@ -97,6 +98,7 @@ export const MY_FORMATS = { KeyResultDialogComponent, ConfirmDialogComponent, CheckInFormComponent, + CheckInFormMetricComponent, ], imports: [ CommonModule, diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index c091b26d27..a3ba27c72a 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -8,6 +8,7 @@ import { MatDialog } from '@angular/material/dialog'; import { KeyResultDialogComponent } from '../key-result-dialog/key-result-dialog.component'; import { NotifierService } from '../shared/services/notifier.service'; import { CheckInFormComponent } from '../shared/dialog/check-in-form/check-in-form.component'; +import { CheckInFormMetricComponent } from '../shared/dialog/check-in-form-metric/check-in-form-metric.component'; @Component({ selector: 'app-keyresult-detail', @@ -82,7 +83,7 @@ export class KeyresultDetailComponent implements OnChanges { } openCheckInForm() { - const dialogRef = this.dialog.open(CheckInFormComponent, { + const dialogRef = this.dialog.open(CheckInFormMetricComponent, { data: { keyResult: this.keyResult, }, diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html similarity index 100% rename from frontend/src/app/shared/dialog/check-in-form/check-in-form.component.html rename to frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss similarity index 100% rename from frontend/src/app/shared/dialog/check-in-form/check-in-form.component.scss rename to frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.spec.ts similarity index 52% rename from frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts rename to frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.spec.ts index 24eed6bd94..1d757c5c02 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.spec.ts @@ -1,16 +1,16 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { CheckInFormComponent } from './check-in-form.component'; +import { CheckInFormMetricComponent } from './check-in-form-metric.component'; describe('CheckInFormComponent', () => { - let component: CheckInFormComponent; - let fixture: ComponentFixture; + let component: CheckInFormMetricComponent; + let fixture: ComponentFixture; beforeEach(() => { TestBed.configureTestingModule({ - declarations: [CheckInFormComponent], + declarations: [CheckInFormMetricComponent], }); - fixture = TestBed.createComponent(CheckInFormComponent); + fixture = TestBed.createComponent(CheckInFormMetricComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts similarity index 77% rename from frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts rename to frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index 7b3c4ca183..bd9e0e8eb4 100644 --- a/frontend/src/app/shared/dialog/check-in-form/check-in-form.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -5,18 +5,18 @@ import { FormGroup } from '@angular/forms'; import errorMessages from '../../../../assets/errors/error-messages.json'; @Component({ - selector: 'app-check-in-form', - templateUrl: './check-in-form.component.html', - styleUrls: ['./check-in-form.component.scss'], + selector: 'app-check-in-form-metric', + templateUrl: './check-in-form-metric.component.html', + styleUrls: ['./check-in-form-metric.component.scss'], }) -export class CheckInFormComponent implements OnInit { +export class CheckInFormMetricComponent implements OnInit { keyResult: KeyResult; currentDate: Date; dialogForm = new FormGroup({}); constructor( - public dialogRef: MatDialogRef, + public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, ) { this.keyResult = data.keyResult; From 080b7cd4def376195bb0475cbdb8dd6201292509 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 09:25:59 +0200 Subject: [PATCH 09/97] implement and align metric components of dialog --- .../check-in-form-metric.component.html | 25 ++++++++++++++++++- .../check-in-form-metric.component.ts | 5 ++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html index 1a1ce1115c..9a006340ca 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html @@ -4,7 +4,29 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

Key Result

{{ keyResult.lastCheckIn?.changeInfo }} -
+ + +
+
+ Aktueller Wert ({{ keyResult.unit }}) +
+ + +
+ + {{ errorMessages[errorKey.toUpperCase()] }} + +
+
+
+
+
+ Confidence um Target zu erreichen + +
+
+ + Veränderungen seit letztem Check-in (optional) @@ -15,6 +37,7 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+ Massnahmen (optional) diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index bd9e0e8eb4..eab7ffa304 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -3,6 +3,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { KeyResult } from '../../types/model/KeyResult'; import { FormGroup } from '@angular/forms'; import errorMessages from '../../../../assets/errors/error-messages.json'; +import { KeyResultMetric } from '../../types/model/KeyResultMetric'; @Component({ selector: 'app-check-in-form-metric', @@ -10,7 +11,7 @@ import errorMessages from '../../../../assets/errors/error-messages.json'; styleUrls: ['./check-in-form-metric.component.scss'], }) export class CheckInFormMetricComponent implements OnInit { - keyResult: KeyResult; + keyResult: KeyResultMetric; currentDate: Date; dialogForm = new FormGroup({}); @@ -24,7 +25,7 @@ export class CheckInFormMetricComponent implements OnInit { } ngOnInit(): void { - console.log(this.keyResult.description); + console.log(this.keyResult); } isTouchedOrDirty(name: string) { From 8fb88db50f80e47f980938346ec674f43996cef6 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 09:48:25 +0200 Subject: [PATCH 10/97] restyle confidence component and add margin to match figma mockup --- frontend/src/app/confidence/confidence.component.scss | 4 ++++ .../check-in-form-metric/check-in-form-metric.component.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/confidence/confidence.component.scss b/frontend/src/app/confidence/confidence.component.scss index 87fb8639f1..2f63c8fb3a 100644 --- a/frontend/src/app/confidence/confidence.component.scss +++ b/frontend/src/app/confidence/confidence.component.scss @@ -6,3 +6,7 @@ p { width: 63px; height: 23px; } + +mat-slider { + min-width: 360px; +} diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html index 9a006340ca..2bc1e22265 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html @@ -8,7 +8,7 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

- Aktueller Wert ({{ keyResult.unit }}) + Aktueller Wert ({{ keyResult.unit }})
From 3c019d318495eda9999e1bb962f586184c853e6b Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 10:37:55 +0200 Subject: [PATCH 11/97] increase width of slider and delete console log --- frontend/src/app/confidence/confidence.component.scss | 2 +- .../check-in-form-metric/check-in-form-metric.component.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/confidence/confidence.component.scss b/frontend/src/app/confidence/confidence.component.scss index 2f63c8fb3a..43b865b946 100644 --- a/frontend/src/app/confidence/confidence.component.scss +++ b/frontend/src/app/confidence/confidence.component.scss @@ -8,5 +8,5 @@ p { } mat-slider { - min-width: 360px; + min-width: 370px; } diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index eab7ffa304..7e1ff50ec2 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -24,9 +24,7 @@ export class CheckInFormMetricComponent implements OnInit { this.currentDate = new Date(); } - ngOnInit(): void { - console.log(this.keyResult); - } + ngOnInit(): void {} isTouchedOrDirty(name: string) { return this.dialogForm.get(name)?.dirty || this.dialogForm.get(name)?.touched; From a86ff5a0f50529f7769565ce8bd90aad575723a8 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 11:46:42 +0200 Subject: [PATCH 12/97] implement correct formating of default value with custom pipe --- frontend/src/app/app.module.ts | 2 ++ .../check-in-form-metric.component.html | 11 ++++++++-- .../pipes/unit-transformation.pipe.spec.ts | 8 +++++++ .../shared/pipes/unit-transformation.pipe.ts | 21 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 frontend/src/app/shared/pipes/unit-transformation.pipe.spec.ts create mode 100644 frontend/src/app/shared/pipes/unit-transformation.pipe.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index af3c2872ad..06b32eeef9 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -49,6 +49,7 @@ import { MatDividerModule } from '@angular/material/divider'; import { ApplicationBannerComponent } from './application-banner/application-banner.component'; import { CheckInFormComponent } from './shared/dialog/check-in-form/check-in-form.component'; import { CheckInFormMetricComponent } from './shared/dialog/check-in-form-metric/check-in-form-metric.component'; +import { UnitTransformationPipe } from './shared/pipes/unit-transformation.pipe'; import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog.component'; import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; @@ -99,6 +100,7 @@ export const MY_FORMATS = { ConfirmDialogComponent, CheckInFormComponent, CheckInFormMetricComponent, + UnitTransformationPipe, ], imports: [ CommonModule, diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html index 2bc1e22265..b47cab96d3 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html @@ -8,10 +8,17 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

- Aktueller Wert ({{ keyResult.unit }}) + Aktueller Wert ({{ keyResult.unit }}):
- + +
{{ errorMessages[errorKey.toUpperCase()] }} diff --git a/frontend/src/app/shared/pipes/unit-transformation.pipe.spec.ts b/frontend/src/app/shared/pipes/unit-transformation.pipe.spec.ts new file mode 100644 index 0000000000..1e32c5fa12 --- /dev/null +++ b/frontend/src/app/shared/pipes/unit-transformation.pipe.spec.ts @@ -0,0 +1,8 @@ +import { UnitTransformationPipe } from './unit-transformation.pipe'; + +describe('UnitTransformationPipe', () => { + it('create an instance', () => { + const pipe = new UnitTransformationPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-transformation.pipe.ts new file mode 100644 index 0000000000..ae96f9c149 --- /dev/null +++ b/frontend/src/app/shared/pipes/unit-transformation.pipe.ts @@ -0,0 +1,21 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import {formatCurrency} from "@angular/common"; + +@Pipe({ + name: 'unitTransformation' +}) +export class UnitTransformationPipe implements PipeTransform { + + transform(unit: string, value: number): string { + switch (unit) { + case 'CHF': + return value % 1 != 0 ? formatCurrency(value, 'en', '') : value + '.-'; + case 'PERCENT': + return value + '%'; + case 'FTE': + return value.toString(); + default: + return value.toString(); + } + } +} From 842f11c6c8a6df45acae8a6fec0826779344b7a4 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 11:53:25 +0200 Subject: [PATCH 13/97] format pipe file --- frontend/src/app/shared/pipes/unit-transformation.pipe.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-transformation.pipe.ts index ae96f9c149..a6469873f8 100644 --- a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts +++ b/frontend/src/app/shared/pipes/unit-transformation.pipe.ts @@ -1,11 +1,10 @@ import { Pipe, PipeTransform } from '@angular/core'; -import {formatCurrency} from "@angular/common"; +import { formatCurrency } from '@angular/common'; @Pipe({ - name: 'unitTransformation' + name: 'unitTransformation', }) export class UnitTransformationPipe implements PipeTransform { - transform(unit: string, value: number): string { switch (unit) { case 'CHF': From 5ba16700b64962724586152ea2b57244355879e9 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 13:06:57 +0200 Subject: [PATCH 14/97] implement formgroup with validators and add form control names in template --- .../check-in-form-metric.component.html | 54 ++++++++++++------- .../check-in-form-metric.component.ts | 24 +++++++-- 2 files changed, 55 insertions(+), 23 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html index b47cab96d3..021b354433 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html @@ -4,23 +4,25 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

Key Result

{{ keyResult.lastCheckIn?.changeInfo }} - +
Aktueller Wert ({{ keyResult.unit }}): + >Aktueller Wert ({{ keyResult.unit }}): +
- -
- + +
+ {{ errorMessages[errorKey.toUpperCase()] }}
@@ -36,9 +38,15 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

Veränderungen seit letztem Check-in (optional) - -
- + +
+ {{ errorMessages[errorKey.toUpperCase()] }}
@@ -47,18 +55,26 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

Massnahmen (optional) - -
- + +
+ {{ errorMessages[errorKey.toUpperCase()] }}
+ + + + + + - - - - diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index 7e1ff50ec2..44b4eb447f 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -1,7 +1,6 @@ import { Component, Inject, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { KeyResult } from '../../types/model/KeyResult'; -import { FormGroup } from '@angular/forms'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; import errorMessages from '../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../types/model/KeyResultMetric'; @@ -14,18 +13,35 @@ export class CheckInFormMetricComponent implements OnInit { keyResult: KeyResultMetric; currentDate: Date; - dialogForm = new FormGroup({}); + dialogForm = new FormGroup({ + value: new FormControl(0, [Validators.required]), + confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), + changeInfo: new FormControl('', [Validators.maxLength(4096)]), + initiatives: new FormControl('', [Validators.maxLength(4096)]), + }); constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, ) { - this.keyResult = data.keyResult; this.currentDate = new Date(); + this.keyResult = data.keyResult; + this.setFormValues(); } ngOnInit(): void {} + setFormValues() { + if (this.keyResult.lastCheckIn != null) { + this.dialogForm.controls.value.setValue(+this.keyResult.lastCheckIn.value); + this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn.confidence); + } + } + + saveCheckIn() { + console.log(this.dialogForm.value); + } + isTouchedOrDirty(name: string) { return this.dialogForm.get(name)?.dirty || this.dialogForm.get(name)?.touched; } From ff63a2f04d1a08887bdcb01358f76aa758117542 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 13:20:50 +0200 Subject: [PATCH 15/97] fix button position by wrapping buttons into custom flexed div --- .../check-in-form-metric.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html index 021b354433..f3f1280e46 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html @@ -70,11 +70,11 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

- - - +
From a6e174a73ca3af5b6abd9a84b830c1da17a67e26 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 13:24:52 +0200 Subject: [PATCH 16/97] set confidence value from confidence component after clicked on submit button --- .../check-in-form-metric/check-in-form-metric.component.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index 44b4eb447f..d4be967e04 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -39,6 +39,8 @@ export class CheckInFormMetricComponent implements OnInit { } saveCheckIn() { + this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); + console.log(this.keyResult.id); console.log(this.dialogForm.value); } From eeced451de28aa8217864bcf34a45f7136d061ba Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 15:13:41 +0200 Subject: [PATCH 17/97] implement method to update value with correct label whenever focues out of input --- frontend/src/app/app.module.ts | 1 + .../check-in-form-metric.component.html | 9 +------ .../check-in-form-metric.component.ts | 27 ++++++++++++------- .../shared/pipes/unit-transformation.pipe.ts | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 06b32eeef9..b6ccde55b7 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -151,6 +151,7 @@ export const MY_FORMATS = { { provide: HTTP_INTERCEPTORS, useClass: DrawerInterceptor, multi: true }, { provide: OAuthStorage, useFactory: storageFactory }, { provide: APP_INITIALIZER, useFactory: initOauthFactory, deps: [ConfigService, OAuthService], multi: true }, + UnitTransformationPipe, ], bootstrap: [AppComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html index f3f1280e46..383b9cc5aa 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html @@ -13,14 +13,7 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

- - +
{{ errorMessages[errorKey.toUpperCase()] }} diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index d4be967e04..490b9f7f45 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -3,6 +3,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import errorMessages from '../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../types/model/KeyResultMetric'; +import { UnitTransformationPipe } from '../../pipes/unit-transformation.pipe'; @Component({ selector: 'app-check-in-form-metric', @@ -14,33 +15,43 @@ export class CheckInFormMetricComponent implements OnInit { currentDate: Date; dialogForm = new FormGroup({ - value: new FormControl(0, [Validators.required]), + value: new FormControl('', [Validators.required]), confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), changeInfo: new FormControl('', [Validators.maxLength(4096)]), initiatives: new FormControl('', [Validators.maxLength(4096)]), }); + protected readonly errorMessages: any = errorMessages; constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, + private pipe: UnitTransformationPipe, ) { this.currentDate = new Date(); this.keyResult = data.keyResult; - this.setFormValues(); + this.setDefaultValues(); + this.formatValue(); } - ngOnInit(): void {} + ngOnInit(): void { + console.log(this.keyResult); + } - setFormValues() { - if (this.keyResult.lastCheckIn != null) { - this.dialogForm.controls.value.setValue(+this.keyResult.lastCheckIn.value); + setDefaultValues() { + if (this.keyResult.lastCheckIn?.value != null) { + this.dialogForm.controls.value.setValue(this.keyResult.lastCheckIn.value.toString()); this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn.confidence); } } + formatValue() { + this.dialogForm.controls.value.setValue( + this.pipe.transform(+this.dialogForm.controls.value.value!, this.keyResult.unit), + ); + } + saveCheckIn() { this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); - console.log(this.keyResult.id); console.log(this.dialogForm.value); } @@ -52,6 +63,4 @@ export class CheckInFormMetricComponent implements OnInit { const errors = this.dialogForm.get(name)?.errors; return errors == null ? [] : Object.keys(errors); } - - protected readonly errorMessages: any = errorMessages; } diff --git a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-transformation.pipe.ts index a6469873f8..8ddab1ce68 100644 --- a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts +++ b/frontend/src/app/shared/pipes/unit-transformation.pipe.ts @@ -5,7 +5,7 @@ import { formatCurrency } from '@angular/common'; name: 'unitTransformation', }) export class UnitTransformationPipe implements PipeTransform { - transform(unit: string, value: number): string { + transform(value: number, unit: String): string { switch (unit) { case 'CHF': return value % 1 != 0 ? formatCurrency(value, 'en', '') : value + '.-'; From 9df627af8a8aefeb3cab79bbc1b8c4c5c7d3ecb9 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 15:52:56 +0200 Subject: [PATCH 18/97] add parseValue function to be able to return value in save method --- .../check-in-form-metric.component.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index 490b9f7f45..31a3115077 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -45,14 +45,17 @@ export class CheckInFormMetricComponent implements OnInit { } formatValue() { - this.dialogForm.controls.value.setValue( - this.pipe.transform(+this.dialogForm.controls.value.value!, this.keyResult.unit), - ); + this.dialogForm.controls.value.setValue(this.pipe.transform(this.parseValue(), this.keyResult.unit)); + } + + parseValue(): number { + return +this.dialogForm.controls.value.value?.replaceAll('%', '').replaceAll('.-', '')!; } saveCheckIn() { this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); - console.log(this.dialogForm.value); + let checkIn = { ...this.dialogForm.value, value: this.parseValue() }; + console.log(checkIn); } isTouchedOrDirty(name: string) { From 16cfc49b0782c56c38308aaa1faa21a3e546751c Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 16:03:08 +0200 Subject: [PATCH 19/97] implement workflow of creating checkIn in frontend --- .../src/app/keyresult-detail/keyresult-detail.component.ts | 6 ++++++ .../check-in-form-metric/check-in-form-metric.component.ts | 6 ++---- frontend/src/app/shared/services/check-in.service.ts | 5 +++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index a3ba27c72a..9834ebeac8 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -9,6 +9,7 @@ import { KeyResultDialogComponent } from '../key-result-dialog/key-result-dialog import { NotifierService } from '../shared/services/notifier.service'; import { CheckInFormComponent } from '../shared/dialog/check-in-form/check-in-form.component'; import { CheckInFormMetricComponent } from '../shared/dialog/check-in-form-metric/check-in-form-metric.component'; +import { CheckInService } from '../shared/services/check-in.service'; @Component({ selector: 'app-keyresult-detail', @@ -22,6 +23,7 @@ export class KeyresultDetailComponent implements OnChanges { constructor( private keyResultService: KeyresultService, + private checkInService: CheckInService, private changeDetectorRef: ChangeDetectorRef, private dialog: MatDialog, private notifierService: NotifierService, @@ -89,5 +91,9 @@ export class KeyresultDetailComponent implements OnChanges { }, width: '719px', }); + dialogRef.afterClosed().subscribe((data) => { + console.log(data); + this.checkInService.createKeyResult(data).subscribe(); + }); } } diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index 31a3115077..63a4d2fe0b 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -33,9 +33,7 @@ export class CheckInFormMetricComponent implements OnInit { this.formatValue(); } - ngOnInit(): void { - console.log(this.keyResult); - } + ngOnInit(): void {} setDefaultValues() { if (this.keyResult.lastCheckIn?.value != null) { @@ -55,7 +53,7 @@ export class CheckInFormMetricComponent implements OnInit { saveCheckIn() { this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); let checkIn = { ...this.dialogForm.value, value: this.parseValue() }; - console.log(checkIn); + this.dialogRef.close({ data: checkIn }); } isTouchedOrDirty(name: string) { diff --git a/frontend/src/app/shared/services/check-in.service.ts b/frontend/src/app/shared/services/check-in.service.ts index 768f4ea8d4..7a634ffa68 100644 --- a/frontend/src/app/shared/services/check-in.service.ts +++ b/frontend/src/app/shared/services/check-in.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { CheckInMin } from '../types/model/CheckInMin'; import { Observable } from 'rxjs'; +import { CheckIn } from '../types/model/CheckIn'; @Injectable({ providedIn: 'root', @@ -12,4 +13,8 @@ export class CheckInService { getAllCheckInOfKeyResult(keyResultId: number): Observable { return this.httpclient.get(`/api/v2/keyresults/${keyResultId}/checkins`); } + + createKeyResult(checkIn: any): Observable { + return this.httpclient.post('/api/v2/checkIns', checkIn); + } } From a14d3d6883ff0bc272eccf1d1f39d5298cf2adf1 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 27 Sep 2023 16:09:20 +0200 Subject: [PATCH 20/97] fix error of missing keyResultId in checkIn --- .../src/app/keyresult-detail/keyresult-detail.component.ts | 5 ++--- .../check-in-form-metric/check-in-form-metric.component.ts | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 9834ebeac8..ddd3c97923 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -91,9 +91,8 @@ export class KeyresultDetailComponent implements OnChanges { }, width: '719px', }); - dialogRef.afterClosed().subscribe((data) => { - console.log(data); - this.checkInService.createKeyResult(data).subscribe(); + dialogRef.afterClosed().subscribe((result) => { + this.checkInService.createKeyResult(result.data).subscribe(); }); } } diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts index 63a4d2fe0b..c67d7cef2b 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts @@ -52,7 +52,7 @@ export class CheckInFormMetricComponent implements OnInit { saveCheckIn() { this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); - let checkIn = { ...this.dialogForm.value, value: this.parseValue() }; + let checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; this.dialogRef.close({ data: checkIn }); } From b7da170610fc6bcb9d579dabfb7943e35253d25b Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 08:48:46 +0200 Subject: [PATCH 21/97] update keyResultDetail after creating new checkIn and rename method of service to match its use --- .../src/app/keyresult-detail/keyresult-detail.component.ts | 5 ++++- frontend/src/app/shared/services/check-in.service.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index ddd3c97923..8ef8d8bc9a 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -92,7 +92,10 @@ export class KeyresultDetailComponent implements OnChanges { width: '719px', }); dialogRef.afterClosed().subscribe((result) => { - this.checkInService.createKeyResult(result.data).subscribe(); + this.checkInService.createCheckIn(result.data).subscribe((createdCheckIn) => { + this.keyResult.lastCheckIn = createdCheckIn; + this.changeDetectorRef.detectChanges(); + }); }); } } diff --git a/frontend/src/app/shared/services/check-in.service.ts b/frontend/src/app/shared/services/check-in.service.ts index 7a634ffa68..85f00c58de 100644 --- a/frontend/src/app/shared/services/check-in.service.ts +++ b/frontend/src/app/shared/services/check-in.service.ts @@ -14,7 +14,7 @@ export class CheckInService { return this.httpclient.get(`/api/v2/keyresults/${keyResultId}/checkins`); } - createKeyResult(checkIn: any): Observable { + createCheckIn(checkIn: any): Observable { return this.httpclient.post('/api/v2/checkIns', checkIn); } } From 1a27a0e1f6517a1d23c0de8a38f19f8c32d26cc0 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 09:06:49 +0200 Subject: [PATCH 22/97] add option to differ between ordinal and metric checkIn dialog --- .../src/app/keyresult-detail/keyresult-detail.component.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 8ef8d8bc9a..c97cb22eab 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -39,9 +39,11 @@ export class KeyresultDetailComponent implements OnChanges { castToMetric(keyResult: KeyResult) { return keyResult as KeyResultMetric; } + castToOrdinal(keyResult: KeyResult) { return keyResult as KeyResultOrdinal; } + checkInHistory() { const dialogRef = this.dialog.open(CheckInHistoryDialogComponent, { data: { @@ -85,7 +87,8 @@ export class KeyresultDetailComponent implements OnChanges { } openCheckInForm() { - const dialogRef = this.dialog.open(CheckInFormMetricComponent, { + let component = this.keyResult.keyResultType === 'metric' ? CheckInFormMetricComponent : CheckInFormMetricComponent; + const dialogRef = this.dialog.open(component, { data: { keyResult: this.keyResult, }, From 2f6bfe157116bd25822fbc09730c617b98b0eb5e Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 09:31:42 +0200 Subject: [PATCH 23/97] add check to do create request only if created form data is not undefined --- .../app/keyresult-detail/keyresult-detail.component.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index c97cb22eab..5570eb66cc 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -95,10 +95,12 @@ export class KeyresultDetailComponent implements OnChanges { width: '719px', }); dialogRef.afterClosed().subscribe((result) => { - this.checkInService.createCheckIn(result.data).subscribe((createdCheckIn) => { - this.keyResult.lastCheckIn = createdCheckIn; - this.changeDetectorRef.detectChanges(); - }); + if (result != undefined) { + this.checkInService.createCheckIn(result.data).subscribe((createdCheckIn) => { + this.keyResult.lastCheckIn = createdCheckIn; + this.changeDetectorRef.detectChanges(); + }); + } }); } } From 47ae5d0dc0c7be29bbbc8d889389dec5b34407b0 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 09:42:36 +0200 Subject: [PATCH 24/97] format error message of input field --- .../check-in-form-metric/check-in-form-metric.component.html | 4 ++-- .../check-in-form-metric/check-in-form-metric.component.scss | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html index 383b9cc5aa..cb7589c9ed 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html @@ -11,11 +11,11 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

Aktueller Wert ({{ keyResult.unit }}): -
+
- + {{ errorMessages[errorKey.toUpperCase()] }}
diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss index 66f0cce297..3f5bc788b6 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss +++ b/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss @@ -10,6 +10,6 @@ color: $pz-dark-blue; } -mat-dialog-content { - padding-bottom: 0 !important; +.error-font { + font-size: 13px; } From 27f9e95f00c2d9d0ca2daca160e3675edbe4347a Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 10:18:44 +0200 Subject: [PATCH 25/97] create check-in-form-ordinal component and let detail of keyresult open it if keyresult is ordinal --- frontend/src/app/app.module.ts | 2 ++ .../keyresult-detail.component.ts | 4 +++- .../check-in-form-ordinal.component.html | 1 + .../check-in-form-ordinal.component.scss | 0 .../check-in-form-ordinal.component.spec.ts | 21 +++++++++++++++++++ .../check-in-form-ordinal.component.ts | 10 +++++++++ 6 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.html create mode 100644 frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.scss create mode 100644 frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts create mode 100644 frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index b6ccde55b7..24e6cd2e06 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -50,6 +50,7 @@ import { ApplicationBannerComponent } from './application-banner/application-ban import { CheckInFormComponent } from './shared/dialog/check-in-form/check-in-form.component'; import { CheckInFormMetricComponent } from './shared/dialog/check-in-form-metric/check-in-form-metric.component'; import { UnitTransformationPipe } from './shared/pipes/unit-transformation.pipe'; +import { CheckInFormOrdinalComponent } from './shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component'; import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog.component'; import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; @@ -101,6 +102,7 @@ export const MY_FORMATS = { CheckInFormComponent, CheckInFormMetricComponent, UnitTransformationPipe, + CheckInFormOrdinalComponent, ], imports: [ CommonModule, diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 5570eb66cc..12aeb5ccb0 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -10,6 +10,7 @@ import { NotifierService } from '../shared/services/notifier.service'; import { CheckInFormComponent } from '../shared/dialog/check-in-form/check-in-form.component'; import { CheckInFormMetricComponent } from '../shared/dialog/check-in-form-metric/check-in-form-metric.component'; import { CheckInService } from '../shared/services/check-in.service'; +import { CheckInFormOrdinalComponent } from '../shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component'; @Component({ selector: 'app-keyresult-detail', @@ -87,7 +88,8 @@ export class KeyresultDetailComponent implements OnChanges { } openCheckInForm() { - let component = this.keyResult.keyResultType === 'metric' ? CheckInFormMetricComponent : CheckInFormMetricComponent; + let component = + this.keyResult.keyResultType === 'metric' ? CheckInFormMetricComponent : CheckInFormOrdinalComponent; const dialogRef = this.dialog.open(component, { data: { keyResult: this.keyResult, diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.html b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.html new file mode 100644 index 0000000000..36a062ac78 --- /dev/null +++ b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.html @@ -0,0 +1 @@ +

check-in-form-ordinal works!

diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.scss b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts new file mode 100644 index 0000000000..65db8ffc34 --- /dev/null +++ b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CheckInFormOrdinalComponent } from './check-in-form-ordinal.component'; + +describe('CheckInFormOrdinalComponent', () => { + let component: CheckInFormOrdinalComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [CheckInFormOrdinalComponent] + }); + fixture = TestBed.createComponent(CheckInFormOrdinalComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts new file mode 100644 index 0000000000..b0f903ab7b --- /dev/null +++ b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-check-in-form-ordinal', + templateUrl: './check-in-form-ordinal.component.html', + styleUrls: ['./check-in-form-ordinal.component.scss'] +}) +export class CheckInFormOrdinalComponent { + +} From a473855156f1cf900b25dafc35c64e64b5a9270b Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 10:19:47 +0200 Subject: [PATCH 26/97] format generated files --- .../check-in-form-ordinal.component.spec.ts | 2 +- .../check-in-form-ordinal.component.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts index 65db8ffc34..b28ee93ba6 100644 --- a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts +++ b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts @@ -8,7 +8,7 @@ describe('CheckInFormOrdinalComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [CheckInFormOrdinalComponent] + declarations: [CheckInFormOrdinalComponent], }); fixture = TestBed.createComponent(CheckInFormOrdinalComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts index b0f903ab7b..0475186968 100644 --- a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts +++ b/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts @@ -3,8 +3,6 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-check-in-form-ordinal', templateUrl: './check-in-form-ordinal.component.html', - styleUrls: ['./check-in-form-ordinal.component.scss'] + styleUrls: ['./check-in-form-ordinal.component.scss'], }) -export class CheckInFormOrdinalComponent { - -} +export class CheckInFormOrdinalComponent {} From f5429a3bfe01ed9af5ddeb5542ed335e1b367635 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 10:32:00 +0200 Subject: [PATCH 27/97] include option of not posting check-in if cancel button was clicked --- frontend/src/app/keyresult-detail/keyresult-detail.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 12aeb5ccb0..5aac9dd8c0 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -97,7 +97,7 @@ export class KeyresultDetailComponent implements OnChanges { width: '719px', }); dialogRef.afterClosed().subscribe((result) => { - if (result != undefined) { + if (result != undefined && result != '') { this.checkInService.createCheckIn(result.data).subscribe((createdCheckIn) => { this.keyResult.lastCheckIn = createdCheckIn; this.changeDetectorRef.detectChanges(); From a4b39f09652b0ff4ddc02adcfc198cbc81436c69 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 10:56:18 +0200 Subject: [PATCH 28/97] move check-in dialogs into seperate folder and create component for check-in base informations --- frontend/src/app/app.module.ts | 4 +++- .../keyresult-detail.component.ts | 6 +++--- .../check-in-base-informations.component.html | 1 + ...check-in-base-informations.component.scss} | 0 ...eck-in-base-informations.component.spec.ts | 21 +++++++++++++++++++ .../check-in-base-informations.component.ts | 10 +++++++++ .../check-in-form-metric.component.html | 0 .../check-in-form-metric.component.scss | 2 +- .../check-in-form-metric.component.spec.ts | 0 .../check-in-form-metric.component.ts | 6 +++--- .../check-in-form-ordinal.component.html | 0 .../check-in-form-ordinal.component.scss | 0 .../check-in-form-ordinal.component.spec.ts | 0 .../check-in-form-ordinal.component.ts | 0 14 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html rename frontend/src/app/shared/dialog/{check-in-form-ordinal/check-in-form-ordinal.component.scss => checkin/check-in-base-informations/check-in-base-informations.component.scss} (100%) create mode 100644 frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.spec.ts create mode 100644 frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts rename frontend/src/app/shared/dialog/{ => checkin}/check-in-form-metric/check-in-form-metric.component.html (100%) rename frontend/src/app/shared/dialog/{ => checkin}/check-in-form-metric/check-in-form-metric.component.scss (85%) rename frontend/src/app/shared/dialog/{ => checkin}/check-in-form-metric/check-in-form-metric.component.spec.ts (100%) rename frontend/src/app/shared/dialog/{ => checkin}/check-in-form-metric/check-in-form-metric.component.ts (90%) rename frontend/src/app/shared/dialog/{ => checkin}/check-in-form-ordinal/check-in-form-ordinal.component.html (100%) create mode 100644 frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss rename frontend/src/app/shared/dialog/{ => checkin}/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts (100%) rename frontend/src/app/shared/dialog/{ => checkin}/check-in-form-ordinal/check-in-form-ordinal.component.ts (100%) diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 24e6cd2e06..a0fa784eaa 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -48,8 +48,9 @@ import { CheckInHistoryDialogComponent } from './shared/dialog/check-in-history- import { MatDividerModule } from '@angular/material/divider'; import { ApplicationBannerComponent } from './application-banner/application-banner.component'; import { CheckInFormComponent } from './shared/dialog/check-in-form/check-in-form.component'; -import { CheckInFormMetricComponent } from './shared/dialog/check-in-form-metric/check-in-form-metric.component'; +import { CheckInFormMetricComponent } from './shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component'; import { UnitTransformationPipe } from './shared/pipes/unit-transformation.pipe'; +import { CheckInBaseInformationsComponent } from './shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component'; import { CheckInFormOrdinalComponent } from './shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component'; import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog.component'; import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; @@ -103,6 +104,7 @@ export const MY_FORMATS = { CheckInFormMetricComponent, UnitTransformationPipe, CheckInFormOrdinalComponent, + CheckInBaseInformationsComponent, ], imports: [ CommonModule, diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 5aac9dd8c0..e7d600218f 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -5,12 +5,12 @@ import { KeyResultMetric } from '../shared/types/model/KeyResultMetric'; import { KeyResultOrdinal } from '../shared/types/model/KeyResultOrdinal'; import { CheckInHistoryDialogComponent } from '../shared/dialog/check-in-history-dialog/check-in-history-dialog.component'; import { MatDialog } from '@angular/material/dialog'; +import { CheckInFormMetricComponent } from '../shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component'; import { KeyResultDialogComponent } from '../key-result-dialog/key-result-dialog.component'; import { NotifierService } from '../shared/services/notifier.service'; -import { CheckInFormComponent } from '../shared/dialog/check-in-form/check-in-form.component'; -import { CheckInFormMetricComponent } from '../shared/dialog/check-in-form-metric/check-in-form-metric.component'; +import { CheckInFormComponent } from '../shared/dialog/checkin/check-in-form/check-in-form.component'; import { CheckInService } from '../shared/services/check-in.service'; -import { CheckInFormOrdinalComponent } from '../shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component'; +import { CheckInFormOrdinalComponent } from '../shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component'; @Component({ selector: 'app-keyresult-detail', 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 new file mode 100644 index 0000000000..fcb08da064 --- /dev/null +++ b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.html @@ -0,0 +1 @@ +

check-in-base-informations works!

diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.scss similarity index 100% rename from frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.scss rename to frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.scss 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 new file mode 100644 index 0000000000..2e83f12fb9 --- /dev/null +++ b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CheckInBaseInformationsComponent } from './check-in-base-informations.component'; + +describe('CheckInBaseInformationsComponent', () => { + let component: CheckInBaseInformationsComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [CheckInBaseInformationsComponent] + }); + fixture = TestBed.createComponent(CheckInBaseInformationsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 0000000000..453010d937 --- /dev/null +++ b/frontend/src/app/shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-check-in-base-informations', + templateUrl: './check-in-base-informations.component.html', + styleUrls: ['./check-in-base-informations.component.scss'] +}) +export class CheckInBaseInformationsComponent { + +} diff --git a/frontend/src/app/shared/dialog/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 similarity index 100% rename from frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.html rename to frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.html diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.scss similarity index 85% rename from frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss rename to frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.scss index 3f5bc788b6..c78f110004 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.scss +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.scss @@ -1,4 +1,4 @@ -@import "_variables"; +@import "../style/variables"; .submit { background-color: $pz-dark-blue; diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts similarity index 100% rename from frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.spec.ts rename to frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts diff --git a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts similarity index 90% rename from frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts rename to frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index c67d7cef2b..9115b48834 100644 --- a/frontend/src/app/shared/dialog/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -1,9 +1,9 @@ import { Component, Inject, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { FormControl, FormGroup, Validators } from '@angular/forms'; -import errorMessages from '../../../../assets/errors/error-messages.json'; -import { KeyResultMetric } from '../../types/model/KeyResultMetric'; -import { UnitTransformationPipe } from '../../pipes/unit-transformation.pipe'; +import errorMessages from '../../../../../assets/errors/error-messages.json'; +import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; +import { UnitTransformationPipe } from '../../../pipes/unit-transformation.pipe'; @Component({ selector: 'app-check-in-form-metric', diff --git a/frontend/src/app/shared/dialog/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 similarity index 100% rename from frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.html rename to frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.html diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts similarity index 100% rename from frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts rename to frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts diff --git a/frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts similarity index 100% rename from frontend/src/app/shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component.ts rename to frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts From aa84bd3718794c18c7defd25df33db0920e4e560 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 10:56:41 +0200 Subject: [PATCH 29/97] format base-informations component --- .../check-in-base-informations.component.spec.ts | 2 +- .../check-in-base-informations.component.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) 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 index 2e83f12fb9..184a0876b8 100644 --- 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 @@ -8,7 +8,7 @@ describe('CheckInBaseInformationsComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [CheckInBaseInformationsComponent] + declarations: [CheckInBaseInformationsComponent], }); fixture = TestBed.createComponent(CheckInBaseInformationsComponent); component = fixture.componentInstance; 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 453010d937..1aa0ea46d6 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 @@ -3,8 +3,6 @@ import { Component } from '@angular/core'; @Component({ selector: 'app-check-in-base-informations', templateUrl: './check-in-base-informations.component.html', - styleUrls: ['./check-in-base-informations.component.scss'] + styleUrls: ['./check-in-base-informations.component.scss'], }) -export class CheckInBaseInformationsComponent { - -} +export class CheckInBaseInformationsComponent {} From a5183e29fb99de653785859e55bb2f2a9931f02a Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 11:13:59 +0200 Subject: [PATCH 30/97] implement structure of base form component --- .../check-in-base-informations.component.html | 36 ++++++++++++++++++- .../check-in-base-informations.component.ts | 20 +++++++++-- .../check-in-form-metric.component.html | 36 +------------------ 3 files changed, 54 insertions(+), 38 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 fcb08da064..4d721e34f8 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 +1,35 @@ -

check-in-base-informations works!

+
+ + Veränderungen seit letztem Check-in (optional) + + +
+ + + +
+
+ + + Massnahmen (optional) + + +
+ + + +
+
+
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 1aa0ea46d6..0bf522d8ba 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 @@ -1,8 +1,24 @@ -import { Component } from '@angular/core'; +import { Component, Input } from '@angular/core'; +import { FormGroup } from '@angular/forms'; +import errorMessages from '../../../../../assets/errors/error-messages.json'; @Component({ selector: 'app-check-in-base-informations', templateUrl: './check-in-base-informations.component.html', styleUrls: ['./check-in-base-informations.component.scss'], }) -export class CheckInBaseInformationsComponent {} +export class CheckInBaseInformationsComponent { + @Input() + dialogForm!: FormGroup; + + isTouchedOrDirty(name: string) { + return this.dialogForm.get(name)?.dirty || this.dialogForm.get(name)?.touched; + } + + getErrorKeysOfFormField(name: string) { + const errors = this.dialogForm.get(name)?.errors; + return errors == null ? [] : Object.keys(errors); + } + + protected readonly errorMessages = errorMessages; +} 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 cb7589c9ed..18d8da483c 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 @@ -27,41 +27,7 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

- - - Veränderungen seit letztem Check-in (optional) - - -
- - {{ errorMessages[errorKey.toUpperCase()] }} - -
-
- - - Massnahmen (optional) - - -
- - {{ errorMessages[errorKey.toUpperCase()] }} - -
-
- +
- -
- +
+ +
+ + + +
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index 9115b48834..4ad7721a43 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -13,6 +13,7 @@ import { UnitTransformationPipe } from '../../../pipes/unit-transformation.pipe' export class CheckInFormMetricComponent implements OnInit { keyResult: KeyResultMetric; currentDate: Date; + continued: boolean = false; dialogForm = new FormGroup({ value: new FormControl('', [Validators.required]), From ca51d2bfa7ca4ac4d4e69db5bc37bbcd5565491e Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 13:08:18 +0200 Subject: [PATCH 33/97] center continue text inside button --- .../check-in-form-metric/check-in-form-metric.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 70e7763e62..31be4c2a4d 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 @@ -37,7 +37,7 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

- - - -
+ +
+ + + +
From 652963562099165436ae7bfbf4b91ba3925e4b47 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 14:55:32 +0200 Subject: [PATCH 40/97] implement basic html structure of check-in ordinal form component --- .../keyresult-detail.component.ts | 2 +- .../check-in-form-ordinal.component.html | 35 ++++++++++++++++++- .../check-in-form-ordinal.component.scss | 11 ++++++ .../check-in-form-ordinal.component.ts | 31 ++++++++++++++-- 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index e7d600218f..21eb8a1d57 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -88,7 +88,7 @@ export class KeyresultDetailComponent implements OnChanges { } openCheckInForm() { - let component = + let component: any = this.keyResult.keyResultType === 'metric' ? CheckInFormMetricComponent : CheckInFormOrdinalComponent; const dialogRef = this.dialog.open(component, { data: { 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 36a062ac78..69352a0f46 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 @@ -1 +1,34 @@ -

check-in-form-ordinal works!

+ +
+

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+
+
+

Key Result

+
+ {{ keyResult.lastCheckIn?.changeInfo }} +
+ + + +
+
+ +
+
+ +
+ + + +
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss index e69de29bb2..21560e802a 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss @@ -0,0 +1,11 @@ +@import "../style/variables"; + +.submit { + background-color: $pz-dark-blue; + border-radius: 8px; +} + +.cancel { + background-color: white; + color: $pz-dark-blue; +} diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts index 0475186968..a1817db920 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts @@ -1,8 +1,35 @@ -import { Component } from '@angular/core'; +import { Component, Inject } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; @Component({ selector: 'app-check-in-form-ordinal', templateUrl: './check-in-form-ordinal.component.html', styleUrls: ['./check-in-form-ordinal.component.scss'], }) -export class CheckInFormOrdinalComponent {} +export class CheckInFormOrdinalComponent { + keyResult: KeyResultOrdinal; + currentDate: Date; + continued: boolean = false; + dialogForm = new FormGroup({ + value: new FormControl('', [Validators.required]), + confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), + changeInfo: new FormControl('', [Validators.maxLength(4096)]), + initiatives: new FormControl('', [Validators.maxLength(4096)]), + }); + + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any, + ) { + this.keyResult = data.keyResult; + this.currentDate = new Date(); + } + + saveCheckIn() { + this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); + let checkIn = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; + this.dialogRef.close({ data: checkIn }); + } +} From 2294e9b2d471bdeeb321e897949e0e6fa5df6b09 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 15:29:06 +0200 Subject: [PATCH 41/97] implement parent component which inserts ordinal or metric input --- frontend/src/app/app.module.ts | 3 +- .../keyresult-detail.component.ts | 7 +- .../check-in-form-metric.component.html | 75 ++++++------------- .../check-in-form-metric.component.scss | 12 --- .../check-in-form-metric.component.ts | 55 ++++---------- .../check-in-form.component.html | 38 ++++++++++ .../check-in-form.component.scss | 11 +++ .../check-in-form.component.spec.ts | 21 ++++++ .../check-in-form/check-in-form.component.ts | 60 +++++++++++++++ 9 files changed, 169 insertions(+), 113 deletions(-) create mode 100644 frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html create mode 100644 frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.scss create mode 100644 frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts create mode 100644 frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index eadf174b58..d803b08b10 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -47,7 +47,6 @@ import { DrawerInterceptor } from './shared/interceptors/drawer.interceptor'; import { CheckInHistoryDialogComponent } from './shared/dialog/check-in-history-dialog/check-in-history-dialog.component'; import { MatDividerModule } from '@angular/material/divider'; import { ApplicationBannerComponent } from './application-banner/application-banner.component'; -import { CheckInFormComponent } from './shared/dialog/check-in-form/check-in-form.component'; import { CheckInFormMetricComponent } from './shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component'; import { UnitTransformationPipe } from './shared/pipes/unit-transformation.pipe'; import { CheckInBaseInformationsComponent } from './shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component'; @@ -55,6 +54,7 @@ import { CustomInputComponent } from './shared/custom/custom-input/custom-input. import { CheckInFormOrdinalComponent } from './shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component'; import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog.component'; import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; +import { CheckInFormComponent } from './shared/dialog/checkin/check-in-form/check-in-form.component'; function initOauthFactory(configService: ConfigService, oauthService: OAuthService) { return async () => { @@ -107,6 +107,7 @@ export const MY_FORMATS = { CheckInFormOrdinalComponent, CheckInBaseInformationsComponent, CustomInputComponent, + CheckInFormComponent, ], imports: [ CommonModule, diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 21eb8a1d57..21a5bf1ebc 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -8,9 +8,8 @@ import { MatDialog } from '@angular/material/dialog'; import { CheckInFormMetricComponent } from '../shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component'; import { KeyResultDialogComponent } from '../key-result-dialog/key-result-dialog.component'; import { NotifierService } from '../shared/services/notifier.service'; -import { CheckInFormComponent } from '../shared/dialog/checkin/check-in-form/check-in-form.component'; import { CheckInService } from '../shared/services/check-in.service'; -import { CheckInFormOrdinalComponent } from '../shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component'; +import { CheckInFormComponent } from '../shared/dialog/checkin/check-in-form/check-in-form.component'; @Component({ selector: 'app-keyresult-detail', @@ -88,9 +87,7 @@ export class KeyresultDetailComponent implements OnChanges { } openCheckInForm() { - let component: any = - this.keyResult.keyResultType === 'metric' ? CheckInFormMetricComponent : CheckInFormOrdinalComponent; - const dialogRef = this.dialog.open(component, { + const dialogRef = this.dialog.open(CheckInFormComponent, { data: { keyResult: this.keyResult, }, 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 4e149ef05e..2f20aa1019 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 @@ -1,58 +1,25 @@ - -
-

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

-
-
-

Key Result

-
- {{ keyResult.lastCheckIn?.changeInfo }} -
-
- -
-
- Aktueller Wert ({{ keyResult.unit }}): - -
- -
- - {{ errorMessages[errorKey.toUpperCase()] }} - -
-
-
-
- Confidence um Target zu erreichen - -
+ +
+
+ Aktueller Wert ({{ keyResult.unit }}): + +
+ +
+ + {{ errorMessages[errorKey.toUpperCase()] }} +
- +
-
- +
+ Confidence um Target zu erreichen +
- - -
- - -
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.scss index 0dec7326d1..7378efdd5a 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.scss +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.scss @@ -1,15 +1,3 @@ -@import "../style/variables"; - -.submit { - background-color: $pz-dark-blue; - border-radius: 8px; -} - -.cancel { - background-color: white; - color: $pz-dark-blue; -} - .error-font { font-size: 13px; } diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index 4ad7721a43..d5eb8702e2 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -1,6 +1,5 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { AfterViewInit, Component, Input } from '@angular/core'; +import { FormGroup } from '@angular/forms'; import errorMessages from '../../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; import { UnitTransformationPipe } from '../../../pipes/unit-transformation.pipe'; @@ -10,51 +9,21 @@ import { UnitTransformationPipe } from '../../../pipes/unit-transformation.pipe' templateUrl: './check-in-form-metric.component.html', styleUrls: ['./check-in-form-metric.component.scss'], }) -export class CheckInFormMetricComponent implements OnInit { - keyResult: KeyResultMetric; - currentDate: Date; - continued: boolean = false; - - dialogForm = new FormGroup({ - value: new FormControl('', [Validators.required]), - confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), - changeInfo: new FormControl('', [Validators.maxLength(4096)]), - initiatives: new FormControl('', [Validators.maxLength(4096)]), - }); +export class CheckInFormMetricComponent implements AfterViewInit { + @Input() + keyResult!: KeyResultMetric; + @Input() + dialogForm!: FormGroup; protected readonly errorMessages: any = errorMessages; - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - private pipe: UnitTransformationPipe, - ) { - this.currentDate = new Date(); - this.keyResult = data.keyResult; - this.setDefaultValues(); - this.formatValue(); - } - - ngOnInit(): void {} - - setDefaultValues() { - if (this.keyResult.lastCheckIn?.value != null) { - this.dialogForm.controls.value.setValue(this.keyResult.lastCheckIn.value.toString()); - this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn.confidence); - } - } + constructor(private pipe: UnitTransformationPipe) {} formatValue() { - this.dialogForm.controls.value.setValue(this.pipe.transform(this.parseValue(), this.keyResult.unit)); + this.dialogForm?.controls['value'].setValue(this.pipe.transform(this.parseValue(), this.keyResult.unit)); } parseValue(): number { - return +this.dialogForm.controls.value.value?.replaceAll('%', '').replaceAll('.-', '')!; - } - - saveCheckIn() { - this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); - let checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; - this.dialogRef.close({ data: checkIn }); + return +this.dialogForm?.controls['value'].value?.replaceAll('%', '').replaceAll('.-', '')!; } isTouchedOrDirty(name: string) { @@ -65,4 +34,8 @@ export class CheckInFormMetricComponent implements OnInit { const errors = this.dialogForm.get(name)?.errors; return errors == null ? [] : Object.keys(errors); } + + ngAfterViewInit(): void { + this.formatValue(); + } } 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 new file mode 100644 index 0000000000..0125030918 --- /dev/null +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.html @@ -0,0 +1,38 @@ + +
+

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+
+ +
+

Key Result

+
+ {{ keyResult.lastCheckIn?.changeInfo }} +
+
+ + +
+
+ +
+ +
+
+ +
+ + + +
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.scss new file mode 100644 index 0000000000..21560e802a --- /dev/null +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.scss @@ -0,0 +1,11 @@ +@import "../style/variables"; + +.submit { + background-color: $pz-dark-blue; + border-radius: 8px; +} + +.cancel { + background-color: white; + color: $pz-dark-blue; +} diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts new file mode 100644 index 0000000000..c26bd0cb2e --- /dev/null +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CheckInFormComponent } from './check-in-form.component'; + +describe('CheckInFormComponent', () => { + let component: CheckInFormComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [CheckInFormComponent] + }); + fixture = TestBed.createComponent(CheckInFormComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 0000000000..954b28a4ae --- /dev/null +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.ts @@ -0,0 +1,60 @@ +import {Component, Inject} from '@angular/core'; +import {KeyResultMetric} from "../../../types/model/KeyResultMetric"; +import {FormControl, FormGroup, Validators} from "@angular/forms"; +import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import {KeyResult} from "../../../types/model/KeyResult"; +import {KeyResultOrdinal} from "../../../types/model/KeyResultOrdinal"; + +@Component({ + selector: 'app-check-in-form', + templateUrl: './check-in-form.component.html', + styleUrls: ['./check-in-form.component.scss'] +}) +export class CheckInFormComponent { + keyResult: KeyResult; + currentDate: Date; + continued: boolean = false; + + dialogForm = new FormGroup({ + value: new FormControl('', [Validators.required]), + confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), + changeInfo: new FormControl('', [Validators.maxLength(4096)]), + initiatives: new FormControl('', [Validators.maxLength(4096)]), + }); + + constructor( + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any) { + this.currentDate = new Date(); + this.keyResult = data.keyResult; + this.setDefaultValues(); + } + + setDefaultValues() { + if (this.keyResult.lastCheckIn?.value != null) { + this.dialogForm.controls.value.setValue(this.keyResult.lastCheckIn.value.toString()); + this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn.confidence); + } + } + + saveCheckIn() { + let checkIn: any = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; + if(this.keyResult.keyResultType === 'metric') { + checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; + } + this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); + this.dialogRef.close({ data: checkIn }); + } + + parseValue(): number { + return +this.dialogForm?.controls['value'].value?.replaceAll('%', '').replaceAll('.-', '')!; + } + + getKeyResultMetric(): KeyResultMetric { + return this.keyResult as KeyResultMetric; + } + + getKeyResultOrdinal(): KeyResultOrdinal { + return this.keyResult as KeyResultOrdinal; + } +} From b5a5035456786e64a288040fe8be82b66195e95f Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 15:29:26 +0200 Subject: [PATCH 42/97] format new generated files --- .../check-in-form.component.html | 7 +++++-- .../check-in-form.component.spec.ts | 2 +- .../check-in-form/check-in-form.component.ts | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 12 deletions(-) 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 0125030918..970d647f95 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 @@ -10,8 +10,11 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

- +
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts index c26bd0cb2e..24eed6bd94 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts @@ -8,7 +8,7 @@ describe('CheckInFormComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [CheckInFormComponent] + declarations: [CheckInFormComponent], }); fixture = TestBed.createComponent(CheckInFormComponent); component = fixture.componentInstance; 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 954b28a4ae..77220da4f2 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 @@ -1,14 +1,14 @@ -import {Component, Inject} from '@angular/core'; -import {KeyResultMetric} from "../../../types/model/KeyResultMetric"; -import {FormControl, FormGroup, Validators} from "@angular/forms"; -import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; -import {KeyResult} from "../../../types/model/KeyResult"; -import {KeyResultOrdinal} from "../../../types/model/KeyResultOrdinal"; +import { Component, Inject } from '@angular/core'; +import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { KeyResult } from '../../../types/model/KeyResult'; +import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; @Component({ selector: 'app-check-in-form', templateUrl: './check-in-form.component.html', - styleUrls: ['./check-in-form.component.scss'] + styleUrls: ['./check-in-form.component.scss'], }) export class CheckInFormComponent { keyResult: KeyResult; @@ -24,7 +24,8 @@ export class CheckInFormComponent { constructor( public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any) { + @Inject(MAT_DIALOG_DATA) public data: any, + ) { this.currentDate = new Date(); this.keyResult = data.keyResult; this.setDefaultValues(); @@ -39,7 +40,7 @@ export class CheckInFormComponent { saveCheckIn() { let checkIn: any = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; - if(this.keyResult.keyResultType === 'metric') { + if (this.keyResult.keyResultType === 'metric') { checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; } this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); From 46d4f9ef5b3a9b5e3a90a449ca20c542a2b2a4ce Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 15:34:18 +0200 Subject: [PATCH 43/97] build up typescript of check-in-ordinal component --- .../check-in-form-ordinal.component.html | 35 +------------------ .../check-in-form-ordinal.component.ts | 32 ++++------------- .../check-in-form.component.html | 5 +++ 3 files changed, 12 insertions(+), 60 deletions(-) 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 69352a0f46..0252f0bfec 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 @@ -1,34 +1 @@ - -
-

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

-
-
-

Key Result

-
- {{ keyResult.lastCheckIn?.changeInfo }} -
-
- -
-
-
- -
-
- -
- - - -
+

Was glaubt ihr wo komm ich her

diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts index a1817db920..1a5a719d0b 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts @@ -1,7 +1,6 @@ -import { Component, Inject } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { Component, Input } from '@angular/core'; +import { FormGroup } from '@angular/forms'; import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; @Component({ selector: 'app-check-in-form-ordinal', @@ -9,27 +8,8 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; styleUrls: ['./check-in-form-ordinal.component.scss'], }) export class CheckInFormOrdinalComponent { - keyResult: KeyResultOrdinal; - currentDate: Date; - continued: boolean = false; - dialogForm = new FormGroup({ - value: new FormControl('', [Validators.required]), - confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), - changeInfo: new FormControl('', [Validators.maxLength(4096)]), - initiatives: new FormControl('', [Validators.maxLength(4096)]), - }); - - constructor( - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, - ) { - this.keyResult = data.keyResult; - this.currentDate = new Date(); - } - - saveCheckIn() { - this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); - let checkIn = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; - this.dialogRef.close({ data: checkIn }); - } + @Input() + keyResult!: KeyResultOrdinal; + @Input() + dialogForm!: FormGroup; } 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 970d647f95..bbb7c88ac4 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 @@ -15,6 +15,11 @@

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+
From 27e20b22a30ad4468c3a114c4ffe48b66f0e232c Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 15:43:15 +0200 Subject: [PATCH 44/97] insert confidence component into check-in-ordinal form --- .../check-in-form-ordinal.component.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 0252f0bfec..5739957e1d 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 @@ -1 +1,4 @@ -

Was glaubt ihr wo komm ich her

+
+ Confidence um Target zu erreichen + +
From 9e44f02097dc379e1d956e4daad5b398bb9c73c4 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 15:48:06 +0200 Subject: [PATCH 45/97] fix unset confidence value because of order of commands in saveCheckIn method --- .../dialog/checkin/check-in-form/check-in-form.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 77220da4f2..068be75515 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 @@ -39,11 +39,11 @@ export class CheckInFormComponent { } saveCheckIn() { + this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); let checkIn: any = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; if (this.keyResult.keyResultType === 'metric') { checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; } - this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); this.dialogRef.close({ data: checkIn }); } From 1a6f1e85dfae11abac4973240ecfc4fbdd124b18 Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 15:51:16 +0200 Subject: [PATCH 46/97] add label which tells user the dialog step --- .../dialog/checkin/check-in-form/check-in-form.component.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 bbb7c88ac4..d96efb451a 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,6 +1,8 @@ -
+

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+

(1/2)

+

(2/2)

From 5b242a18dabadac14575b486acc1a2b30695838b Mon Sep 17 00:00:00 2001 From: megli2 Date: Thu, 28 Sep 2023 16:15:40 +0200 Subject: [PATCH 47/97] add radio button group style --- .../check-in-form-ordinal.component.html | 13 ++++++++++++- .../check-in-form-ordinal.component.scss | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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 5739957e1d..4be2ce930b 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 @@ -1,4 +1,15 @@ -
+

Erreichten Bereich wählen

+ + +
+ Meilenstein (Commit / Target / Stretch) noch nicht erreicht +
+
+ + + +
+
Confidence um Target zu erreichen
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss index 21560e802a..b5553264e5 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss @@ -9,3 +9,8 @@ background-color: white; color: $pz-dark-blue; } + +.radio-text-container { + background: #f5f5f5; + height: 51px; +} From 32bf995da20160d94beab155a362b7862760c055 Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 08:02:31 +0200 Subject: [PATCH 48/97] implement radio-button zones --- .../check-in-form-ordinal.component.html | 20 +++++++++++++++---- .../check-in-form-ordinal.component.scss | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) 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 4be2ce930b..02ff96cc5d 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 @@ -1,13 +1,25 @@

Erreichten Bereich wählen

- +
Meilenstein (Commit / Target / Stretch) noch nicht erreicht
- - - + +
+ {{ keyResult.commitZone }} +
+
+ +
+ {{ keyResult.targetZone }} +
+
+ +
+ {{ keyResult.stretchZone }} +
+
Confidence um Target zu erreichen diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss index b5553264e5..5c49d70eb2 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.scss @@ -13,4 +13,5 @@ .radio-text-container { background: #f5f5f5; height: 51px; + width: 625px; } From 251220ee1a1929a9b2203ce07e4c99f5c89a878a Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 08:21:09 +0200 Subject: [PATCH 49/97] implement post action for ordinal check-ins --- .../check-in-form-ordinal.component.html | 56 ++++++++++--------- .../check-in-form-ordinal.component.ts | 2 + .../check-in-form/check-in-form.component.ts | 1 + frontend/src/app/shared/types/enums/Zone.ts | 6 ++ 4 files changed, 38 insertions(+), 27 deletions(-) create mode 100644 frontend/src/app/shared/types/enums/Zone.ts 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 02ff96cc5d..f182dc8b1b 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 @@ -1,27 +1,29 @@ -

Erreichten Bereich wählen

- - -
- Meilenstein (Commit / Target / Stretch) noch nicht erreicht -
-
- -
- {{ keyResult.commitZone }} -
-
- -
- {{ keyResult.targetZone }} -
-
- -
- {{ keyResult.stretchZone }} -
-
-
-
- Confidence um Target zu erreichen - -
+
+

Erreichten Bereich wählen

+ + +
+ Meilenstein (Commit / Target / Stretch) noch nicht erreicht +
+
+ +
+ {{ keyResult.commitZone }} +
+
+ +
+ {{ keyResult.targetZone }} +
+
+ +
+ {{ keyResult.stretchZone }} +
+
+
+
+ Confidence um Target zu erreichen + +
+
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts index 1a5a719d0b..9bee902d50 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; +import { Zone } from '../../../types/enums/Zone'; @Component({ selector: 'app-check-in-form-ordinal', @@ -12,4 +13,5 @@ export class CheckInFormOrdinalComponent { keyResult!: KeyResultOrdinal; @Input() dialogForm!: FormGroup; + protected readonly Zone = Zone; } 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 068be75515..b5c3e52ada 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 @@ -44,6 +44,7 @@ export class CheckInFormComponent { if (this.keyResult.keyResultType === 'metric') { checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; } + console.log(checkIn); this.dialogRef.close({ data: checkIn }); } diff --git a/frontend/src/app/shared/types/enums/Zone.ts b/frontend/src/app/shared/types/enums/Zone.ts new file mode 100644 index 0000000000..0a34e2fffc --- /dev/null +++ b/frontend/src/app/shared/types/enums/Zone.ts @@ -0,0 +1,6 @@ +export enum Zone { + FAIL='FAIL', + COMMIT='COMMIT', + TARGET='TARGET', + STRETCH='STRETCH', +} From 1f15f607b360dd4225694eabc70a4889d31341ee Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 08:21:29 +0200 Subject: [PATCH 50/97] format created enum --- frontend/src/app/shared/types/enums/Zone.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/shared/types/enums/Zone.ts b/frontend/src/app/shared/types/enums/Zone.ts index 0a34e2fffc..6610eef36e 100644 --- a/frontend/src/app/shared/types/enums/Zone.ts +++ b/frontend/src/app/shared/types/enums/Zone.ts @@ -1,6 +1,6 @@ export enum Zone { - FAIL='FAIL', - COMMIT='COMMIT', - TARGET='TARGET', - STRETCH='STRETCH', + FAIL = 'FAIL', + COMMIT = 'COMMIT', + TARGET = 'TARGET', + STRETCH = 'STRETCH', } From 81635771b389da9780661cbed148bbc751628399 Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 08:54:19 +0200 Subject: [PATCH 51/97] rename zone of KeyResultOrdinalDto to value --- .../okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java | 4 +++- .../puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java index 9b827495db..b4525da0f1 100644 --- a/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java +++ b/backend/src/main/java/ch/puzzle/okr/dto/keyresult/KeyResultLastCheckInOrdinalDto.java @@ -1,7 +1,9 @@ package ch.puzzle.okr.dto.keyresult; +import ch.puzzle.okr.models.checkin.Zone; + import java.time.LocalDateTime; -public record KeyResultLastCheckInOrdinalDto(Long id, String zone, Integer confidence, LocalDateTime createdOn, +public record KeyResultLastCheckInOrdinalDto(Long id, Zone value, Integer confidence, LocalDateTime createdOn, String changeInfo, String initiatives) implements KeyResultLastCheckIn { } diff --git a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java index b44dd07981..e10d0d2c4b 100644 --- a/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java +++ b/backend/src/main/java/ch/puzzle/okr/mapper/keyresult/KeyResultOrdinalMapper.java @@ -57,8 +57,8 @@ public KeyResultLastCheckInOrdinalDto getLastCheckInDto(Long keyResultId) { lastCheckInDto = null; } else { lastCheckInDto = new KeyResultLastCheckInOrdinalDto(lastCheckIn.getId(), - ((CheckInOrdinal) lastCheckIn).getZone().toString(), lastCheckIn.getConfidence(), - lastCheckIn.getCreatedOn(), lastCheckIn.getChangeInfo(), lastCheckIn.getInitiatives()); + ((CheckInOrdinal) lastCheckIn).getZone(), lastCheckIn.getConfidence(), lastCheckIn.getCreatedOn(), + lastCheckIn.getChangeInfo(), lastCheckIn.getInitiatives()); } return lastCheckInDto; } From d7e46eaa22ad1daab2c0dacd2d31be24eabd3bae Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 09:16:22 +0200 Subject: [PATCH 52/97] implement enum which holds unit values and use it in unit-transformation pipe --- .../src/app/shared/pipes/unit-transformation.pipe.ts | 9 ++++++--- frontend/src/app/shared/types/enums/Unit.ts | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 frontend/src/app/shared/types/enums/Unit.ts diff --git a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-transformation.pipe.ts index 5af94a6e4f..aa83e63fcc 100644 --- a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts +++ b/frontend/src/app/shared/pipes/unit-transformation.pipe.ts @@ -1,5 +1,6 @@ import { Pipe, PipeTransform } from '@angular/core'; import { formatCurrency } from '@angular/common'; +import { Unit } from '../types/enums/Unit'; @Pipe({ name: 'unitTransformation', @@ -10,11 +11,13 @@ export class UnitTransformationPipe implements PipeTransform { value = 0; } switch (unit) { - case 'CHF': + case Unit.CHF: return value % 1 != 0 ? formatCurrency(value, 'en', '') : value + '.-'; - case 'PERCENT': + case Unit.PERCENT: return value + '%'; - case 'FTE': + case Unit.FTE: + return value.toString(); + case Unit.NUMBER: return value.toString(); default: return value.toString(); diff --git a/frontend/src/app/shared/types/enums/Unit.ts b/frontend/src/app/shared/types/enums/Unit.ts new file mode 100644 index 0000000000..0da371a27c --- /dev/null +++ b/frontend/src/app/shared/types/enums/Unit.ts @@ -0,0 +1,6 @@ +export enum Unit { + PERCENT = 'PERCENT', + CHF = 'CHF', + FTE = 'FTE', + NUMBER = 'NUMBER', +} From 20189c812ea999ce62d54764965f1f8c4375b0b8 Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 09:30:58 +0200 Subject: [PATCH 53/97] implement pipe to transform label of unit into wanted string --- frontend/src/app/app.module.ts | 6 +++-- .../check-in-form-metric.component.html | 2 +- .../check-in-form-metric.component.ts | 2 +- .../unit-label-transformation.pipe.spec.ts | 8 +++++++ .../unit-label-transformation.pipe.ts | 24 +++++++++++++++++++ .../unit-transformation.pipe.spec.ts | 0 .../unit-transformation.pipe.ts | 2 +- 7 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts create mode 100644 frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts rename frontend/src/app/shared/pipes/{ => unit-transformation}/unit-transformation.pipe.spec.ts (100%) rename frontend/src/app/shared/pipes/{ => unit-transformation}/unit-transformation.pipe.ts (93%) diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index d803b08b10..e2f943e77f 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -48,13 +48,14 @@ import { CheckInHistoryDialogComponent } from './shared/dialog/check-in-history- import { MatDividerModule } from '@angular/material/divider'; import { ApplicationBannerComponent } from './application-banner/application-banner.component'; import { CheckInFormMetricComponent } from './shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component'; -import { UnitTransformationPipe } from './shared/pipes/unit-transformation.pipe'; +import { UnitTransformationPipe } from './shared/pipes/unit-transformation/unit-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 { CheckInFormOrdinalComponent } from './shared/dialog/check-in-form-ordinal/check-in-form-ordinal.component'; import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog.component'; import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; import { CheckInFormComponent } from './shared/dialog/checkin/check-in-form/check-in-form.component'; +import { UnitLabelTransformationPipe } from './shared/pipes/unit-label-transformation/unit-label-transformation.pipe'; function initOauthFactory(configService: ConfigService, oauthService: OAuthService) { return async () => { @@ -108,6 +109,7 @@ export const MY_FORMATS = { CheckInBaseInformationsComponent, CustomInputComponent, CheckInFormComponent, + UnitLabelTransformationPipe, ], imports: [ CommonModule, 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 2f20aa1019..d8db34bb10 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 @@ -2,7 +2,7 @@
Aktueller Wert ({{ keyResult.unit }}): + >Aktueller Wert ({{ keyResult.unit | unitLabelTransformation }}):
{ + it('create an instance', () => { + const pipe = new UnitLabelTransformationPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts new file mode 100644 index 0000000000..09f694b69f --- /dev/null +++ b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts @@ -0,0 +1,24 @@ +import {Pipe, PipeTransform} from '@angular/core'; +import {Unit} from "../../types/enums/Unit"; +import translation from "../../../../assets/i18n/de.json" + +@Pipe({ + name: 'unitLabelTransformation' +}) +export class UnitLabelTransformationPipe implements PipeTransform { + + transform(unitLabel: String): String { + switch (unitLabel) { + case Unit.PERCENT: + return ""; + case Unit.FTE: + return Unit.FTE; + case Unit.CHF: + return Unit.CHF; + case Unit.NUMBER: + return translation.UNIT.NUMBER + default: + return unitLabel; + } + } +} diff --git a/frontend/src/app/shared/pipes/unit-transformation.pipe.spec.ts b/frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.spec.ts similarity index 100% rename from frontend/src/app/shared/pipes/unit-transformation.pipe.spec.ts rename to frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.spec.ts diff --git a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.ts similarity index 93% rename from frontend/src/app/shared/pipes/unit-transformation.pipe.ts rename to frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.ts index aa83e63fcc..4483c3c8a1 100644 --- a/frontend/src/app/shared/pipes/unit-transformation.pipe.ts +++ b/frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.ts @@ -1,6 +1,6 @@ import { Pipe, PipeTransform } from '@angular/core'; import { formatCurrency } from '@angular/common'; -import { Unit } from '../types/enums/Unit'; +import { Unit } from '../../types/enums/Unit'; @Pipe({ name: 'unitTransformation', From 77523762f9778a618ec72ba7dd612c5939ba939f Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 09:31:30 +0200 Subject: [PATCH 54/97] format generated pipe --- .../unit-label-transformation.pipe.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts index 09f694b69f..71d518302d 100644 --- a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts +++ b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.ts @@ -1,22 +1,21 @@ -import {Pipe, PipeTransform} from '@angular/core'; -import {Unit} from "../../types/enums/Unit"; -import translation from "../../../../assets/i18n/de.json" +import { Pipe, PipeTransform } from '@angular/core'; +import { Unit } from '../../types/enums/Unit'; +import translation from '../../../../assets/i18n/de.json'; @Pipe({ - name: 'unitLabelTransformation' + name: 'unitLabelTransformation', }) export class UnitLabelTransformationPipe implements PipeTransform { - transform(unitLabel: String): String { switch (unitLabel) { case Unit.PERCENT: - return ""; + return ''; case Unit.FTE: return Unit.FTE; case Unit.CHF: return Unit.CHF; case Unit.NUMBER: - return translation.UNIT.NUMBER + return translation.UNIT.NUMBER; default: return unitLabel; } From 9db46af819b4d971e1052f62c04538bd7fd2d35c Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 09:38:08 +0200 Subject: [PATCH 55/97] fix error of confidence not updating on keyresult detail component --- .../src/app/keyresult-detail/keyresult-detail.component.ts | 3 ++- .../dialog/checkin/check-in-form/check-in-form.component.ts | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 21a5bf1ebc..72805356b6 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -10,6 +10,7 @@ import { KeyResultDialogComponent } from '../key-result-dialog/key-result-dialog import { NotifierService } from '../shared/services/notifier.service'; import { CheckInService } from '../shared/services/check-in.service'; import { CheckInFormComponent } from '../shared/dialog/checkin/check-in-form/check-in-form.component'; +import { keyResult } from '../shared/testData'; @Component({ selector: 'app-keyresult-detail', @@ -96,7 +97,7 @@ export class KeyresultDetailComponent implements OnChanges { dialogRef.afterClosed().subscribe((result) => { if (result != undefined && result != '') { this.checkInService.createCheckIn(result.data).subscribe((createdCheckIn) => { - this.keyResult.lastCheckIn = createdCheckIn; + this.keyResult = { ...this.keyResult, lastCheckIn: createdCheckIn }; this.changeDetectorRef.detectChanges(); }); } 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 b5c3e52ada..068be75515 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 @@ -44,7 +44,6 @@ export class CheckInFormComponent { if (this.keyResult.keyResultType === 'metric') { checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; } - console.log(checkIn); this.dialogRef.close({ data: checkIn }); } From 8b4c3485cda36ef4d672a23efab859b4cddce78c Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 09:48:52 +0200 Subject: [PATCH 56/97] use constant of constantLibrary in check-in-history to format date --- .../check-in-history-dialog.component.html | 3 +-- .../check-in-history-dialog.component.ts | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html index e35e64ee48..d6d4fc0e29 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html @@ -8,8 +8,7 @@

Check-in History

- - {{ checkIn.createdOn | date: "dd.MM.yyyy" }} + {{ checkIn.createdOn | date: DATE_FORMAT }} -
Wert: {{ checkIn.value }}; diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts index cd0cbd0b26..51d1cc9942 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts @@ -3,6 +3,7 @@ import { CheckInMin } from '../../types/model/CheckInMin'; import { CheckInService } from '../../services/check-in.service'; import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import errorMessages from '../../../../assets/errors/error-messages.json'; +import { DATE_FORMAT } from '../../constantLibary'; @Component({ selector: 'app-check-in-history-dialog', @@ -23,4 +24,5 @@ export class CheckInHistoryDialogComponent implements OnInit { } protected readonly errorMessages = errorMessages; + protected readonly DATE_FORMAT = DATE_FORMAT; } From 3c16d9be5da4b19b119ca7660a3280cc41226665 Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 10:07:55 +0200 Subject: [PATCH 57/97] open dialog on click to menu --- .../keyresult-detail.component.ts | 2 +- .../check-in-history-dialog.component.html | 19 +++++++++++----- .../check-in-history-dialog.component.ts | 22 ++++++++++++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 72805356b6..a2ebd29914 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -10,7 +10,6 @@ import { KeyResultDialogComponent } from '../key-result-dialog/key-result-dialog import { NotifierService } from '../shared/services/notifier.service'; import { CheckInService } from '../shared/services/check-in.service'; import { CheckInFormComponent } from '../shared/dialog/checkin/check-in-form/check-in-form.component'; -import { keyResult } from '../shared/testData'; @Component({ selector: 'app-keyresult-detail', @@ -49,6 +48,7 @@ export class KeyresultDetailComponent implements OnChanges { const dialogRef = this.dialog.open(CheckInHistoryDialogComponent, { data: { keyResultId: this.keyResult.id, + keyResult: this.keyResult, }, }); diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html index d6d4fc0e29..c13b5d1fd2 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html @@ -8,12 +8,21 @@

Check-in History

- {{ checkIn.createdOn | date: DATE_FORMAT }} - - -
- Wert: {{ checkIn.value }}; +
+ {{ checkIn.createdOn | date: DATE_FORMAT }} + - +
+ Wert: {{ checkIn.value }}; +
+ Confidence: {{ checkIn.confidence }} / 10; +
+
+ + + + +
- Confidence: {{ checkIn.confidence }} / 10;

Veränderungen: {{ checkIn.changeInfo }}

Massnahmen: {{ checkIn.initiatives }}

diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts index 51d1cc9942..930727b103 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts @@ -1,9 +1,11 @@ import { Component, Inject, OnInit } from '@angular/core'; import { CheckInMin } from '../../types/model/CheckInMin'; import { CheckInService } from '../../services/check-in.service'; -import { MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog'; import errorMessages from '../../../../assets/errors/error-messages.json'; import { DATE_FORMAT } from '../../constantLibary'; +import { KeyResult } from '../../types/model/KeyResult'; +import { CheckInFormComponent } from '../checkin/check-in-form/check-in-form.component'; @Component({ selector: 'app-check-in-history-dialog', @@ -11,18 +13,36 @@ import { DATE_FORMAT } from '../../constantLibary'; styleUrls: ['./check-in-history-dialog.component.scss'], }) export class CheckInHistoryDialogComponent implements OnInit { + keyResult!: KeyResult; checkInHistory: CheckInMin[] = []; constructor( @Inject(MAT_DIALOG_DATA) public data: any, private checkInService: CheckInService, + private dialog: MatDialog, + public dialogRef: MatDialogRef, ) {} ngOnInit(): void { + this.keyResult = this.data.keyResult; this.checkInService.getAllCheckInOfKeyResult(this.data.keyResultId).subscribe((result) => { this.checkInHistory = result; }); } + openCheckInDialog(checkIn: CheckInMin) { + this.dialogRef.close(); + const dialogRef = this.dialog.open(CheckInFormComponent, { + data: { + keyResultId: this.keyResult.id, + keyResult: this.keyResult, + }, + width: '719px', + }); + dialogRef.afterClosed().subscribe((result) => { + console.log(result); + }); + } + protected readonly errorMessages = errorMessages; protected readonly DATE_FORMAT = DATE_FORMAT; } From 4c359f320b0ace434db14b3fe4264aa0dc3f32b4 Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 10:21:08 +0200 Subject: [PATCH 58/97] load all values into form from edited check-in except confidence --- .../check-in-history-dialog.component.ts | 2 +- .../checkin/check-in-form/check-in-form.component.html | 5 ++++- .../checkin/check-in-form/check-in-form.component.ts | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts index 930727b103..9941509a3e 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts @@ -33,8 +33,8 @@ export class CheckInHistoryDialogComponent implements OnInit { this.dialogRef.close(); const dialogRef = this.dialog.open(CheckInFormComponent, { data: { - keyResultId: this.keyResult.id, keyResult: this.keyResult, + checkIn: checkIn, }, width: '719px', }); 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 d96efb451a..ef0a737413 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,6 +1,9 @@
-

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

+

+ Check-in bearbeiten ({{ checkIn.createdOn | date: "dd.MM.yyyy" }}) +

(1/2)

(2/2)

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 068be75515..f8db093610 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 @@ -4,6 +4,7 @@ import { FormControl, FormGroup, Validators } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { KeyResult } from '../../../types/model/KeyResult'; import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; +import { CheckInMin } from '../../../types/model/CheckInMin'; @Component({ selector: 'app-check-in-form', @@ -12,6 +13,7 @@ import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; }) export class CheckInFormComponent { keyResult: KeyResult; + checkIn: CheckInMin; currentDate: Date; continued: boolean = false; @@ -28,10 +30,18 @@ export class CheckInFormComponent { ) { this.currentDate = new Date(); this.keyResult = data.keyResult; + this.checkIn = data.checkIn; this.setDefaultValues(); } setDefaultValues() { + if (this.data.checkIn != null) { + this.dialogForm.controls.value.setValue(this.checkIn.value!.toString()); + this.dialogForm.controls.confidence.setValue(this.checkIn.confidence); + this.dialogForm.controls.changeInfo.setValue(this.checkIn.changeInfo); + this.dialogForm.controls.initiatives.setValue(this.checkIn.initiatives); + return; + } if (this.keyResult.lastCheckIn?.value != null) { this.dialogForm.controls.value.setValue(this.keyResult.lastCheckIn.value.toString()); this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn.confidence); From 2e1929103f3134fb8413e26f7a66963c2f399f3f Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 14:57:04 +0200 Subject: [PATCH 59/97] fix error of confidence component not setting check-in confidence because of wrong model use in ngmodel --- frontend/src/app/confidence/confidence.component.html | 8 +++----- frontend/src/app/confidence/confidence.component.ts | 6 +++--- .../app/keyresult-detail/keyresult-detail.component.html | 2 +- frontend/src/app/keyresult/keyresult.component.html | 2 +- frontend/src/app/keyresult/keyresult.component.ts | 2 +- .../check-in-form-metric.component.html | 2 +- .../check-in-form-metric.component.ts | 3 +++ .../check-in-form-ordinal.component.html | 2 +- .../check-in-form-ordinal.component.ts | 3 +++ .../checkin/check-in-form/check-in-form.component.html | 2 ++ .../checkin/check-in-form/check-in-form.component.ts | 4 ++-- 11 files changed, 21 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/confidence/confidence.component.html b/frontend/src/app/confidence/confidence.component.html index c05766e27e..f8aebb6bd5 100644 --- a/frontend/src/app/confidence/confidence.component.html +++ b/frontend/src/app/confidence/confidence.component.html @@ -1,14 +1,12 @@ -
+
-

- {{ keyResult.lastCheckIn?.confidence }}/{{ max }} -

+

{{ checkIn.confidence }}/{{ max }}

- +
diff --git a/frontend/src/app/confidence/confidence.component.ts b/frontend/src/app/confidence/confidence.component.ts index 466e77db62..f477643f38 100644 --- a/frontend/src/app/confidence/confidence.component.ts +++ b/frontend/src/app/confidence/confidence.component.ts @@ -13,12 +13,12 @@ export class ConfidenceComponent implements OnChanges { min: number = 1; max: number = 10; @Input() edit: boolean = true; - @Input() keyResult!: KeyresultMin | KeyResult; + @Input() checkIn!: CheckInMin; @Input() backgroundColor!: string; ngOnChanges(changes: SimpleChanges) { - if (changes['keyResult']?.currentValue?.lastCheckIn === null) { - this.keyResult.lastCheckIn = { confidence: 5 } as CheckInMin; + if (changes['checkIn']?.currentValue === undefined || changes['checkIn']?.currentValue === null) { + this.checkIn = { confidence: 5 } as CheckInMin; } } } diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.html b/frontend/src/app/keyresult-detail/keyresult-detail.component.html index 6542e035c2..5145f0cde8 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.html +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.html @@ -18,7 +18,7 @@

{{ keyResult.title }}

Confidence

- +
diff --git a/frontend/src/app/keyresult/keyresult.component.html b/frontend/src/app/keyresult/keyresult.component.html index 54bbcf67b5..1b3b4f0968 100644 --- a/frontend/src/app/keyresult/keyresult.component.html +++ b/frontend/src/app/keyresult/keyresult.component.html @@ -12,7 +12,7 @@

Confidence

- +
Noch kein Check-in vorhanden
diff --git a/frontend/src/app/keyresult/keyresult.component.ts b/frontend/src/app/keyresult/keyresult.component.ts index 142a799f21..838814ee3b 100644 --- a/frontend/src/app/keyresult/keyresult.component.ts +++ b/frontend/src/app/keyresult/keyresult.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; import { KeyresultMin } from '../shared/types/model/KeyresultMin'; import { MatDialog } from '@angular/material/dialog'; import { CheckInHistoryDialogComponent } from '../shared/dialog/check-in-history-dialog/check-in-history-dialog.component'; 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 d8db34bb10..bf5bf64eb9 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 @@ -20,6 +20,6 @@
Confidence um Target zu erreichen - +
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index 6e3e9f3adb..8b5f05be2e 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -3,6 +3,7 @@ import { FormGroup } from '@angular/forms'; import errorMessages from '../../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; import { UnitTransformationPipe } from '../../../pipes/unit-transformation/unit-transformation.pipe'; +import { CheckInMin } from '../../../types/model/CheckInMin'; @Component({ selector: 'app-check-in-form-metric', @@ -13,6 +14,8 @@ export class CheckInFormMetricComponent implements AfterViewInit { @Input() keyResult!: KeyResultMetric; @Input() + checkIn!: CheckInMin; + @Input() dialogForm!: FormGroup; protected readonly errorMessages: any = errorMessages; 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 f182dc8b1b..747a9d2638 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 @@ -24,6 +24,6 @@
Confidence um Target zu erreichen - +
diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts index 9bee902d50..ce4b89342b 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts @@ -2,6 +2,7 @@ import { Component, Input } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; import { Zone } from '../../../types/enums/Zone'; +import { CheckInMin } from '../../../types/model/CheckInMin'; @Component({ selector: 'app-check-in-form-ordinal', @@ -12,6 +13,8 @@ export class CheckInFormOrdinalComponent { @Input() keyResult!: KeyResultOrdinal; @Input() + checkIn!: CheckInMin; + @Input() dialogForm!: FormGroup; protected readonly Zone = Zone; } 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 ef0a737413..86ab9fe048 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 @@ -18,11 +18,13 @@

(2/2)

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 f8db093610..3bc327ce91 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 @@ -30,7 +30,7 @@ export class CheckInFormComponent { ) { this.currentDate = new Date(); this.keyResult = data.keyResult; - this.checkIn = data.checkIn; + this.checkIn = data.checkIn === undefined ? this.keyResult.lastCheckIn : data.checkIn; this.setDefaultValues(); } @@ -44,11 +44,11 @@ export class CheckInFormComponent { } if (this.keyResult.lastCheckIn?.value != null) { this.dialogForm.controls.value.setValue(this.keyResult.lastCheckIn.value.toString()); - this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn.confidence); } } saveCheckIn() { + this.dialogForm.controls.confidence.setValue(this.checkIn.confidence); this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); let checkIn: any = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; if (this.keyResult.keyResultType === 'metric') { From c0176137de7f6420381616afa76ed5c525cfc989 Mon Sep 17 00:00:00 2001 From: megli2 Date: Fri, 29 Sep 2023 16:04:58 +0200 Subject: [PATCH 60/97] update check-in in frontend --- .../okr/service/business/CheckInBusinessService.java | 1 + .../keyresult-detail/keyresult-detail.component.html | 8 +++++++- .../keyresult-detail/keyresult-detail.component.ts | 12 ++++++++++-- .../check-in-history-dialog.component.ts | 7 ++++++- .../checkin/check-in-form/check-in-form.component.ts | 2 +- frontend/src/app/shared/services/check-in.service.ts | 4 ++++ frontend/src/app/shared/services/notifier.service.ts | 2 ++ 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/ch/puzzle/okr/service/business/CheckInBusinessService.java b/backend/src/main/java/ch/puzzle/okr/service/business/CheckInBusinessService.java index 5de7eadbe1..96cdd776c9 100644 --- a/backend/src/main/java/ch/puzzle/okr/service/business/CheckInBusinessService.java +++ b/backend/src/main/java/ch/puzzle/okr/service/business/CheckInBusinessService.java @@ -31,6 +31,7 @@ public CheckIn getCheckInById(Long id) { @Transactional public CheckIn createCheckIn(CheckIn checkIn, Jwt token) { checkIn.setCreatedOn(LocalDateTime.now()); + checkIn.setModifiedOn(LocalDateTime.now()); checkIn.setCreatedBy(userBusinessService.getUserByAuthorisationToken(token)); validator.validateOnCreate(checkIn); return checkInPersistenceService.save(checkIn); diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.html b/frontend/src/app/keyresult-detail/keyresult-detail.component.html index 5145f0cde8..c8d2425d8a 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.html +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.html @@ -49,7 +49,13 @@

{{ keyResult.title }}

-
+
+

+ Letztes Check-in ({{ keyResult.lastCheckIn?.modifiedOn | date: "dd.MM.yyy" }}) +

+

{{ keyResult.lastCheckIn?.changeInfo }}

+
+

Letztes Check-in ({{ keyResult.lastCheckIn?.createdOn | date: "dd.MM.yyy" }})

diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index a2ebd29914..8d8cd1efeb 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -24,10 +24,18 @@ export class KeyresultDetailComponent implements OnChanges { constructor( private keyResultService: KeyresultService, private checkInService: CheckInService, + private notifierService: NotifierService, private changeDetectorRef: ChangeDetectorRef, private dialog: MatDialog, - private notifierService: NotifierService, - ) {} + ) { + this.notifierService.reopenCheckInDialog.subscribe((result) => { + if (this.keyResult.lastCheckIn?.id === result.id) { + this.keyResult = { ...this.keyResult, lastCheckIn: result }; + this.changeDetectorRef.detectChanges(); + } + this.checkInHistory(); + }); + } ngOnChanges() { this.keyResultService.getFullKeyResult(this.keyResultId).subscribe((fullKeyResult) => { diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts index 9941509a3e..b6c235936d 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts @@ -6,6 +6,7 @@ import errorMessages from '../../../../assets/errors/error-messages.json'; import { DATE_FORMAT } from '../../constantLibary'; import { KeyResult } from '../../types/model/KeyResult'; import { CheckInFormComponent } from '../checkin/check-in-form/check-in-form.component'; +import { NotifierService } from '../../services/notifier.service'; @Component({ selector: 'app-check-in-history-dialog', @@ -21,6 +22,7 @@ export class CheckInHistoryDialogComponent implements OnInit { private checkInService: CheckInService, private dialog: MatDialog, public dialogRef: MatDialogRef, + public notifierService: NotifierService, ) {} ngOnInit(): void { this.keyResult = this.data.keyResult; @@ -39,7 +41,10 @@ export class CheckInHistoryDialogComponent implements OnInit { width: '719px', }); dialogRef.afterClosed().subscribe((result) => { - console.log(result); + let updatedCheckIn = { ...result.data, id: checkIn.id }; + this.checkInService.updateCheckIn(updatedCheckIn, updatedCheckIn.id).subscribe((updatedCheckIn) => { + this.notifierService.reopenCheckInDialog.next(updatedCheckIn); + }); }); } 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 3bc327ce91..8c0f6314cf 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 @@ -48,8 +48,8 @@ export class CheckInFormComponent { } saveCheckIn() { + console.log(this.checkIn); this.dialogForm.controls.confidence.setValue(this.checkIn.confidence); - this.dialogForm.controls.confidence.setValue(this.keyResult.lastCheckIn!.confidence); let checkIn: any = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; if (this.keyResult.keyResultType === 'metric') { checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; diff --git a/frontend/src/app/shared/services/check-in.service.ts b/frontend/src/app/shared/services/check-in.service.ts index 85f00c58de..82780221b2 100644 --- a/frontend/src/app/shared/services/check-in.service.ts +++ b/frontend/src/app/shared/services/check-in.service.ts @@ -17,4 +17,8 @@ export class CheckInService { createCheckIn(checkIn: any): Observable { return this.httpclient.post('/api/v2/checkIns', checkIn); } + + updateCheckIn(checkIn: any, id: number): Observable { + return this.httpclient.put('/api/v2/checkIns/' + id, checkIn); + } } diff --git a/frontend/src/app/shared/services/notifier.service.ts b/frontend/src/app/shared/services/notifier.service.ts index bf8c756577..2d2048a210 100644 --- a/frontend/src/app/shared/services/notifier.service.ts +++ b/frontend/src/app/shared/services/notifier.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Subject } from 'rxjs'; +import { CheckIn } from '../types/model/CheckIn'; import { KeyResult } from '../types/model/KeyResult'; import { Objective } from '../types/model/Objective'; @@ -8,6 +9,7 @@ import { Objective } from '../types/model/Objective'; }) export class NotifierService { closeDetailSubject: Subject = new Subject(); + reopenCheckInDialog: Subject = new Subject(); keyResultsChanges: Subject<{ keyResult: KeyResult; changeId: number | null; objective: Objective; delete: boolean }> = new Subject<{ From 836d72076f2450f7cf3669a4495dc5b5fac5decf Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 10:26:42 +0200 Subject: [PATCH 61/97] create insert script for new data with of new quarter --- .../data-migration/V2_1_2__newQuarterData.sql | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql diff --git a/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql b/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql new file mode 100644 index 0000000000..406bcdf70f --- /dev/null +++ b/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql @@ -0,0 +1,42 @@ +insert into objective (id, description, modified_on, title, created_by_id, quarter_id, team_id, state, modified_by_id, created_on) +values (17, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:01:50.000000', 'Unsere Mockups werden zu den Besten der Schweiz', 1, 7, 8, 'NOTSUCCESSFUL', null, '2023-10-02 09:02:38.000000'), + (18, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:03:01.000000', 'Wir pflegen eine offene Kommunikation mit den Entwicklern.', 1, 7, 8, 'DRAFT', null, '2023-10-02 09:03:44.000000'), + (19, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 15:04:02.000000', 'Wir verwenden ausschliesslich Angular Material in unseren Designs.', 1, 7, 8, 'NOTSUCCESSFUL', null, '2023-10-02 09:05:17.000000'), + (20, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 15:05:57.000000', 'Loremsen Inud di doro sim guru', 1, 7, 6, 'SUCCESSFUL', null, '2023-10-02 09:06:41.000000'), + (21, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 13:07:09.000000', 'Ting Tang Wala Wala Bing Bang', 1, 7, 6, 'SUCCESSFUL', null, '2023-10-02 09:07:39.000000'), + (22, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 13:07:56.000000', 'Wing Wang Tala Tala Ting Tang', 1, 7, 6, 'NOTSUCCESSFUL', null, '2023-10-02 09:08:40.000000'), + (11, 'Damit wir effizienter und besser zusammenarbeiten, müssen wir den Teamzusammenhalt stärken', '2023-10-02 13:49:39.000000', 'Wir wollen die Zusammenarbeit im Team steigern.', 1, 7, 5, 'ONGOING', null, '2023-10-02 08:49:29.000000'), + (12, 'Um die Löhne unserer Mitarbeiter zu erhöhen müssen wir mehr Umsatz machen', '2023-10-02 10:51:02.000000', 'Wir wollen mehr Umsatz machen.', 1, 7, 5, 'DRAFT', null, '2023-10-02 08:51:40.000000'), + (13, 'Um eine saubere und natürliche Arbeitsumgebung für die Mitarbeiter zu schaffen, richten wir mehr Pflanzen ein.', '2023-10-02 12:53:36.000000', 'Wir wollen mehr Pflanzen in den Puzzle Büros.', 1, 7, 5, 'DRAFT', null, '2023-10-02 08:54:11.000000'), + (14, 'Damit wir motivierte Lernende geben wir Ihnen jeden morgen ein gratis Schoggigipfeli.', '2023-10-02 14:55:30.000000', 'Wir wollen motivierte, satte Lernende', 1, 7, 4, 'ONGOING', null, '2023-10-02 08:56:12.000000'), + (15, 'Um die Ausgaben für Getränke zu reduzieren, muss der Konsum im BBT reduziert werden.', '2023-10-02 14:57:25.000000', 'Wir wollen unseren Konsum von Süssgetränken und Speisen reduzieren.', 1, 7, 4, 'NOTSUCCESSFUL', null, '2023-10-02 08:58:39.000000'), + (16, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:59:21.000000', 'Das BBT wird zur rentabelsten Division bei Puzzle ITC', 1, 7, 4, 'SUCCESSFUL', null, '2023-10-02 09:00:23.000000'); + + +insert into key_result (id, baseline, description, modified_on, stretch_goal, title, created_by_id, objective_id, owner_id, unit, key_result_type, created_on, commit_zone, target_zone, stretch_zone) +values (20, 0, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 150, 'Prow scuttle parrel provost Sail ho shrouds spirits boom mizzenmast yardarm.', 1, 11, 1, 'PERCENT', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (21, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Clap of thunder bilge aft log crows nest landlubber or just lubber overhaul', 1, 11, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'This is the commit zone', 'This is the target zone', 'This is the stretch zone'), + (22, 40, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 300, 'Scourge of the seven seas blow the man down provost hail-shot Yellow Jack', 1, 11, 1, 'PERCENT', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (23, 1050, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 5000, 'Sea Legs hogshead yardarm Pieces of Eight boatswain jack mizzen tack belay ballast', 1, 12, 1, 'NUMBER', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (24, 50, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 100, 'Parrel Shiver me timbers lanyard crows nest fluke gun skysail no prey', 1, 12, 1, 'CHF', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (25, 15, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 45, 'Driver jack hempen halter poop deck bucko broadside me', 1, 12, 1, 'FTE', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (26, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Hornswaggle hands rum Gold Road lugsail spanker Davy Jones Locker pressgang ', 1, 13, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), + (27, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Black spot bilge booty marooned Davy Jones Locker rum scourge of the seven seas Sink ', 1, 13, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), + (28, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Scallywag Spanish Main coxswain brigantine case shot bring a spring upon her cable ', 1, 13, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), + (29, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Smartly aye Pieces of Eight hang the jib gun nipperkin Nelsons folly schooner Pirate Round swab', 1, 18, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), + (30, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Jack Tar strike colors draft Cat onine tails blow the man down skysail mutiny yawl overhaul bilge', 1, 18, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Commit zone is here', 'Target zone is here', 'Stretch zone is here'), + (31, 9, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 27, 'Rigging tender flogging gun clipper Plate Fleet bowsprit crack Jennys tea cup gunwalls Davy Jones Locker', 1, 20, 1, 'NUMBER', 'metric', '2023-10-02 09:16:07.000000', null, null, null); + +insert into check_in (id, change_info, created_on, initiatives, modified_on, value_metric, created_by_id, key_result_id, confidence, check_in_type, zone) + values (21, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', 150, 1, 20, 10, 'metric', null), +(22, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', null, 1, 21, 4, 'ordinal', 'FAIL'), +(23, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', 200, 1, 22, 6, 'metric', null), +(24, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', 200, 1, 23, 1, 'metric', null), +(25, 'Lorem ipsum dolor sit amet', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', 75, 1, 24, 2, 'metric', ''), +(26, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', 70, 1, 25, 9, 'metric', null), +(27, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 26, 6, 'ordinal', 'COMMIT'), +(28, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 27, 8, 'ordinal', 'TARGET'), +(29, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 28, 8, 'ordinal', 'STRETCH'), +(30, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 29, 10, 'ordinal', 'STRETCH'), +(31, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 30, 2, 'ordinal', 'FAIL'), +(32, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', 13, 1, 31, 3, 'metric', null); \ No newline at end of file From ed552a6c2f175e2381fd6b3c3fc01a9368d6867a Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 10:31:20 +0200 Subject: [PATCH 62/97] do request only if result of update dialog is not undefined and not null --- .../check-in-history-dialog.component.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts index b6c235936d..4b519a9b77 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts @@ -41,10 +41,12 @@ export class CheckInHistoryDialogComponent implements OnInit { width: '719px', }); dialogRef.afterClosed().subscribe((result) => { - let updatedCheckIn = { ...result.data, id: checkIn.id }; - this.checkInService.updateCheckIn(updatedCheckIn, updatedCheckIn.id).subscribe((updatedCheckIn) => { - this.notifierService.reopenCheckInDialog.next(updatedCheckIn); - }); + if (result.data !== undefined && result.data !== null) { + let updatedCheckIn = { ...result.data, id: checkIn.id }; + this.checkInService.updateCheckIn(updatedCheckIn, updatedCheckIn.id).subscribe((updatedCheckIn) => { + this.notifierService.reopenCheckInDialog.next(updatedCheckIn); + }); + } }); } From 2383903648a728ce02ffe3ec8eee0695cb2dc88f Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 10:55:49 +0200 Subject: [PATCH 63/97] implement option to delete check-ins in frontend --- frontend/src/app/app.module.ts | 2 ++ .../keyresult-detail.component.ts | 4 +-- .../check-in-history-dialog.component.html | 2 +- .../check-in-history-dialog.component.ts | 18 +++++++++++- .../confirm-dialog.component.html | 4 +-- .../confirm-dialog.component.spec.ts | 28 +++---------------- .../confirm-dialog.component.ts | 13 +++++---- .../app/shared/services/check-in.service.ts | 4 +++ .../app/shared/services/notifier.service.ts | 1 + 9 files changed, 40 insertions(+), 36 deletions(-) diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index e2f943e77f..69c4d62b49 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -56,6 +56,7 @@ import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog. import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; import { CheckInFormComponent } from './shared/dialog/checkin/check-in-form/check-in-form.component'; import { UnitLabelTransformationPipe } from './shared/pipes/unit-label-transformation/unit-label-transformation.pipe'; +import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; function initOauthFactory(configService: ConfigService, oauthService: OAuthService) { return async () => { @@ -110,6 +111,7 @@ export const MY_FORMATS = { CustomInputComponent, CheckInFormComponent, UnitLabelTransformationPipe, + ConfirmDialogComponent, ], imports: [ CommonModule, diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 8d8cd1efeb..18a2eb3cd3 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -28,8 +28,8 @@ export class KeyresultDetailComponent implements OnChanges { private changeDetectorRef: ChangeDetectorRef, private dialog: MatDialog, ) { - this.notifierService.reopenCheckInDialog.subscribe((result) => { - if (this.keyResult.lastCheckIn?.id === result.id) { + this.notifierService.reopenCheckInHistoryDialog.subscribe((result) => { + if (this.keyResult.lastCheckIn?.id === result?.id) { this.keyResult = { ...this.keyResult, lastCheckIn: result }; this.changeDetectorRef.detectChanges(); } diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html index c13b5d1fd2..13d878e10e 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.html @@ -20,7 +20,7 @@

Check-in History

- +
diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts index 4b519a9b77..8e2c08f9e8 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts @@ -7,6 +7,7 @@ import { DATE_FORMAT } from '../../constantLibary'; import { KeyResult } from '../../types/model/KeyResult'; import { CheckInFormComponent } from '../checkin/check-in-form/check-in-form.component'; import { NotifierService } from '../../services/notifier.service'; +import { ConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.component'; @Component({ selector: 'app-check-in-history-dialog', @@ -44,12 +45,27 @@ export class CheckInHistoryDialogComponent implements OnInit { if (result.data !== undefined && result.data !== null) { let updatedCheckIn = { ...result.data, id: checkIn.id }; this.checkInService.updateCheckIn(updatedCheckIn, updatedCheckIn.id).subscribe((updatedCheckIn) => { - this.notifierService.reopenCheckInDialog.next(updatedCheckIn); + this.notifierService.reopenCheckInHistoryDialog.next(updatedCheckIn); }); } }); } + deleteCheckIn(checkIn: CheckInMin) { + this.dialogRef.close(); + const dialogRef = this.dialog.open(ConfirmDialogComponent, { + data: { + title: 'Check-in', + }, + }); + dialogRef.afterClosed().subscribe((result) => { + if (result) { + this.checkInService.deleteCheckIn(checkIn.id).subscribe(); + } + this.notifierService.reopenCheckInHistoryDialog.next(null); + }); + } + protected readonly errorMessages = errorMessages; protected readonly DATE_FORMAT = DATE_FORMAT; } diff --git a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.html b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.html index b223838f27..659d7811a1 100644 --- a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.html +++ b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.html @@ -1,5 +1,5 @@ -

Key Result löschen

-
Soll dieses Key Result gelöscht werden?
+

{{this.data.title}} löschen

+
Soll dieses {{this.data.title}} gelöscht werden?
diff --git a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts index f93f2af047..cf09cfdda0 100644 --- a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts +++ b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts @@ -1,8 +1,6 @@ -import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ConfirmDialogComponent } from './confirm-dialog.component'; -import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; -import { ReactiveFormsModule } from '@angular/forms'; describe('ConfirmDialogComponent', () => { let component: ConfirmDialogComponent; @@ -10,32 +8,14 @@ describe('ConfirmDialogComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [MatDialogModule, ReactiveFormsModule], - providers: [ - { - provide: MatDialogRef, - useValue: {}, - }, - { - provide: MAT_DIALOG_DATA, - useValue: {}, - }, - ], - declarations: [ConfirmDialogComponent], + declarations: [ConfirmDialogComponent] }); fixture = TestBed.createComponent(ConfirmDialogComponent); component = fixture.componentInstance; fixture.detectChanges(); }); - it('should create', fakeAsync(() => { + it('should create', () => { expect(component).toBeTruthy(); - })); - - it('should have two buttons', fakeAsync(() => { - const buttons = document.querySelectorAll('button'); - expect(buttons.length).toEqual(2); - expect(buttons[0].innerHTML).toEqual('Ja'); - expect(buttons[1].innerHTML).toEqual('Nein'); - })); + }); }); diff --git a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.ts b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.ts index d9105497d2..53b83fc80d 100644 --- a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.ts +++ b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.ts @@ -1,16 +1,17 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { MatDialogRef } from '@angular/material/dialog'; +import {Component, Inject} from '@angular/core'; +import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; @Component({ selector: 'app-confirm-dialog', templateUrl: './confirm-dialog.component.html', - styleUrls: ['./confirm-dialog.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, + styleUrls: ['./confirm-dialog.component.scss'] }) export class ConfirmDialogComponent { - constructor(public dialogRef: MatDialogRef) {} + constructor(@Inject(MAT_DIALOG_DATA) public data: any, + public dialogRef: MatDialogRef,) { + } closeAndDelete() { - this.dialogRef.close('deleteKeyResult'); + this.dialogRef.close(true); } } diff --git a/frontend/src/app/shared/services/check-in.service.ts b/frontend/src/app/shared/services/check-in.service.ts index 82780221b2..d3e448cfa5 100644 --- a/frontend/src/app/shared/services/check-in.service.ts +++ b/frontend/src/app/shared/services/check-in.service.ts @@ -21,4 +21,8 @@ export class CheckInService { updateCheckIn(checkIn: any, id: number): Observable { return this.httpclient.put('/api/v2/checkIns/' + id, checkIn); } + + deleteCheckIn(id: number) { + return this.httpclient.delete('/api/v2/checkIns/' + id); + } } diff --git a/frontend/src/app/shared/services/notifier.service.ts b/frontend/src/app/shared/services/notifier.service.ts index 2d2048a210..eef65578b8 100644 --- a/frontend/src/app/shared/services/notifier.service.ts +++ b/frontend/src/app/shared/services/notifier.service.ts @@ -9,6 +9,7 @@ import { Objective } from '../types/model/Objective'; }) export class NotifierService { closeDetailSubject: Subject = new Subject(); + reopenCheckInHistoryDialog: Subject = new Subject(); reopenCheckInDialog: Subject = new Subject(); keyResultsChanges: Subject<{ keyResult: KeyResult; changeId: number | null; objective: Objective; delete: boolean }> = From 6dca4c19d383bd3a438196d6df343ce567c5ba8a Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 10:56:27 +0200 Subject: [PATCH 64/97] format new confirm-dialog which pops up when user tries to delete check-in --- .../confirm-dialog/confirm-dialog.component.html | 4 ++-- .../confirm-dialog/confirm-dialog.component.spec.ts | 2 +- .../confirm-dialog/confirm-dialog.component.ts | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.html b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.html index 659d7811a1..dc62ef17b9 100644 --- a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.html +++ b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.html @@ -1,5 +1,5 @@ -

{{this.data.title}} löschen

-
Soll dieses {{this.data.title}} gelöscht werden?
+

{{ this.data.title }} löschen

+
Soll dieses {{ this.data.title }} gelöscht werden?
diff --git a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts index cf09cfdda0..98cde0d3f6 100644 --- a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts +++ b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts @@ -8,7 +8,7 @@ describe('ConfirmDialogComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [ConfirmDialogComponent] + declarations: [ConfirmDialogComponent], }); fixture = TestBed.createComponent(ConfirmDialogComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.ts b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.ts index 53b83fc80d..d3944267bf 100644 --- a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.ts +++ b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.ts @@ -1,15 +1,16 @@ -import {Component, Inject} from '@angular/core'; -import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; @Component({ selector: 'app-confirm-dialog', templateUrl: './confirm-dialog.component.html', - styleUrls: ['./confirm-dialog.component.scss'] + styleUrls: ['./confirm-dialog.component.scss'], }) export class ConfirmDialogComponent { - constructor(@Inject(MAT_DIALOG_DATA) public data: any, - public dialogRef: MatDialogRef,) { - } + constructor( + @Inject(MAT_DIALOG_DATA) public data: any, + public dialogRef: MatDialogRef, + ) {} closeAndDelete() { this.dialogRef.close(true); From c171ffaf8dc05f3e9e73eda4bcf022e88d097e90 Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 11:30:56 +0200 Subject: [PATCH 65/97] implement endpoint to delete check-in by id --- .../java/ch/puzzle/okr/controller/CheckInController.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/src/main/java/ch/puzzle/okr/controller/CheckInController.java b/backend/src/main/java/ch/puzzle/okr/controller/CheckInController.java index 702684a182..0c316597da 100644 --- a/backend/src/main/java/ch/puzzle/okr/controller/CheckInController.java +++ b/backend/src/main/java/ch/puzzle/okr/controller/CheckInController.java @@ -67,4 +67,13 @@ public ResponseEntity updateCheckIn( CheckInDto updatedCheckIn = this.checkInMapper.toDto(this.checkInBusinessService.updateCheckIn(id, checkIn)); return ResponseEntity.status(HttpStatus.OK).body(updatedCheckIn); } + + @Operation(summary = "Delete Check-in by ID", description = "Delete Check-in by ID") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Deleted Check-in by ID"), + @ApiResponse(responseCode = "404", description = "Did not find the Check-in with requested ID") }) + @DeleteMapping("/{id}") + public void deleteCheckIn( + @Parameter(description = "The ID of an Check-in to delete it.", required = true) @PathVariable long id) { + this.checkInBusinessService.deleteCheckIn(id); + } } From 60d6bd76074090320e314c4e12646195c55e49e9 Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 11:53:29 +0200 Subject: [PATCH 66/97] add okr-tool objectives to bbt --- .../db/data-migration/V2_1_2__newQuarterData.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql b/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql index 406bcdf70f..234fa7d461 100644 --- a/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql +++ b/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql @@ -10,7 +10,8 @@ values (17, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di ga (13, 'Um eine saubere und natürliche Arbeitsumgebung für die Mitarbeiter zu schaffen, richten wir mehr Pflanzen ein.', '2023-10-02 12:53:36.000000', 'Wir wollen mehr Pflanzen in den Puzzle Büros.', 1, 7, 5, 'DRAFT', null, '2023-10-02 08:54:11.000000'), (14, 'Damit wir motivierte Lernende geben wir Ihnen jeden morgen ein gratis Schoggigipfeli.', '2023-10-02 14:55:30.000000', 'Wir wollen motivierte, satte Lernende', 1, 7, 4, 'ONGOING', null, '2023-10-02 08:56:12.000000'), (15, 'Um die Ausgaben für Getränke zu reduzieren, muss der Konsum im BBT reduziert werden.', '2023-10-02 14:57:25.000000', 'Wir wollen unseren Konsum von Süssgetränken und Speisen reduzieren.', 1, 7, 4, 'NOTSUCCESSFUL', null, '2023-10-02 08:58:39.000000'), - (16, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:59:21.000000', 'Das BBT wird zur rentabelsten Division bei Puzzle ITC', 1, 7, 4, 'SUCCESSFUL', null, '2023-10-02 09:00:23.000000'); + (16, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:59:21.000000', 'Das BBT wird zur rentabelsten Division bei Puzzle ITC', 1, 7, 4, 'SUCCESSFUL', null, '2023-10-02 09:00:23.000000'), + (23, 'Mit der Weiterentwiklung wollen wir ein perfektes Tool für das OKR-Framework entwickeln, damit das volle Potential des Frameworks ausgenutzt werden kann.', '2023-10-02 14:59:21.000000', 'The Puzzle OKR Tool will be the best application ever developed by Puzzle ITC', 1, 7, 4, 'ONGOING', null, '2023-10-02 09:00:23.000000'); insert into key_result (id, baseline, description, modified_on, stretch_goal, title, created_by_id, objective_id, owner_id, unit, key_result_type, created_on, commit_zone, target_zone, stretch_zone) @@ -25,7 +26,11 @@ values (20, 0, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed di (28, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Scallywag Spanish Main coxswain brigantine case shot bring a spring upon her cable ', 1, 13, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), (29, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Smartly aye Pieces of Eight hang the jib gun nipperkin Nelsons folly schooner Pirate Round swab', 1, 18, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), (30, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Jack Tar strike colors draft Cat onine tails blow the man down skysail mutiny yawl overhaul bilge', 1, 18, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Commit zone is here', 'Target zone is here', 'Stretch zone is here'), - (31, 9, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 27, 'Rigging tender flogging gun clipper Plate Fleet bowsprit crack Jennys tea cup gunwalls Davy Jones Locker', 1, 20, 1, 'NUMBER', 'metric', '2023-10-02 09:16:07.000000', null, null, null); + (31, 9, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 27, 'Rigging tender flogging gun clipper Plate Fleet bowsprit crack Jennys tea cup gunwalls Davy Jones Locker', 1, 20, 1, 'NUMBER', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (32, null, '', null, null, 'Das OKR-Tool wird zum Vorzeigeprojekt für herrvorragende Usability', 1, 23, 1, null, 'ordinal', '2023-10-02 09:16:07.000000', 'Wenn ein User die Applikation zum ersten mal benutzt, kann dieser ohne nachfragen seine Objectives und Key Results erfassen und scoren', 'Für interne Projekte wird das OKR-Tool als zu erreichender Standard angesehen, wir wollen mindestens 1 Anfrage erhalten, wie wir ein Frontendfeature umgesetzt haben.', 'Das OKR-Tool wird von UX als Beispiel bei mindestens einem Kunde für ein perfektes Usererlebnis verwendet. Weiter richten sich die restlichen internen Projekte (PTime, Cryptopus und PSkills) nach den Icons und Buttonhirarchien, welche in unserem OKR-Tool implementiert sind.'), + (33, 3, 'Sonar untersucht den Code auf unsaubere Methoden (schlechte performance, security issues), und auf Code, welcher potentiell Bugs herbeiführen kann, dabei erstellt Sonar ein Rating mit 5 stufen, wobei E die schlechteste Stufe ist und A die beste.', null, 5, 'Das OKR-Tool verbessert den Sonar Bugscore von C auf A', 1, 23, 1, 'Sonar Skala von E bis A', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (34, null, 'Um zukünftige Wartungsarbeiten oder Weiterentwicklungen am Tool sauber auszuführen und um die Funktionalität des Tools sicherzustellen, wird die Applikation mit verschieden Testsgetestet.', null, null, 'Das OKR-Tool weisst eine ausgezeichnete Testabdenkung auf', 1, 23, 1, null, 'ordinal', '2023-10-02 09:16:07.000000', 'Unit Tests erreichen eine Testabdekung von 80% auf den Methoden und 80% auf den Branches, Controller sind mit IntegrationsTests getestet, einfache EndToEnd Tests sind mit Cypress umgesetzt.', 'Unit Tests erreichen eine Testabdekung von 80% auf Methoden und Branches, Controller sind mit Integrationstests getestet und EndToEnd Tests, testen Rollenspezifisch die verschiedenen Ansichten der Applikation durch.', 'Unit Tests erreichen eine Testabdekung von 85% auf Branches und Methoden, Controller sind zu 100% mit Integrationstests getestet, EndToEnd Tests, testen für jede Rolle, jede Ansicht, ausserdem überprüffen die End2End tests, ob jeweils die Richtigen ereignisse geschehen wenn eine Aktion ausgeführt wird.'), + (35, null, 'Der erleichterte Umgang mit dem OKR-Framework soll weitere Members dazu Anregen, das Framework von OKRs zu nutzen.', null, null, 'Unser Tool macht das OKR-Framework beliebter', 1, 23, 1, null, 'ordinal', '2023-10-02 09:16:07.000000', 'Mindestens ein Team von Puzzle, welches bis lang nicht am OKR-Framework teilnimmt, wird dank dem Tool neu auch am OKR Teilnehmen. Wir finden dies heraus anhand von Nachfragen wenn neue Teams dazustossen.', 'Alle Teams von Puzzle nehmen am OKR-Framework Teil.', 'Alle Teams von Puzzle nehmen am OKR-Framework Teil, zusätzlich haben wir mindestens eine externe Anfrage für unser Tool.'); insert into check_in (id, change_info, created_on, initiatives, modified_on, value_metric, created_by_id, key_result_id, confidence, check_in_type, zone) values (21, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', 150, 1, 20, 10, 'metric', null), From 3d10e3fb5beba93365b763e5b00bc2b01360cfc2 Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 13:11:54 +0200 Subject: [PATCH 67/97] implement updating logic after check-in has been deleted --- .../keyresult-detail.component.html | 9 +++++++-- .../keyresult-detail/keyresult-detail.component.ts | 14 +++++++++++--- .../check-in-history-dialog.component.ts | 9 ++++++--- .../src/app/shared/services/notifier.service.ts | 6 ++++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.html b/frontend/src/app/keyresult-detail/keyresult-detail.component.html index c8d2425d8a..6fb1fc098f 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.html +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.html @@ -18,7 +18,12 @@

{{ keyResult.title }}

Confidence

- +
@@ -62,7 +67,7 @@

{{ keyResult.lastCheckIn?.changeInfo }}

- +
diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 18a2eb3cd3..fc5acf26b7 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -29,15 +29,24 @@ export class KeyresultDetailComponent implements OnChanges { private dialog: MatDialog, ) { this.notifierService.reopenCheckInHistoryDialog.subscribe((result) => { - if (this.keyResult.lastCheckIn?.id === result?.id) { - this.keyResult = { ...this.keyResult, lastCheckIn: result }; + /* LastCheckIn has been updated */ + if (this.keyResult.lastCheckIn?.id === result?.checkIn?.id) { + this.keyResult = { ...this.keyResult, lastCheckIn: result.checkIn }; this.changeDetectorRef.detectChanges(); } + /* CheckIn was deleted */ + if (result.deleted) { + this.fetchKeyResult(); + } this.checkInHistory(); }); } ngOnChanges() { + this.fetchKeyResult(); + } + + fetchKeyResult() { this.keyResultService.getFullKeyResult(this.keyResultId).subscribe((fullKeyResult) => { this.keyResult = fullKeyResult; this.changeDetectorRef.markForCheck(); @@ -59,7 +68,6 @@ export class KeyresultDetailComponent implements OnChanges { keyResult: this.keyResult, }, }); - dialogRef.afterClosed().subscribe(() => {}); } diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts index 8e2c08f9e8..a68dd05e08 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts @@ -45,7 +45,7 @@ export class CheckInHistoryDialogComponent implements OnInit { if (result.data !== undefined && result.data !== null) { let updatedCheckIn = { ...result.data, id: checkIn.id }; this.checkInService.updateCheckIn(updatedCheckIn, updatedCheckIn.id).subscribe((updatedCheckIn) => { - this.notifierService.reopenCheckInHistoryDialog.next(updatedCheckIn); + this.notifierService.reopenCheckInHistoryDialog.next({ checkIn: updatedCheckIn, deleted: false }); }); } }); @@ -60,9 +60,12 @@ export class CheckInHistoryDialogComponent implements OnInit { }); dialogRef.afterClosed().subscribe((result) => { if (result) { - this.checkInService.deleteCheckIn(checkIn.id).subscribe(); + this.checkInService.deleteCheckIn(checkIn.id).subscribe(() => { + this.notifierService.reopenCheckInHistoryDialog.next({ checkIn: null, deleted: true }); + }); + } else { + this.notifierService.reopenCheckInHistoryDialog.next({ checkIn: null, deleted: false }); } - this.notifierService.reopenCheckInHistoryDialog.next(null); }); } diff --git a/frontend/src/app/shared/services/notifier.service.ts b/frontend/src/app/shared/services/notifier.service.ts index eef65578b8..2b075abdef 100644 --- a/frontend/src/app/shared/services/notifier.service.ts +++ b/frontend/src/app/shared/services/notifier.service.ts @@ -9,8 +9,10 @@ import { Objective } from '../types/model/Objective'; }) export class NotifierService { closeDetailSubject: Subject = new Subject(); - reopenCheckInHistoryDialog: Subject = new Subject(); - reopenCheckInDialog: Subject = new Subject(); + reopenCheckInHistoryDialog: Subject<{ checkIn: CheckIn | null; deleted: boolean }> = new Subject<{ + checkIn: CheckIn | null; + deleted: boolean; + }>(); keyResultsChanges: Subject<{ keyResult: KeyResult; changeId: number | null; objective: Objective; delete: boolean }> = new Subject<{ From c89fcad2608b152e862e1784cb3bf0127bf2bf4c Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 14:08:13 +0200 Subject: [PATCH 68/97] fix error of post not working when there are no check-ins and optimize sql data file --- .../data-migration/V2_1_2__newQuarterData.sql | 213 ++++++++++++++---- .../check-in-form/check-in-form.component.ts | 13 +- 2 files changed, 178 insertions(+), 48 deletions(-) diff --git a/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql b/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql index 234fa7d461..d649876aad 100644 --- a/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql +++ b/backend/src/main/resources/db/data-migration/V2_1_2__newQuarterData.sql @@ -1,47 +1,170 @@ -insert into objective (id, description, modified_on, title, created_by_id, quarter_id, team_id, state, modified_by_id, created_on) -values (17, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:01:50.000000', 'Unsere Mockups werden zu den Besten der Schweiz', 1, 7, 8, 'NOTSUCCESSFUL', null, '2023-10-02 09:02:38.000000'), - (18, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:03:01.000000', 'Wir pflegen eine offene Kommunikation mit den Entwicklern.', 1, 7, 8, 'DRAFT', null, '2023-10-02 09:03:44.000000'), - (19, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 15:04:02.000000', 'Wir verwenden ausschliesslich Angular Material in unseren Designs.', 1, 7, 8, 'NOTSUCCESSFUL', null, '2023-10-02 09:05:17.000000'), - (20, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 15:05:57.000000', 'Loremsen Inud di doro sim guru', 1, 7, 6, 'SUCCESSFUL', null, '2023-10-02 09:06:41.000000'), - (21, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 13:07:09.000000', 'Ting Tang Wala Wala Bing Bang', 1, 7, 6, 'SUCCESSFUL', null, '2023-10-02 09:07:39.000000'), - (22, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 13:07:56.000000', 'Wing Wang Tala Tala Ting Tang', 1, 7, 6, 'NOTSUCCESSFUL', null, '2023-10-02 09:08:40.000000'), - (11, 'Damit wir effizienter und besser zusammenarbeiten, müssen wir den Teamzusammenhalt stärken', '2023-10-02 13:49:39.000000', 'Wir wollen die Zusammenarbeit im Team steigern.', 1, 7, 5, 'ONGOING', null, '2023-10-02 08:49:29.000000'), - (12, 'Um die Löhne unserer Mitarbeiter zu erhöhen müssen wir mehr Umsatz machen', '2023-10-02 10:51:02.000000', 'Wir wollen mehr Umsatz machen.', 1, 7, 5, 'DRAFT', null, '2023-10-02 08:51:40.000000'), - (13, 'Um eine saubere und natürliche Arbeitsumgebung für die Mitarbeiter zu schaffen, richten wir mehr Pflanzen ein.', '2023-10-02 12:53:36.000000', 'Wir wollen mehr Pflanzen in den Puzzle Büros.', 1, 7, 5, 'DRAFT', null, '2023-10-02 08:54:11.000000'), - (14, 'Damit wir motivierte Lernende geben wir Ihnen jeden morgen ein gratis Schoggigipfeli.', '2023-10-02 14:55:30.000000', 'Wir wollen motivierte, satte Lernende', 1, 7, 4, 'ONGOING', null, '2023-10-02 08:56:12.000000'), - (15, 'Um die Ausgaben für Getränke zu reduzieren, muss der Konsum im BBT reduziert werden.', '2023-10-02 14:57:25.000000', 'Wir wollen unseren Konsum von Süssgetränken und Speisen reduzieren.', 1, 7, 4, 'NOTSUCCESSFUL', null, '2023-10-02 08:58:39.000000'), - (16, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:59:21.000000', 'Das BBT wird zur rentabelsten Division bei Puzzle ITC', 1, 7, 4, 'SUCCESSFUL', null, '2023-10-02 09:00:23.000000'), - (23, 'Mit der Weiterentwiklung wollen wir ein perfektes Tool für das OKR-Framework entwickeln, damit das volle Potential des Frameworks ausgenutzt werden kann.', '2023-10-02 14:59:21.000000', 'The Puzzle OKR Tool will be the best application ever developed by Puzzle ITC', 1, 7, 4, 'ONGOING', null, '2023-10-02 09:00:23.000000'); +insert into public.objective (id, description, modified_on, title, created_by_id, quarter_id, team_id, state, + modified_by_id, created_on) +values (19, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 15:04:02.000000', + 'Wir verwenden ausschliesslich Angular Material in unseren Designs.', 1, 7, 8, 'NOTSUCCESSFUL', null, + '2023-10-02 09:05:17.000000'), + (20, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 15:05:57.000000', + 'Loremsen Inud di doro sim guru', 1, 7, 6, 'SUCCESSFUL', null, '2023-10-02 09:06:41.000000'), + (11, 'Damit wir effizienter und besser zusammenarbeiten, müssen wir den Teamzusammenhalt stärken', + '2023-10-02 13:49:39.000000', 'Wir wollen die Zusammenarbeit im Team steigern.', 1, 7, 5, 'ONGOING', null, + '2023-10-02 08:49:29.000000'), + (14, 'Damit wir motivierte Lernende geben wir Ihnen jeden morgen ein gratis Schoggigipfeli.', + '2023-10-02 14:55:30.000000', 'Wir wollen motivierte, satte Lernende', 1, 7, 4, 'ONGOING', null, + '2023-10-02 08:56:12.000000'), + (15, 'Um die Ausgaben für Getränke zu reduzieren, muss der Konsum im BBT reduziert werden.', + '2023-10-02 14:57:25.000000', 'Wir wollen unseren Konsum von Süssgetränken und Speisen reduzieren.', 1, 7, 4, + 'NOTSUCCESSFUL', null, '2023-10-02 08:58:39.000000'), + (23, + 'Mit der Weiterentwiklung wollen wir ein perfektes Tool für das OKR-Framework entwickeln, damit das volle Potential des Frameworks ausgenutzt werden kann.', + '2023-10-02 14:59:21.000000', 'The Puzzle OKR Tool will be the best application ever developed by Puzzle ITC', + 1, 7, 4, 'ONGOING', null, '2023-10-02 09:00:23.000000'), + (17, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:01:50.000000', + 'Unsere Mockups werden zu den Besten der Schweiz', 1, 7, 8, 'DRAFT', null, '2023-10-02 09:02:38.000000'), + (18, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 14:03:01.000000', + 'Wir pflegen eine offene Kommunikation mit den Entwicklern.', 1, 7, 8, 'NOTSUCCESSFUL', null, + '2023-10-02 09:03:44.000000'), + (12, 'Um die Löhne unserer Mitarbeiter zu erhöhen müssen wir mehr Umsatz machen', '2023-10-02 10:51:02.000000', + 'Wir wollen mehr Umsatz machen.', 1, 7, 5, 'ONGOING', null, '2023-10-02 08:51:40.000000'), + (13, + 'Um eine saubere und natürliche Arbeitsumgebung für die Mitarbeiter zu schaffen, richten wir mehr Pflanzen ein.', + '2023-10-02 12:53:36.000000', 'Wir wollen mehr Pflanzen in den Puzzle Büros.', 1, 7, 5, 'ONGOING', null, + '2023-10-02 08:54:11.000000'), + (22, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 13:07:56.000000', + 'Wing Wang Tala Tala Ting Tang', 1, 7, 6, 'DRAFT', null, '2023-10-02 09:08:40.000000'), + (21, 'Lorem Ipsum sit amet diri guru humu saguri alam apmach helum di gau', '2023-10-02 13:07:09.000000', + 'Ting Tang Wala Wala Bing Bang', 1, 7, 6, 'DRAFT', null, '2023-10-02 09:07:39.000000'); +insert into key_result (id, baseline, description, modified_on, stretch_goal, title, created_by_id, objective_id, + owner_id, unit, key_result_type, created_on, commit_zone, target_zone, stretch_zone) +values (20, 0, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', 150, + 'Prow scuttle parrel provost Sail ho shrouds spirits boom mizzenmast yardarm.', 1, 11, 1, 'PERCENT', 'metric', + '2023-10-02 09:16:07.000000', null, null, null), + (21, null, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', null, + 'Clap of thunder bilge aft log crows nest landlubber or just lubber overhaul', 1, 11, 1, '', 'ordinal', + '2023-10-02 09:16:07.000000', 'This is the commit zone', 'This is the target zone', 'This is the stretch zone'), + (22, 40, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', 300, 'Scourge of the seven seas blow the man down provost hail-shot Yellow Jack', + 1, 11, 1, 'PERCENT', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (23, 1050, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', 5000, + 'Sea Legs hogshead yardarm Pieces of Eight boatswain jack mizzen tack belay ballast', 1, 12, 1, 'NUMBER', + 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (24, 50, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', 100, 'Parrel Shiver me timbers lanyard crows nest fluke gun skysail no prey', 1, + 12, 1, 'CHF', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (25, 15, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', 45, 'Driver jack hempen halter poop deck bucko broadside me', 1, 12, 1, 'FTE', + 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (26, null, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', null, + 'Hornswaggle hands rum Gold Road lugsail spanker Davy Jones Locker pressgang ', 1, 13, 1, '', 'ordinal', + '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', + 'Reached stretch zone here'), + (27, null, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', null, + 'Black spot bilge booty marooned Davy Jones Locker rum scourge of the seven seas Sink ', 1, 13, 1, '', + 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', + 'Reached stretch zone here'), + (28, null, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', null, + 'Scallywag Spanish Main coxswain brigantine case shot bring a spring upon her cable ', 1, 13, 1, '', 'ordinal', + '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', + 'Reached stretch zone here'), + (29, null, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', null, + 'Smartly aye Pieces of Eight hang the jib gun nipperkin Nelsons folly schooner Pirate Round swab', 1, 18, 1, '', + 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', + 'Reached stretch zone here'), + (30, null, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', null, + 'Jack Tar strike colors draft Cat onine tails blow the man down skysail mutiny yawl overhaul bilge', 1, 18, 1, + '', 'ordinal', '2023-10-02 09:16:07.000000', 'Commit zone is here', 'Target zone is here', + 'Stretch zone is here'), + (31, 9, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', + '2023-10-02 13:15:22.000000', 27, + 'Rigging tender flogging gun clipper Plate Fleet bowsprit crack Jennys tea cup gunwalls Davy Jones Locker', 1, + 20, 1, 'NUMBER', 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (32, null, '', null, null, 'Das OKR-Tool wird zum Vorzeigeprojekt für herrvorragende Usability', 1, 23, 1, null, + 'ordinal', '2023-10-02 09:16:07.000000', + 'Wenn ein User die Applikation zum ersten mal benutzt, kann dieser ohne nachfragen seine Objectives und Key Results erfassen und scoren', + 'Für interne Projekte wird das OKR-Tool als zu erreichender Standard angesehen, wir wollen mindestens 1 Anfrage erhalten, wie wir ein Frontendfeature umgesetzt haben.', + 'Das OKR-Tool wird von UX als Beispiel bei mindestens einem Kunde für ein perfektes Usererlebnis verwendet. Weiter richten sich die restlichen internen Projekte (PTime, Cryptopus und PSkills) nach den Icons und Buttonhirarchien, welche in unserem OKR-Tool implementiert sind.'), + (33, 3, + 'Sonar untersucht den Code auf unsaubere Methoden (schlechte performance, security issues), und auf Code, welcher potentiell Bugs herbeiführen kann, dabei erstellt Sonar ein Rating mit 5 stufen, wobei E die schlechteste Stufe ist und A die beste.', + null, 5, 'Das OKR-Tool verbessert den Sonar Bugscore von C auf A', 1, 23, 1, 'Sonar Skala von E bis A', + 'metric', '2023-10-02 09:16:07.000000', null, null, null), + (34, null, + 'Um zukünftige Wartungsarbeiten oder Weiterentwicklungen am Tool sauber auszuführen und um die Funktionalität des Tools sicherzustellen, wird die Applikation mit verschieden Testsgetestet.', + null, null, 'Das OKR-Tool weisst eine ausgezeichnete Testabdenkung auf', 1, 23, 1, null, 'ordinal', + '2023-10-02 09:16:07.000000', + 'Unit Tests erreichen eine Testabdekung von 80% auf den Methoden und 80% auf den Branches, Controller sind mit IntegrationsTests getestet, einfache EndToEnd Tests sind mit Cypress umgesetzt.', + 'Unit Tests erreichen eine Testabdekung von 80% auf Methoden und Branches, Controller sind mit Integrationstests getestet und EndToEnd Tests, testen Rollenspezifisch die verschiedenen Ansichten der Applikation durch.', + 'Unit Tests erreichen eine Testabdekung von 85% auf Branches und Methoden, Controller sind zu 100% mit Integrationstests getestet, EndToEnd Tests, testen für jede Rolle, jede Ansicht, ausserdem überprüffen die End2End tests, ob jeweils die Richtigen ereignisse geschehen wenn eine Aktion ausgeführt wird.'), + (35, null, + 'Der erleichterte Umgang mit dem OKR-Framework soll weitere Members dazu Anregen, das Framework von OKRs zu nutzen.', + null, null, 'Unser Tool macht das OKR-Framework beliebter', 1, 23, 1, null, 'ordinal', + '2023-10-02 09:16:07.000000', + 'Mindestens ein Team von Puzzle, welches bis lang nicht am OKR-Framework teilnimmt, wird dank dem Tool neu auch am OKR Teilnehmen. Wir finden dies heraus anhand von Nachfragen wenn neue Teams dazustossen.', + 'Alle Teams von Puzzle nehmen am OKR-Framework Teil.', + 'Alle Teams von Puzzle nehmen am OKR-Framework Teil, zusätzlich haben wir mindestens eine externe Anfrage für unser Tool.'); -insert into key_result (id, baseline, description, modified_on, stretch_goal, title, created_by_id, objective_id, owner_id, unit, key_result_type, created_on, commit_zone, target_zone, stretch_zone) -values (20, 0, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 150, 'Prow scuttle parrel provost Sail ho shrouds spirits boom mizzenmast yardarm.', 1, 11, 1, 'PERCENT', 'metric', '2023-10-02 09:16:07.000000', null, null, null), - (21, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Clap of thunder bilge aft log crows nest landlubber or just lubber overhaul', 1, 11, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'This is the commit zone', 'This is the target zone', 'This is the stretch zone'), - (22, 40, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 300, 'Scourge of the seven seas blow the man down provost hail-shot Yellow Jack', 1, 11, 1, 'PERCENT', 'metric', '2023-10-02 09:16:07.000000', null, null, null), - (23, 1050, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 5000, 'Sea Legs hogshead yardarm Pieces of Eight boatswain jack mizzen tack belay ballast', 1, 12, 1, 'NUMBER', 'metric', '2023-10-02 09:16:07.000000', null, null, null), - (24, 50, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 100, 'Parrel Shiver me timbers lanyard crows nest fluke gun skysail no prey', 1, 12, 1, 'CHF', 'metric', '2023-10-02 09:16:07.000000', null, null, null), - (25, 15, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 45, 'Driver jack hempen halter poop deck bucko broadside me', 1, 12, 1, 'FTE', 'metric', '2023-10-02 09:16:07.000000', null, null, null), - (26, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Hornswaggle hands rum Gold Road lugsail spanker Davy Jones Locker pressgang ', 1, 13, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), - (27, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Black spot bilge booty marooned Davy Jones Locker rum scourge of the seven seas Sink ', 1, 13, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), - (28, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Scallywag Spanish Main coxswain brigantine case shot bring a spring upon her cable ', 1, 13, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), - (29, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Smartly aye Pieces of Eight hang the jib gun nipperkin Nelsons folly schooner Pirate Round swab', 1, 18, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Reached commit zone here', 'Reached target zone here', 'Reached stretch zone here'), - (30, null, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', null, 'Jack Tar strike colors draft Cat onine tails blow the man down skysail mutiny yawl overhaul bilge', 1, 18, 1, '', 'ordinal', '2023-10-02 09:16:07.000000', 'Commit zone is here', 'Target zone is here', 'Stretch zone is here'), - (31, 9, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lore', '2023-10-02 13:15:22.000000', 27, 'Rigging tender flogging gun clipper Plate Fleet bowsprit crack Jennys tea cup gunwalls Davy Jones Locker', 1, 20, 1, 'NUMBER', 'metric', '2023-10-02 09:16:07.000000', null, null, null), - (32, null, '', null, null, 'Das OKR-Tool wird zum Vorzeigeprojekt für herrvorragende Usability', 1, 23, 1, null, 'ordinal', '2023-10-02 09:16:07.000000', 'Wenn ein User die Applikation zum ersten mal benutzt, kann dieser ohne nachfragen seine Objectives und Key Results erfassen und scoren', 'Für interne Projekte wird das OKR-Tool als zu erreichender Standard angesehen, wir wollen mindestens 1 Anfrage erhalten, wie wir ein Frontendfeature umgesetzt haben.', 'Das OKR-Tool wird von UX als Beispiel bei mindestens einem Kunde für ein perfektes Usererlebnis verwendet. Weiter richten sich die restlichen internen Projekte (PTime, Cryptopus und PSkills) nach den Icons und Buttonhirarchien, welche in unserem OKR-Tool implementiert sind.'), - (33, 3, 'Sonar untersucht den Code auf unsaubere Methoden (schlechte performance, security issues), und auf Code, welcher potentiell Bugs herbeiführen kann, dabei erstellt Sonar ein Rating mit 5 stufen, wobei E die schlechteste Stufe ist und A die beste.', null, 5, 'Das OKR-Tool verbessert den Sonar Bugscore von C auf A', 1, 23, 1, 'Sonar Skala von E bis A', 'metric', '2023-10-02 09:16:07.000000', null, null, null), - (34, null, 'Um zukünftige Wartungsarbeiten oder Weiterentwicklungen am Tool sauber auszuführen und um die Funktionalität des Tools sicherzustellen, wird die Applikation mit verschieden Testsgetestet.', null, null, 'Das OKR-Tool weisst eine ausgezeichnete Testabdenkung auf', 1, 23, 1, null, 'ordinal', '2023-10-02 09:16:07.000000', 'Unit Tests erreichen eine Testabdekung von 80% auf den Methoden und 80% auf den Branches, Controller sind mit IntegrationsTests getestet, einfache EndToEnd Tests sind mit Cypress umgesetzt.', 'Unit Tests erreichen eine Testabdekung von 80% auf Methoden und Branches, Controller sind mit Integrationstests getestet und EndToEnd Tests, testen Rollenspezifisch die verschiedenen Ansichten der Applikation durch.', 'Unit Tests erreichen eine Testabdekung von 85% auf Branches und Methoden, Controller sind zu 100% mit Integrationstests getestet, EndToEnd Tests, testen für jede Rolle, jede Ansicht, ausserdem überprüffen die End2End tests, ob jeweils die Richtigen ereignisse geschehen wenn eine Aktion ausgeführt wird.'), - (35, null, 'Der erleichterte Umgang mit dem OKR-Framework soll weitere Members dazu Anregen, das Framework von OKRs zu nutzen.', null, null, 'Unser Tool macht das OKR-Framework beliebter', 1, 23, 1, null, 'ordinal', '2023-10-02 09:16:07.000000', 'Mindestens ein Team von Puzzle, welches bis lang nicht am OKR-Framework teilnimmt, wird dank dem Tool neu auch am OKR Teilnehmen. Wir finden dies heraus anhand von Nachfragen wenn neue Teams dazustossen.', 'Alle Teams von Puzzle nehmen am OKR-Framework Teil.', 'Alle Teams von Puzzle nehmen am OKR-Framework Teil, zusätzlich haben wir mindestens eine externe Anfrage für unser Tool.'); - -insert into check_in (id, change_info, created_on, initiatives, modified_on, value_metric, created_by_id, key_result_id, confidence, check_in_type, zone) - values (21, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', 150, 1, 20, 10, 'metric', null), -(22, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', null, 1, 21, 4, 'ordinal', 'FAIL'), -(23, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', 200, 1, 22, 6, 'metric', null), -(24, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 08:50:44.059000', 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', '2023-10-02 22:00:00.000000', 200, 1, 23, 1, 'metric', null), -(25, 'Lorem ipsum dolor sit amet', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', 75, 1, 24, 2, 'metric', ''), -(26, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', 70, 1, 25, 9, 'metric', null), -(27, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 26, 6, 'ordinal', 'COMMIT'), -(28, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 27, 8, 'ordinal', 'TARGET'), -(29, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 28, 8, 'ordinal', 'STRETCH'), -(30, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 29, 10, 'ordinal', 'STRETCH'), -(31, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', null, 1, 30, 2, 'ordinal', 'FAIL'), -(32, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', 13, 1, 31, 3, 'metric', null); \ No newline at end of file +insert into check_in (id, change_info, created_on, initiatives, modified_on, value_metric, created_by_id, key_result_id, + confidence, check_in_type, zone) +values (21, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', + '2023-10-02 08:50:44.059000', + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', + '2023-10-02 22:00:00.000000', 150, 1, 20, 10, 'metric', null), + (22, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', + '2023-10-02 08:50:44.059000', + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', + '2023-10-02 22:00:00.000000', null, 1, 21, 4, 'ordinal', 'FAIL'), + (23, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', + '2023-10-02 08:50:44.059000', + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', + '2023-10-02 22:00:00.000000', 200, 1, 22, 6, 'metric', null), + (24, + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', + '2023-10-02 08:50:44.059000', + 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores ', + '2023-10-02 22:00:00.000000', 200, 1, 23, 1, 'metric', null), + (25, 'Lorem ipsum dolor sit amet', '2023-10-02 08:50:44.059000', + ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', + 75, 1, 24, 2, 'metric', ''), + (26, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', + ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', + 70, 1, 25, 9, 'metric', null), + (27, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', + ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', + null, 1, 26, 6, 'ordinal', 'COMMIT'), + (28, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', + ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', + null, 1, 27, 8, 'ordinal', 'TARGET'), + (29, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', + ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', + null, 1, 28, 8, 'ordinal', 'STRETCH'), + (30, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', + ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', + null, 1, 29, 10, 'ordinal', 'STRETCH'), + (31, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', + ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', + null, 1, 30, 2, 'ordinal', 'FAIL'), + (32, 'Lorem ipsum dolor sit amet, richi rogsi brokilon', '2023-10-02 08:50:44.059000', + ' sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat', '2023-10-02 22:00:00.000000', + 13, 1, 31, 3, 'metric', null); \ No newline at end of file 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 8c0f6314cf..99f0931711 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 @@ -13,7 +13,7 @@ import { CheckInMin } from '../../../types/model/CheckInMin'; }) export class CheckInFormComponent { keyResult: KeyResult; - checkIn: CheckInMin; + checkIn: CheckInMin = { confidence: 5 } as CheckInMin; currentDate: Date; continued: boolean = false; @@ -30,7 +30,7 @@ export class CheckInFormComponent { ) { this.currentDate = new Date(); this.keyResult = data.keyResult; - this.checkIn = data.checkIn === undefined ? this.keyResult.lastCheckIn : data.checkIn; + this.setCheckIn(); this.setDefaultValues(); } @@ -48,7 +48,6 @@ export class CheckInFormComponent { } saveCheckIn() { - console.log(this.checkIn); this.dialogForm.controls.confidence.setValue(this.checkIn.confidence); let checkIn: any = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; if (this.keyResult.keyResultType === 'metric') { @@ -68,4 +67,12 @@ export class CheckInFormComponent { getKeyResultOrdinal(): KeyResultOrdinal { return this.keyResult as KeyResultOrdinal; } + + setCheckIn() { + if (this.data.checkIn != null) { + this.checkIn = this.data.checkIn; + } else if (this.keyResult.lastCheckIn != null) { + this.checkIn = this.keyResult.lastCheckIn!; + } + } } From d5955f30865a8a1492bb6741e89adfbaa9875042 Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 14:26:27 +0200 Subject: [PATCH 69/97] prevent check-in history from opening if no other check-in exists after delete --- .../keyresult-detail.component.ts | 15 ++++++++++----- .../check-in-history-dialog.component.ts | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index fc5acf26b7..3e57fed3fb 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -36,17 +36,22 @@ export class KeyresultDetailComponent implements OnChanges { } /* CheckIn was deleted */ if (result.deleted) { - this.fetchKeyResult(); + if (result.checkIn?.id == this.keyResult.lastCheckIn?.id) { + this.keyResultService.getFullKeyResult(this.keyResultId).subscribe((fullKeyResult) => { + this.keyResult = fullKeyResult; + this.changeDetectorRef.markForCheck(); + if (this.keyResult.lastCheckIn != null) { + this.checkInHistory(); + } + }); + } + return; } this.checkInHistory(); }); } ngOnChanges() { - this.fetchKeyResult(); - } - - fetchKeyResult() { this.keyResultService.getFullKeyResult(this.keyResultId).subscribe((fullKeyResult) => { this.keyResult = fullKeyResult; this.changeDetectorRef.markForCheck(); diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts index a68dd05e08..f3b311fa98 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.ts @@ -8,6 +8,7 @@ import { KeyResult } from '../../types/model/KeyResult'; import { CheckInFormComponent } from '../checkin/check-in-form/check-in-form.component'; import { NotifierService } from '../../services/notifier.service'; import { ConfirmDialogComponent } from '../confirm-dialog/confirm-dialog.component'; +import { CheckIn } from '../../types/model/CheckIn'; @Component({ selector: 'app-check-in-history-dialog', @@ -61,7 +62,7 @@ export class CheckInHistoryDialogComponent implements OnInit { dialogRef.afterClosed().subscribe((result) => { if (result) { this.checkInService.deleteCheckIn(checkIn.id).subscribe(() => { - this.notifierService.reopenCheckInHistoryDialog.next({ checkIn: null, deleted: true }); + this.notifierService.reopenCheckInHistoryDialog.next({ checkIn: checkIn as CheckIn, deleted: true }); }); } else { this.notifierService.reopenCheckInHistoryDialog.next({ checkIn: null, deleted: false }); From 0093462e6ad27f49efa4a63fbae4dbf687d9b60a Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 15:27:00 +0200 Subject: [PATCH 70/97] set value of ordinal by default to fail --- .../check-in-form-ordinal.component.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts index ce4b89342b..2d62e0f75d 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; import { Zone } from '../../../types/enums/Zone'; @@ -9,7 +9,7 @@ import { CheckInMin } from '../../../types/model/CheckInMin'; templateUrl: './check-in-form-ordinal.component.html', styleUrls: ['./check-in-form-ordinal.component.scss'], }) -export class CheckInFormOrdinalComponent { +export class CheckInFormOrdinalComponent implements OnInit { @Input() keyResult!: KeyResultOrdinal; @Input() @@ -17,4 +17,10 @@ export class CheckInFormOrdinalComponent { @Input() dialogForm!: FormGroup; protected readonly Zone = Zone; + + ngOnInit(): void { + if (this.dialogForm.controls['value'].value == '') { + this.dialogForm.controls['value'].setValue(Zone.FAIL); + } + } } From 44446c423ef873a70b645c8358e1ae3af3eb3217 Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 15:36:59 +0200 Subject: [PATCH 71/97] optimize imports in confidence component --- frontend/src/app/confidence/confidence.component.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/src/app/confidence/confidence.component.ts b/frontend/src/app/confidence/confidence.component.ts index f477643f38..30e037816c 100644 --- a/frontend/src/app/confidence/confidence.component.ts +++ b/frontend/src/app/confidence/confidence.component.ts @@ -1,7 +1,5 @@ import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core'; -import { KeyresultMin } from '../shared/types/model/KeyresultMin'; import { CheckInMin } from '../shared/types/model/CheckInMin'; -import { KeyResult } from '../shared/types/model/KeyResult'; @Component({ selector: 'app-confidence', From 2b81cb82f2444cd0dad05b6c998ccc49ddae0b9f Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 16:05:48 +0200 Subject: [PATCH 72/97] rewrite comments --- .../src/app/keyresult-detail/keyresult-detail.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts index 3e57fed3fb..032eb08439 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.ts +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.ts @@ -29,12 +29,12 @@ export class KeyresultDetailComponent implements OnChanges { private dialog: MatDialog, ) { this.notifierService.reopenCheckInHistoryDialog.subscribe((result) => { - /* LastCheckIn has been updated */ + /* Update lastCheckIn if it was changed in history dialog */ if (this.keyResult.lastCheckIn?.id === result?.checkIn?.id) { this.keyResult = { ...this.keyResult, lastCheckIn: result.checkIn }; this.changeDetectorRef.detectChanges(); } - /* CheckIn was deleted */ + /* Update lastCheckIn to null if it was deleted in history dialog */ if (result.deleted) { if (result.checkIn?.id == this.keyResult.lastCheckIn?.id) { this.keyResultService.getFullKeyResult(this.keyResultId).subscribe((fullKeyResult) => { From 09dd5a888bd25b8c8de870531bc4a68c6d9ec58c Mon Sep 17 00:00:00 2001 From: megli2 Date: Mon, 2 Oct 2023 16:13:06 +0200 Subject: [PATCH 73/97] fix backend tests --- .../src/test/java/ch/puzzle/okr/KeyResultTestHelpers.java | 5 +++-- .../java/ch/puzzle/okr/controller/KeyResultControllerIT.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/test/java/ch/puzzle/okr/KeyResultTestHelpers.java b/backend/src/test/java/ch/puzzle/okr/KeyResultTestHelpers.java index fa00e18fcb..265ddb11f9 100644 --- a/backend/src/test/java/ch/puzzle/okr/KeyResultTestHelpers.java +++ b/backend/src/test/java/ch/puzzle/okr/KeyResultTestHelpers.java @@ -7,6 +7,7 @@ import ch.puzzle.okr.models.User; import ch.puzzle.okr.models.checkin.CheckIn; import ch.puzzle.okr.models.checkin.CheckInMetric; +import ch.puzzle.okr.models.checkin.Zone; import ch.puzzle.okr.models.keyresult.KeyResult; import ch.puzzle.okr.models.keyresult.KeyResultMetric; import ch.puzzle.okr.models.keyresult.KeyResultOrdinal; @@ -32,7 +33,7 @@ public class KeyResultTestHelpers { public static final String TARGET_ZONE = "Ein Baum"; public static final String STRETCH_ZONE = "Ein Wald"; public static final String QUARTER_LABEL = "GJ 22/23-Q4"; - public static final String LAST_CHECK_IN_ZONE = "Baum"; + public static final Zone LAST_CHECK_IN_ZONE = Zone.COMMIT; public static final String FIRSTNAME = "Johnny"; public static final String LASTNAME = "Appleseed"; public static final String START_DATE = "-999999999-01-01"; @@ -56,7 +57,7 @@ public class KeyResultTestHelpers { public static final String JSON_PATH_TARGET_ZONE = "$.targetZone"; public static final String JSON_PATH_STRETCH_ZONE = "$.stretchZone"; public static final String JSON_PATH_LAST_CHECK_IN_ID = "$.lastCheckIn.id"; - public static final String JSON_PATH_LAST_CHECK_IN_ZONE = "$.lastCheckIn.zone"; + public static final String JSON_PATH_LAST_CHECK_IN_ZONE = "$.lastCheckIn.value"; public static final String JSON_PATH_QUARTER_LABEL = "$.objective.keyResultQuarterDto.label"; public static final String JSON_PATH_QUARTER_START_DATE = "$.objective.keyResultQuarterDto.startDate"; public static final String JSON = "{\"title\": \"Keyresult 1\",\"keyResultType\": \"metric\"}"; diff --git a/backend/src/test/java/ch/puzzle/okr/controller/KeyResultControllerIT.java b/backend/src/test/java/ch/puzzle/okr/controller/KeyResultControllerIT.java index 95c8ebcdb1..0732ab2b5a 100644 --- a/backend/src/test/java/ch/puzzle/okr/controller/KeyResultControllerIT.java +++ b/backend/src/test/java/ch/puzzle/okr/controller/KeyResultControllerIT.java @@ -92,7 +92,7 @@ void shouldGetOrdinalKeyResultWithId() throws Exception { .andExpect(jsonPath(JSON_PATH_OBJECTIVE_ID, Is.is(OBJECTIVE_ID))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_STATE, Is.is(OBJECTIVE_STATE_ONGOING))) .andExpect(jsonPath(JSON_PATH_QUARTER_LABEL, Is.is(QUARTER_LABEL))) - .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_ZONE, Is.is(LAST_CHECK_IN_ZONE))) + .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_ZONE, Is.is(LAST_CHECK_IN_ZONE.toString()))) .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_CONFIDENCE, Is.is(CONFIDENCE))) .andExpect(jsonPath(JSON_PATH_CREATED_ON, Is.is(KEY_RESULT_CREATED_ON))) .andExpect(jsonPath(JSON_PATH_COMMIT_ZONE, Is.is(COMMIT_ZONE))) @@ -214,7 +214,7 @@ void createKeyResultWithEnumKeys() throws Exception { .andExpect(jsonPath(JSON_PATH_KEY_RESULT_TYPE, Is.is(KEY_RESULT_TYPE_ORDINAL))) .andExpect(jsonPath(JSON_PATH_OWNER_FIRSTNAME, Is.is(FIRSTNAME))) .andExpect(jsonPath(JSON_PATH_OBJECTIVE_STATE, Is.is(OBJECTIVE_STATE_ONGOING))) - .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_ZONE, Is.is(LAST_CHECK_IN_ZONE))) + .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_ZONE, Is.is(LAST_CHECK_IN_ZONE.toString()))) .andExpect(jsonPath(JSON_PATH_LAST_CHECK_IN_CONFIDENCE, Is.is(CONFIDENCE))) .andExpect(jsonPath(JSON_PATH_CREATED_ON, Is.is(KEY_RESULT_CREATED_ON))) .andExpect(jsonPath(JSON_PATH_COMMIT_ZONE, Is.is(COMMIT_ZONE))) From 50e475543cc8fe05efca4df4710df5ce18ba6f48 Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 3 Oct 2023 09:22:12 +0200 Subject: [PATCH 74/97] fix frontend tests by adding necessary imports and providers --- .../src/app/confidence/confidence.component.spec.ts | 8 ++++---- .../check-in-history-dialog.component.spec.ts | 4 ++-- .../check-in-base-informations.component.spec.ts | 6 ++++++ .../check-in-form-metric.component.spec.ts | 13 ++++++++++++- .../check-in-form-ordinal.component.spec.ts | 8 ++++++++ .../check-in-form/check-in-form.component.spec.ts | 5 +++++ .../check-in-form/check-in-form.component.ts | 2 +- .../confirm-dialog/confirm-dialog.component.spec.ts | 5 +++++ 8 files changed, 43 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/confidence/confidence.component.spec.ts b/frontend/src/app/confidence/confidence.component.spec.ts index 95d523204f..7b13214ad0 100644 --- a/frontend/src/app/confidence/confidence.component.spec.ts +++ b/frontend/src/app/confidence/confidence.component.spec.ts @@ -3,7 +3,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ConfidenceComponent } from './confidence.component'; import { HarnessLoader } from '@angular/cdk/testing'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; -import { keyResultMetricMin } from '../shared/testData'; +import { checkInMetric } from '../shared/testData'; import { MatSliderModule } from '@angular/material/slider'; import { CheckInMin } from '../shared/types/model/CheckInMin'; import { FormsModule } from '@angular/forms'; @@ -24,7 +24,7 @@ describe('ConfidenceComponent', () => { fixture = TestBed.createComponent(ConfidenceComponent); component = fixture.componentInstance; loader = TestbedHarnessEnvironment.loader(fixture); - component.keyResult = keyResultMetricMin; + component.checkIn = checkInMetric; component.edit = true; }); @@ -36,9 +36,9 @@ describe('ConfidenceComponent', () => { [{ confidence: 8 } as CheckInMin, '8'], [null, '5'], ])('should set confidence of component with right value', async (checkIn: CheckInMin | null, expected: string) => { - component.keyResult.lastCheckIn = checkIn; + component.checkIn = checkIn!; component.ngOnChanges({ - keyResult: new SimpleChange(null, component.keyResult, true), + checkIn: new SimpleChange(null, component.checkIn, true), }); fixture.detectChanges(); await fixture.whenStable(); diff --git a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.spec.ts b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.spec.ts index 1b148c1584..9ab5fd0f9c 100644 --- a/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.spec.ts +++ b/frontend/src/app/shared/dialog/check-in-history-dialog/check-in-history-dialog.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CheckInHistoryDialogComponent } from './check-in-history-dialog.component'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('CheckInHistoryDialogComponent', () => { @@ -11,7 +11,7 @@ describe('CheckInHistoryDialogComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [CheckInHistoryDialogComponent], - imports: [HttpClientTestingModule], + imports: [HttpClientTestingModule, MatDialogModule], providers: [ { provide: MAT_DIALOG_DATA, useValue: {} }, { provide: MatDialogRef, useValue: {} }, 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 index 184a0876b8..e6dd347e82 100644 --- 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 @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CheckInBaseInformationsComponent } from './check-in-base-informations.component'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; describe('CheckInBaseInformationsComponent', () => { let component: CheckInBaseInformationsComponent; @@ -8,10 +9,15 @@ describe('CheckInBaseInformationsComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ + imports: [], 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)]), + }); fixture.detectChanges(); }); diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts index 1d757c5c02..9b0db34b21 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts @@ -1,6 +1,11 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CheckInFormMetricComponent } from './check-in-form-metric.component'; +import { UnitTransformationPipe } from '../../../pipes/unit-transformation/unit-transformation.pipe'; +import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; +import { keyResultMetricMin } from '../../../testData'; +import { UnitLabelTransformationPipe } from '../../../pipes/unit-label-transformation/unit-label-transformation.pipe'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; describe('CheckInFormComponent', () => { let component: CheckInFormMetricComponent; @@ -8,10 +13,16 @@ describe('CheckInFormComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [CheckInFormMetricComponent], + declarations: [CheckInFormMetricComponent, UnitLabelTransformationPipe], + providers: [UnitTransformationPipe], }); fixture = TestBed.createComponent(CheckInFormMetricComponent); component = fixture.componentInstance; + component.keyResult = keyResultMetricMin as unknown as KeyResultMetric; + component.dialogForm = new FormGroup({ + value: new FormControl('', [Validators.required]), + confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), + }); fixture.detectChanges(); }); diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts index b28ee93ba6..5e6f027917 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts @@ -1,6 +1,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CheckInFormOrdinalComponent } from './check-in-form-ordinal.component'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { keyResultOrdinalMin } from '../../../testData'; +import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; describe('CheckInFormOrdinalComponent', () => { let component: CheckInFormOrdinalComponent; @@ -12,6 +15,11 @@ describe('CheckInFormOrdinalComponent', () => { }); fixture = TestBed.createComponent(CheckInFormOrdinalComponent); component = fixture.componentInstance; + component.keyResult = keyResultOrdinalMin as unknown as KeyResultOrdinal; + component.dialogForm = new FormGroup({ + value: new FormControl('', [Validators.required]), + confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), + }); fixture.detectChanges(); }); diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts index 24eed6bd94..e9bfe41b3d 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CheckInFormComponent } from './check-in-form.component'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; describe('CheckInFormComponent', () => { let component: CheckInFormComponent; @@ -8,6 +9,10 @@ describe('CheckInFormComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ + providers: [ + { provide: MAT_DIALOG_DATA, useValue: { keyResult: {} } }, + { provide: MatDialogRef, useValue: {} }, + ], declarations: [CheckInFormComponent], }); fixture = TestBed.createComponent(CheckInFormComponent); 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 99f0931711..8a1b5f5955 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 @@ -72,7 +72,7 @@ export class CheckInFormComponent { if (this.data.checkIn != null) { this.checkIn = this.data.checkIn; } else if (this.keyResult.lastCheckIn != null) { - this.checkIn = this.keyResult.lastCheckIn!; + this.checkIn = this.keyResult.lastCheckIn; } } } diff --git a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts index 98cde0d3f6..ee40f373fe 100644 --- a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts +++ b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ConfirmDialogComponent } from './confirm-dialog.component'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; describe('ConfirmDialogComponent', () => { let component: ConfirmDialogComponent; @@ -9,6 +10,10 @@ describe('ConfirmDialogComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [ConfirmDialogComponent], + providers: [ + { provide: MAT_DIALOG_DATA, useValue: {} }, + { provide: MatDialogRef, useValue: {} }, + ], }); fixture = TestBed.createComponent(ConfirmDialogComponent); component = fixture.componentInstance; From 107a3985e9a2d952882ff2ec419cb38669ca5f8e Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 3 Oct 2023 13:20:01 +0200 Subject: [PATCH 75/97] implement test for check-in-base-information form --- ...eck-in-base-informations.component.spec.ts | 58 ++++++++++++++++++- 1 file changed, 55 insertions(+), 3 deletions(-) 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 index e6dd347e82..254fa34fa8 100644 --- 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 @@ -1,15 +1,38 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { CheckInBaseInformationsComponent } from './check-in-base-informations.component'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; +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'; describe('CheckInBaseInformationsComponent', () => { let component: CheckInBaseInformationsComponent; let fixture: ComponentFixture; + let loader: HarnessLoader; + let errors = errorData; + + let changeInfoText = 'ChangeInfo'; + let initiativesText = 'Initiatives'; beforeEach(() => { TestBed.configureTestingModule({ - imports: [], + imports: [ + MatDialogModule, + NoopAnimationsModule, + MatSelectModule, + MatInputModule, + MatRadioModule, + ReactiveFormsModule, + ], declarations: [CheckInBaseInformationsComponent], }); fixture = TestBed.createComponent(CheckInBaseInformationsComponent); @@ -19,9 +42,38 @@ describe('CheckInBaseInformationsComponent', () => { initiatives: new FormControl('', [Validators.maxLength(4096)]), }); fixture.detectChanges(); + loader = TestbedHarnessEnvironment.loader(fixture); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should save given text in input to form-group in typescript', waitForAsync(async () => { + //Insert values into name input which don't match length validator + const inputs = await loader.getAllHarnesses(MatInputHarness); + const changeInfoTextbox = inputs[0]; + const initiativesTextbox = inputs[1]; + + await changeInfoTextbox.setValue(changeInfoText); + await initiativesTextbox.setValue(initiativesText); + + //Check if submit button is disabled + 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', waitForAsync(async () => { + //Insert values into name input which don't match length validator + const inputs = await loader.getAllHarnesses(MatInputHarness); + 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); + })); }); From 88a6a99acb6da6360357be3e920688fe3f0a349b Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 3 Oct 2023 13:26:36 +0200 Subject: [PATCH 76/97] resolve clean up feedback --- frontend/src/app/app.module.ts | 6 +++--- .../src/app/keyresult/keyresult.component.ts | 20 ++++++++++++------- .../check-in-form-metric.component.spec.ts | 4 ++-- .../check-in-form-metric.component.ts | 4 ++-- .../unit-transformation.pipe.spec.ts | 8 -------- .../unit-transformation.pipe.spec.ts | 8 ++++++++ .../unit-value-transformation.pipe.ts} | 4 ++-- 7 files changed, 30 insertions(+), 24 deletions(-) delete mode 100644 frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.spec.ts create mode 100644 frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts rename frontend/src/app/shared/pipes/{unit-transformation/unit-transformation.pipe.ts => unit-value-transformation/unit-value-transformation.pipe.ts} (85%) diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 69c4d62b49..7500b071a1 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -48,7 +48,7 @@ import { CheckInHistoryDialogComponent } from './shared/dialog/check-in-history- import { MatDividerModule } from '@angular/material/divider'; import { ApplicationBannerComponent } from './application-banner/application-banner.component'; import { CheckInFormMetricComponent } from './shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component'; -import { UnitTransformationPipe } from './shared/pipes/unit-transformation/unit-transformation.pipe'; +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'; @@ -105,7 +105,7 @@ export const MY_FORMATS = { ConfirmDialogComponent, CheckInFormComponent, CheckInFormMetricComponent, - UnitTransformationPipe, + UnitValueTransformationPipe, CheckInFormOrdinalComponent, CheckInBaseInformationsComponent, CustomInputComponent, @@ -162,7 +162,7 @@ export const MY_FORMATS = { { provide: HTTP_INTERCEPTORS, useClass: DrawerInterceptor, multi: true }, { provide: OAuthStorage, useFactory: storageFactory }, { provide: APP_INITIALIZER, useFactory: initOauthFactory, deps: [ConfigService, OAuthService], multi: true }, - UnitTransformationPipe, + UnitValueTransformationPipe, ], bootstrap: [AppComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/frontend/src/app/keyresult/keyresult.component.ts b/frontend/src/app/keyresult/keyresult.component.ts index 838814ee3b..486e0f5be9 100644 --- a/frontend/src/app/keyresult/keyresult.component.ts +++ b/frontend/src/app/keyresult/keyresult.component.ts @@ -1,8 +1,10 @@ -import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core'; -import { KeyresultMin } from '../shared/types/model/KeyresultMin'; -import { MatDialog } from '@angular/material/dialog'; -import { CheckInHistoryDialogComponent } from '../shared/dialog/check-in-history-dialog/check-in-history-dialog.component'; -import { Router } from '@angular/router'; +import {ChangeDetectionStrategy, Component, Input} from '@angular/core'; +import {KeyresultMin} from '../shared/types/model/KeyresultMin'; +import {MatDialog} from '@angular/material/dialog'; +import { + CheckInHistoryDialogComponent +} from '../shared/dialog/check-in-history-dialog/check-in-history-dialog.component'; +import {Router} from '@angular/router'; @Component({ selector: 'app-keyresult', @@ -12,10 +14,13 @@ import { Router } from '@angular/router'; }) export class KeyresultComponent { @Input() keyResult!: KeyresultMin; + constructor( public dialog: MatDialog, private router: Router, - ) {} + ) { + } + checkInHistory() { const dialogRef = this.dialog.open(CheckInHistoryDialogComponent, { data: { @@ -23,7 +28,8 @@ export class KeyresultComponent { }, }); - dialogRef.afterClosed().subscribe(() => {}); + dialogRef.afterClosed().subscribe(() => { + }); } openDrawer() { diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts index 9b0db34b21..c050b79b1e 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CheckInFormMetricComponent } from './check-in-form-metric.component'; -import { UnitTransformationPipe } from '../../../pipes/unit-transformation/unit-transformation.pipe'; +import { UnitValueTransformationPipe } from '../../../pipes/unit-value-transformation/unit-value-transformation.pipe'; import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; import { keyResultMetricMin } from '../../../testData'; import { UnitLabelTransformationPipe } from '../../../pipes/unit-label-transformation/unit-label-transformation.pipe'; @@ -14,7 +14,7 @@ describe('CheckInFormComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [CheckInFormMetricComponent, UnitLabelTransformationPipe], - providers: [UnitTransformationPipe], + providers: [UnitValueTransformationPipe], }); fixture = TestBed.createComponent(CheckInFormMetricComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index 8b5f05be2e..0868230d2b 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -2,7 +2,7 @@ import { AfterViewInit, Component, Input } from '@angular/core'; import { FormGroup } from '@angular/forms'; import errorMessages from '../../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; -import { UnitTransformationPipe } from '../../../pipes/unit-transformation/unit-transformation.pipe'; +import { UnitValueTransformationPipe } from '../../../pipes/unit-value-transformation/unit-value-transformation.pipe'; import { CheckInMin } from '../../../types/model/CheckInMin'; @Component({ @@ -19,7 +19,7 @@ export class CheckInFormMetricComponent implements AfterViewInit { dialogForm!: FormGroup; protected readonly errorMessages: any = errorMessages; - constructor(private pipe: UnitTransformationPipe) {} + constructor(private pipe: UnitValueTransformationPipe) {} formatValue() { this.dialogForm?.controls['value'].setValue(this.pipe.transform(this.parseValue(), this.keyResult.unit)); diff --git a/frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.spec.ts b/frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.spec.ts deleted file mode 100644 index 1e32c5fa12..0000000000 --- a/frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.spec.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { UnitTransformationPipe } from './unit-transformation.pipe'; - -describe('UnitTransformationPipe', () => { - it('create an instance', () => { - const pipe = new UnitTransformationPipe(); - expect(pipe).toBeTruthy(); - }); -}); diff --git a/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts b/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts new file mode 100644 index 0000000000..c5eb31501a --- /dev/null +++ b/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts @@ -0,0 +1,8 @@ +import { UnitValueTransformationPipe } from './unit-value-transformation.pipe'; + +describe('UnitTransformationPipe', () => { + it('create an instance', () => { + const pipe = new UnitValueTransformationPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.ts b/frontend/src/app/shared/pipes/unit-value-transformation/unit-value-transformation.pipe.ts similarity index 85% rename from frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.ts rename to frontend/src/app/shared/pipes/unit-value-transformation/unit-value-transformation.pipe.ts index 4483c3c8a1..db639dc6a2 100644 --- a/frontend/src/app/shared/pipes/unit-transformation/unit-transformation.pipe.ts +++ b/frontend/src/app/shared/pipes/unit-value-transformation/unit-value-transformation.pipe.ts @@ -3,9 +3,9 @@ import { formatCurrency } from '@angular/common'; import { Unit } from '../../types/enums/Unit'; @Pipe({ - name: 'unitTransformation', + name: 'unitValueTransformation', }) -export class UnitTransformationPipe implements PipeTransform { +export class UnitValueTransformationPipe implements PipeTransform { transform(value: number, unit: String): string { if (Number.isNaN(value)) { value = 0; From a311f71d007f1dbc8af7f9d275b03d5379a4ba2e Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 3 Oct 2023 13:26:58 +0200 Subject: [PATCH 77/97] format cleaned up logic in component --- .../src/app/keyresult/keyresult.component.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/keyresult/keyresult.component.ts b/frontend/src/app/keyresult/keyresult.component.ts index 486e0f5be9..ae8d1cd941 100644 --- a/frontend/src/app/keyresult/keyresult.component.ts +++ b/frontend/src/app/keyresult/keyresult.component.ts @@ -1,10 +1,8 @@ -import {ChangeDetectionStrategy, Component, Input} from '@angular/core'; -import {KeyresultMin} from '../shared/types/model/KeyresultMin'; -import {MatDialog} from '@angular/material/dialog'; -import { - CheckInHistoryDialogComponent -} from '../shared/dialog/check-in-history-dialog/check-in-history-dialog.component'; -import {Router} from '@angular/router'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { KeyresultMin } from '../shared/types/model/KeyresultMin'; +import { MatDialog } from '@angular/material/dialog'; +import { CheckInHistoryDialogComponent } from '../shared/dialog/check-in-history-dialog/check-in-history-dialog.component'; +import { Router } from '@angular/router'; @Component({ selector: 'app-keyresult', @@ -18,8 +16,7 @@ export class KeyresultComponent { constructor( public dialog: MatDialog, private router: Router, - ) { - } + ) {} checkInHistory() { const dialogRef = this.dialog.open(CheckInHistoryDialogComponent, { @@ -28,8 +25,7 @@ export class KeyresultComponent { }, }); - dialogRef.afterClosed().subscribe(() => { - }); + dialogRef.afterClosed().subscribe(() => {}); } openDrawer() { From 4b947fbd9bea75e1eb7eec684855a33b4f7255b5 Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 3 Oct 2023 15:11:08 +0200 Subject: [PATCH 78/97] write tests for check-in-form and clean up code --- .../check-in-form.component.spec.ts | 94 ++++++++++++++++++- .../check-in-form/check-in-form.component.ts | 24 ++--- frontend/src/app/shared/testData.ts | 70 ++++++++++++++ 3 files changed, 173 insertions(+), 15 deletions(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts index e9bfe41b3d..5a0c6811a0 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts @@ -1,7 +1,20 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { CheckInFormComponent } from './check-in-form.component'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; +import { checkInMetric, checkInOrdinal, keyResultMetric, keyResultOrdinal } from '../../../testData'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { MatIconModule } from '@angular/material/icon'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatSelectModule } from '@angular/material/select'; +import { ReactiveFormsModule } from '@angular/forms'; +import { MatInputModule } from '@angular/material/input'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { MatCheckboxModule } from '@angular/material/checkbox'; + +const dialogMock = { + close: jest.fn(), +}; describe('CheckInFormComponent', () => { let component: CheckInFormComponent; @@ -9,9 +22,20 @@ describe('CheckInFormComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ + imports: [ + HttpClientTestingModule, + MatDialogModule, + MatIconModule, + MatFormFieldModule, + MatSelectModule, + ReactiveFormsModule, + MatInputModule, + NoopAnimationsModule, + MatCheckboxModule, + ], providers: [ { provide: MAT_DIALOG_DATA, useValue: { keyResult: {} } }, - { provide: MatDialogRef, useValue: {} }, + { provide: MatDialogRef, useValue: dialogMock }, ], declarations: [CheckInFormComponent], }); @@ -23,4 +47,68 @@ describe('CheckInFormComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should return data of check-in correctly if key result is metric', waitForAsync(async () => { + component.checkIn = checkInMetric; + component.keyResult = keyResultMetric; + component.dialogForm.controls['value'].setValue(checkInMetric?.value!.toString()); + component.dialogForm.controls['confidence'].setValue(checkInMetric.confidence); + component.dialogForm.controls['changeInfo'].setValue(checkInMetric.changeInfo); + component.dialogForm.controls['initiatives'].setValue(checkInMetric.initiatives); + + component.saveCheckIn(); + + expect(dialogMock.close).toHaveBeenCalledWith({ + data: { + confidence: checkInMetric.confidence, + value: checkInMetric.value, + changeInfo: checkInMetric.changeInfo, + initiatives: checkInMetric.initiatives, + keyResultId: keyResultMetric.id, + }, + }); + })); + + it('should return data of check-in correctly if key result is ordinal', waitForAsync(async () => { + component.checkIn = checkInOrdinal; + component.keyResult = keyResultOrdinal; + component.dialogForm.controls['value'].setValue(checkInOrdinal?.value as string); + component.dialogForm.controls['confidence'].setValue(checkInOrdinal.confidence); + component.dialogForm.controls['changeInfo'].setValue(checkInOrdinal.changeInfo); + component.dialogForm.controls['initiatives'].setValue(checkInOrdinal.initiatives); + + component.saveCheckIn(); + + expect(dialogMock.close).toHaveBeenCalledWith({ + data: { + confidence: checkInOrdinal.confidence, + value: checkInOrdinal.value, + changeInfo: checkInOrdinal.changeInfo, + initiatives: checkInOrdinal.initiatives, + keyResultId: keyResultOrdinal.id, + }, + }); + })); + + it('should set default values if form check-in input is not null', waitForAsync(async () => { + component.data.checkIn = checkInMetric; + component.setDefaultValues(); + expect(component.dialogForm.value).toStrictEqual({ + confidence: checkInMetric.confidence, + value: checkInMetric.value!.toString(), + changeInfo: checkInMetric.changeInfo, + initiatives: checkInMetric.initiatives, + }); + })); + + it('should set default values if last check-in of key result is not null', waitForAsync(async () => { + component.keyResult = keyResultOrdinal; + component.setDefaultValues(); + expect(component.dialogForm.value).toStrictEqual({ + confidence: keyResultOrdinal.lastCheckIn!.confidence, + value: keyResultOrdinal.lastCheckIn!.value, + changeInfo: '', + initiatives: '', + }); + })); }); 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 8a1b5f5955..09bee04162 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 @@ -13,7 +13,7 @@ import { CheckInMin } from '../../../types/model/CheckInMin'; }) export class CheckInFormComponent { keyResult: KeyResult; - checkIn: CheckInMin = { confidence: 5 } as CheckInMin; + checkIn!: CheckInMin; currentDate: Date; continued: boolean = false; @@ -30,21 +30,29 @@ export class CheckInFormComponent { ) { this.currentDate = new Date(); this.keyResult = data.keyResult; - this.setCheckIn(); this.setDefaultValues(); + if (this.checkIn == null) { + } } setDefaultValues() { if (this.data.checkIn != null) { + this.checkIn = this.data.checkIn; this.dialogForm.controls.value.setValue(this.checkIn.value!.toString()); this.dialogForm.controls.confidence.setValue(this.checkIn.confidence); this.dialogForm.controls.changeInfo.setValue(this.checkIn.changeInfo); this.dialogForm.controls.initiatives.setValue(this.checkIn.initiatives); return; } - if (this.keyResult.lastCheckIn?.value != null) { - this.dialogForm.controls.value.setValue(this.keyResult.lastCheckIn.value.toString()); + /* If KeyResult has lastCheckIn set checkIn to this value */ + if (this.keyResult.lastCheckIn != null) { + this.checkIn = this.keyResult.lastCheckIn; + this.dialogForm.controls.value.setValue(this.checkIn.value!.toString()); + this.dialogForm.controls.confidence.setValue(this.checkIn.confidence); + return; } + /* If Check-in is null set as object with confidence 5 default value */ + this.checkIn = { confidence: 5 } as CheckInMin; } saveCheckIn() { @@ -67,12 +75,4 @@ export class CheckInFormComponent { getKeyResultOrdinal(): KeyResultOrdinal { return this.keyResult as KeyResultOrdinal; } - - setCheckIn() { - if (this.data.checkIn != null) { - this.checkIn = this.data.checkIn; - } else if (this.keyResult.lastCheckIn != null) { - this.checkIn = this.keyResult.lastCheckIn; - } - } } diff --git a/frontend/src/app/shared/testData.ts b/frontend/src/app/shared/testData.ts index bbe8d34eac..7f06e3db1f 100644 --- a/frontend/src/app/shared/testData.ts +++ b/frontend/src/app/shared/testData.ts @@ -12,6 +12,8 @@ import { Quarter } from './types/model/Quarter'; import { KeyResultOrdinal } from './types/model/KeyResultOrdinal'; import { CheckIn } from './types/model/CheckIn'; import { User } from './types/model/User'; +import { KeyResultMetric } from './types/model/KeyResultMetric'; +import { Unit } from './types/enums/Unit'; export const team1: TeamMin = { id: 1, @@ -28,12 +30,16 @@ export const checkInMetric: CheckInMin = { value: 15, confidence: 5, createdOn: '2023-07-20T12:34:56Z' as unknown as Date, + initiatives: 'Initiatives metric', + changeInfo: 'Changeinfo metric', } as CheckInMin; export const checkInOrdinal: CheckInMin = { id: 816, value: 'COMMIT', confidence: 7, createdOn: '2023-07-22T08:45:21Z' as unknown as Date, + initiatives: 'Initiatives ordinal', + changeInfo: 'Changeinfo ordinal', } as CheckInMin; export const keyResultMetricMin: KeyResultMetricMin = { id: 201, @@ -151,3 +157,67 @@ export const keyResult: KeyResultOrdinal = { createdOn: new Date(), modifiedOn: new Date(), }; + +export const keyResultOrdinal: KeyResultOrdinal = { + id: 101, + title: 'Bauen eines Hauses', + description: 'Ein neues Haus für die Puzzle Members', + commitZone: 'Grundriss steht', + targetZone: 'Gebäude gebaut', + stretchZone: 'Inneneinrichtung gestaltet', + owner: { id: 1, firstname: 'firstname', lastname: 'lastname' }, + keyResultType: 'ordinal', + objective: { + id: 301, + state: State.DRAFT, + quarter: { + id: 1, + label: 'GJ 23/24-Q1', + startDate: new Date(), + endDate: new Date(), + } as Quarter, + } as Objective, + lastCheckIn: { + id: 746, + value: 'FAIL', + confidence: 3, + createdOn: new Date(), + modifiedOn: new Date(), + changeInfo: 'Does not look good', + initiatives: 'We have to be faster', + } as CheckIn, + createdOn: new Date(), + modifiedOn: new Date(), +}; + +export const keyResultMetric: KeyResultMetric = { + id: 102, + title: '100% aller Schweizer Kunden betreuen', + description: 'Puzzle ITC erledigt die IT-Aufträge für 100% aller Unternehmen.', + baseline: 30, + stretchGoal: 100, + unit: Unit.PERCENT, + owner: { id: 1, firstname: 'firstname', lastname: 'lastname' }, + keyResultType: 'metric', + objective: { + id: 302, + state: State.DRAFT, + quarter: { + id: 1, + label: 'GJ 23/24-Q1', + startDate: new Date(), + endDate: new Date(), + } as Quarter, + } as Objective, + lastCheckIn: { + id: 746, + value: 45, + confidence: 7, + createdOn: new Date(), + modifiedOn: new Date(), + changeInfo: 'So far so good', + initiatives: 'Work a bit harder', + } as CheckIn, + createdOn: new Date(), + modifiedOn: new Date(), +}; From b7db68d9b3d54187cd11cbf612a85634dcf293bd Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 3 Oct 2023 15:12:08 +0200 Subject: [PATCH 79/97] remove unused if statement --- .../dialog/checkin/check-in-form/check-in-form.component.ts | 2 -- 1 file changed, 2 deletions(-) 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 09bee04162..99023c894b 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 @@ -31,8 +31,6 @@ export class CheckInFormComponent { this.currentDate = new Date(); this.keyResult = data.keyResult; this.setDefaultValues(); - if (this.checkIn == null) { - } } setDefaultValues() { From 4fe71cc56c738bf31bda65138a5e754829733ac2 Mon Sep 17 00:00:00 2001 From: megli2 Date: Tue, 3 Oct 2023 15:49:15 +0200 Subject: [PATCH 80/97] implement tests for check-in-form-metric component --- .../check-in-form-metric.component.spec.ts | 58 ++++++++++++++++--- .../check-in-form-metric.component.ts | 3 +- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts index c050b79b1e..b44386994f 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts @@ -1,32 +1,76 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { CheckInFormMetricComponent } from './check-in-form-metric.component'; import { UnitValueTransformationPipe } from '../../../pipes/unit-value-transformation/unit-value-transformation.pipe'; -import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; -import { keyResultMetricMin } from '../../../testData'; -import { UnitLabelTransformationPipe } from '../../../pipes/unit-label-transformation/unit-label-transformation.pipe'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { checkInMetric, keyResultMetric } from '../../../testData'; +import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; +import { HarnessLoader } from '@angular/cdk/testing'; +import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; +import { MatDialogModule } from '@angular/material/dialog'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { MatSelectModule } from '@angular/material/select'; +import { MatInputModule } from '@angular/material/input'; +import { MatRadioModule } from '@angular/material/radio'; +import { Unit } from '../../../types/enums/Unit'; describe('CheckInFormComponent', () => { let component: CheckInFormMetricComponent; let fixture: ComponentFixture; + let loader: HarnessLoader; beforeEach(() => { TestBed.configureTestingModule({ - declarations: [CheckInFormMetricComponent, UnitLabelTransformationPipe], + imports: [ + MatDialogModule, + NoopAnimationsModule, + MatSelectModule, + MatInputModule, + MatRadioModule, + ReactiveFormsModule, + ], + declarations: [CheckInFormMetricComponent], providers: [UnitValueTransformationPipe], }); fixture = TestBed.createComponent(CheckInFormMetricComponent); component = fixture.componentInstance; - component.keyResult = keyResultMetricMin as unknown as KeyResultMetric; + component.keyResult = keyResultMetric; + component.checkIn = checkInMetric; component.dialogForm = new FormGroup({ value: new FormControl('', [Validators.required]), confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), }); fixture.detectChanges(); + loader = TestbedHarnessEnvironment.loader(fixture); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should format percent correctly', waitForAsync(async () => { + component.keyResult = { ...keyResultMetric, unit: Unit.PERCENT }; + component.dialogForm.controls['value'].setValue(checkInMetric.value!.toString()); + component.formatValue(); + expect(component.dialogForm.controls['value'].value).toBe(checkInMetric.value + '%'); + })); + + it('should format CHF correctly', waitForAsync(async () => { + component.keyResult = { ...keyResultMetric, unit: Unit.CHF }; + component.dialogForm.controls['value'].setValue(checkInMetric.value!.toString()); + component.formatValue(); + expect(component.dialogForm.controls['value'].value).toBe(checkInMetric.value + '.-'); + })); + + it('should format FTE correctly', waitForAsync(async () => { + component.keyResult = { ...keyResultMetric, unit: Unit.FTE }; + component.dialogForm.controls['value'].setValue(checkInMetric.value!.toString()); + component.formatValue(); + expect(component.dialogForm.controls['value'].value).toBe(checkInMetric.value!.toString()); + })); + + it('should parse value correctly', waitForAsync(async () => { + component.keyResult = { ...keyResultMetric, unit: Unit.CHF }; + component.dialogForm.controls['value'].setValue(checkInMetric.value + '.-'); + expect(component.parseValue()).toBe(checkInMetric.value); + })); }); diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index 0868230d2b..b36ac9570c 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, Component, Input } from '@angular/core'; +import { AfterViewInit, ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { FormGroup } from '@angular/forms'; import errorMessages from '../../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; @@ -9,6 +9,7 @@ import { CheckInMin } from '../../../types/model/CheckInMin'; selector: 'app-check-in-form-metric', templateUrl: './check-in-form-metric.component.html', styleUrls: ['./check-in-form-metric.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, }) export class CheckInFormMetricComponent implements AfterViewInit { @Input() From d47e79cb184463fe40f542aa689b0ea274bc4f8c Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 07:45:33 +0200 Subject: [PATCH 81/97] add test in check-in-form-ordinal component --- .../check-in-form-ordinal.component.spec.ts | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts index 5e6f027917..f6caf13f15 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.spec.ts @@ -1,16 +1,34 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { CheckInFormOrdinalComponent } from './check-in-form-ordinal.component'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; import { keyResultOrdinalMin } from '../../../testData'; import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; +import { MatDialogModule } from '@angular/material/dialog'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { MatSelectModule } from '@angular/material/select'; +import { MatInputModule } from '@angular/material/input'; +import { MatRadioModule } from '@angular/material/radio'; +import { Zone } from '../../../types/enums/Zone'; +import { MatRadioButtonHarness } from '@angular/material/radio/testing'; +import { HarnessLoader } from '@angular/cdk/testing'; +import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; describe('CheckInFormOrdinalComponent', () => { let component: CheckInFormOrdinalComponent; let fixture: ComponentFixture; + let loader: HarnessLoader; beforeEach(() => { TestBed.configureTestingModule({ + imports: [ + MatDialogModule, + NoopAnimationsModule, + MatSelectModule, + MatInputModule, + MatRadioModule, + ReactiveFormsModule, + ], declarations: [CheckInFormOrdinalComponent], }); fixture = TestBed.createComponent(CheckInFormOrdinalComponent); @@ -21,9 +39,45 @@ describe('CheckInFormOrdinalComponent', () => { confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), }); fixture.detectChanges(); + loader = TestbedHarnessEnvironment.loader(fixture); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should set zone of check-in to fail if value is empty', waitForAsync(async () => { + expect(component.dialogForm.controls['value'].value).toBe(Zone.FAIL); + })); + + it('should set zone to Fail', waitForAsync(async () => { + const radioButtons = await loader.getAllHarnesses(MatRadioButtonHarness); + await radioButtons[0].check(); + expect(component.dialogForm.controls['value'].value).toBe(Zone.FAIL); + })); + + it('should set zone to Commit', waitForAsync(async () => { + const radioButtons = await loader.getAllHarnesses(MatRadioButtonHarness); + await radioButtons[1].check(); + expect(component.dialogForm.controls['value'].value).toBe(Zone.COMMIT); + })); + + it('should set zone to Target', waitForAsync(async () => { + const radioButtons = await loader.getAllHarnesses(MatRadioButtonHarness); + await radioButtons[2].check(); + expect(component.dialogForm.controls['value'].value).toBe(Zone.TARGET); + })); + + it('should set zone to Stretch', waitForAsync(async () => { + const radioButtons = await loader.getAllHarnesses(MatRadioButtonHarness); + await radioButtons[3].check(); + expect(component.dialogForm.controls['value'].value).toBe(Zone.STRETCH); + })); + + it('should be able to switch options ', waitForAsync(async () => { + const radioButtons = await loader.getAllHarnesses(MatRadioButtonHarness); + await radioButtons[3].check(); + await radioButtons[1].check(); + expect(component.dialogForm.controls['value'].value).toBe(Zone.COMMIT); + })); }); From 57321fcc40b29b14193273e0cac5d1b02949ac88 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 08:01:53 +0200 Subject: [PATCH 82/97] implement tests of confirm-dialog --- .../confirm-dialog.component.spec.ts | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts index ee40f373fe..5efa8680fa 100644 --- a/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts +++ b/frontend/src/app/shared/dialog/confirm-dialog/confirm-dialog.component.spec.ts @@ -1,26 +1,64 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ConfirmDialogComponent } from './confirm-dialog.component'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; +import { HarnessLoader } from '@angular/cdk/testing'; +import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; +import { MatButtonHarness } from '@angular/material/button/testing'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { MatSelectModule } from '@angular/material/select'; +import { MatInputModule } from '@angular/material/input'; +import { MatRadioModule } from '@angular/material/radio'; +import { ReactiveFormsModule } from '@angular/forms'; + +const dialogMock = { + close: jest.fn(), +}; describe('ConfirmDialogComponent', () => { let component: ConfirmDialogComponent; let fixture: ComponentFixture; + let loader: HarnessLoader; beforeEach(() => { TestBed.configureTestingModule({ + imports: [ + MatDialogModule, + NoopAnimationsModule, + MatSelectModule, + MatInputModule, + MatRadioModule, + ReactiveFormsModule, + ], declarations: [ConfirmDialogComponent], providers: [ { provide: MAT_DIALOG_DATA, useValue: {} }, - { provide: MatDialogRef, useValue: {} }, + { provide: MatDialogRef, useValue: dialogMock }, ], }); fixture = TestBed.createComponent(ConfirmDialogComponent); component = fixture.componentInstance; fixture.detectChanges(); + loader = TestbedHarnessEnvironment.loader(fixture); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should call close method with parameter: true if clicked to submit button', async () => { + let buttons = await loader.getAllHarnesses(MatButtonHarness); + const submitButton = buttons[0]; + await submitButton.click(); + + expect(dialogMock.close).toHaveBeenCalledWith(true); + }); + + it('should call close method with parameter: "" if clicked to cancel button', async () => { + let buttons = await loader.getAllHarnesses(MatButtonHarness); + const cancelButton = buttons[1]; + await cancelButton.click(); + + expect(dialogMock.close).toHaveBeenCalledWith(''); + }); }); From aa5ed570ae026fdeb55746297927b1d6fe7823ec Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 09:12:44 +0200 Subject: [PATCH 83/97] add test of custom-input --- .../custom-input/custom-input.component.html | 2 +- .../custom-input.component.spec.ts | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/shared/custom/custom-input/custom-input.component.html b/frontend/src/app/shared/custom/custom-input/custom-input.component.html index cf82d5dc9c..b9877b0e58 100644 --- a/frontend/src/app/shared/custom/custom-input/custom-input.component.html +++ b/frontend/src/app/shared/custom/custom-input/custom-input.component.html @@ -1,3 +1,3 @@
- +
diff --git a/frontend/src/app/shared/custom/custom-input/custom-input.component.spec.ts b/frontend/src/app/shared/custom/custom-input/custom-input.component.spec.ts index 56fada132c..b79b0d3d08 100644 --- a/frontend/src/app/shared/custom/custom-input/custom-input.component.spec.ts +++ b/frontend/src/app/shared/custom/custom-input/custom-input.component.spec.ts @@ -1,21 +1,52 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { HarnessLoader } from '@angular/cdk/testing'; import { CustomInputComponent } from './custom-input.component'; +import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; +import { MatInputHarness } from '@angular/material/input/testing'; +import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; +import { MatDialogModule } from '@angular/material/dialog'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { MatSelectModule } from '@angular/material/select'; +import { MatInputModule } from '@angular/material/input'; +import { MatRadioModule } from '@angular/material/radio'; +import { checkInMetric } from '../../testData'; describe('CustomInputComponent', () => { let component: CustomInputComponent; let fixture: ComponentFixture; + let loader: HarnessLoader; beforeEach(() => { TestBed.configureTestingModule({ + imports: [ + MatDialogModule, + NoopAnimationsModule, + MatSelectModule, + MatInputModule, + MatRadioModule, + ReactiveFormsModule, + ], declarations: [CustomInputComponent], }); fixture = TestBed.createComponent(CustomInputComponent); component = fixture.componentInstance; + component.formControlNameGiven = 'value'; + component.formGroup = new FormGroup({ + value: new FormControl('', [Validators.required]), + }); fixture.detectChanges(); + loader = TestbedHarnessEnvironment.loader(fixture); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should save given text in input to form-group in typescript', waitForAsync(async () => { + const input = await loader.getHarness(MatInputHarness); + await input.setValue(checkInMetric.value!.toString()); + + expect(component.formGroup.controls['value'].value).toBe(checkInMetric.value!.toString()); + })); }); From 49a03fcd10a5981ec78230e9d489c59e53df6b02 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 09:46:01 +0200 Subject: [PATCH 84/97] give title to confirmdialog when deleting keyresult and change check-in date depending on whether last check-in value of keyresult is defined or not --- frontend/src/app/app.module.ts | 1 - .../app/key-result-dialog/key-result-dialog.component.ts | 6 ++++-- .../checkin/check-in-form/check-in-form.component.html | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index 7500b071a1..e1d5c5dbbb 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -56,7 +56,6 @@ import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog. import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; import { CheckInFormComponent } from './shared/dialog/checkin/check-in-form/check-in-form.component'; import { UnitLabelTransformationPipe } from './shared/pipes/unit-label-transformation/unit-label-transformation.pipe'; -import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; function initOauthFactory(configService: ConfigService, oauthService: OAuthService) { return async () => { diff --git a/frontend/src/app/key-result-dialog/key-result-dialog.component.ts b/frontend/src/app/key-result-dialog/key-result-dialog.component.ts index 6ccbc9b374..d58fc6e874 100644 --- a/frontend/src/app/key-result-dialog/key-result-dialog.component.ts +++ b/frontend/src/app/key-result-dialog/key-result-dialog.component.ts @@ -90,15 +90,17 @@ export class KeyResultDialogComponent implements OnInit { deleteKeyResult() { if (this.data.keyResult.lastCheckIn?.id == undefined) { - //ToDo: Make ConfirmDialogComponent generic since its also used in other cases this.dialog .open(ConfirmDialogComponent, { + data: { + title: 'Key Result', + }, width: '15em', height: 'auto', }) .afterClosed() .subscribe((result) => { - if (result == 'deleteKeyResult') { + if (result) { this.keyResultService .deleteKeyResult(this.data.keyResult.id) .subscribe(() => this.dialogRef.close({ keyResult: this.data.keyResult, delete: true, openNew: false })); 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 86ab9fe048..2ed4fe4145 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,7 +1,9 @@
-

Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }})

-

+

+ Check-in erfassen ({{ currentDate | date: "dd.MM.yyyy" }}) +

+

Check-in bearbeiten ({{ checkIn.createdOn | date: "dd.MM.yyyy" }})

(1/2)

From 7722f9dac9247da573e256f0165fd2fb3dfe4377 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 09:46:53 +0200 Subject: [PATCH 85/97] format after bug fixes --- .../src/app/keyresult-detail/keyresult-detail.component.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/keyresult-detail/keyresult-detail.component.html b/frontend/src/app/keyresult-detail/keyresult-detail.component.html index 6fb1fc098f..4cbaacd27e 100644 --- a/frontend/src/app/keyresult-detail/keyresult-detail.component.html +++ b/frontend/src/app/keyresult-detail/keyresult-detail.component.html @@ -67,7 +67,9 @@

{{ keyResult.lastCheckIn?.changeInfo }}

- +
From 10355fb254ff98360d3371dd98d951b8d9d44541 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 10:08:58 +0200 Subject: [PATCH 86/97] disable submit button when form is not valid --- .../dialog/checkin/check-in-form/check-in-form.component.html | 4 +++- .../dialog/checkin/check-in-form/check-in-form.component.scss | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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 2ed4fe4145..24f5094d38 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 @@ -42,12 +42,14 @@

(2/2)

Weiter diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.scss b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.scss index 21560e802a..65fd2ef77e 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.scss +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.scss @@ -9,3 +9,7 @@ background-color: white; color: $pz-dark-blue; } + +.disabled { + background-color: gray; +} From 9168a8340f8126bd17d0446ea6781d4d3c902ea6 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 12:38:58 +0200 Subject: [PATCH 87/97] delete unused comments --- .../check-in-base-informations.component.spec.ts | 2 -- 1 file changed, 2 deletions(-) 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 index 254fa34fa8..f04b41d4b5 100644 --- 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 @@ -50,7 +50,6 @@ describe('CheckInBaseInformationsComponent', () => { }); it('should save given text in input to form-group in typescript', waitForAsync(async () => { - //Insert values into name input which don't match length validator const inputs = await loader.getAllHarnesses(MatInputHarness); const changeInfoTextbox = inputs[0]; const initiativesTextbox = inputs[1]; @@ -58,7 +57,6 @@ describe('CheckInBaseInformationsComponent', () => { await changeInfoTextbox.setValue(changeInfoText); await initiativesTextbox.setValue(initiativesText); - //Check if submit button is disabled expect(component.dialogForm.controls['changeInfo'].value).toBe(changeInfoText); expect(component.dialogForm.controls['initiatives'].value).toBe(initiativesText); })); From f49f67a75e38e18ce5abb744f3b2393ab69fed21 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 12:48:42 +0200 Subject: [PATCH 88/97] use === instead of == in checks --- .../check-in-form-metric/check-in-form-metric.component.ts | 4 ++-- .../check-in-form-ordinal/check-in-form-ordinal.component.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index b36ac9570c..d2e1fa453b 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -1,5 +1,5 @@ import { AfterViewInit, ChangeDetectionStrategy, Component, Input } from '@angular/core'; -import { FormGroup } from '@angular/forms'; +import { FormGroup, ValidationErrors } from '@angular/forms'; import errorMessages from '../../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; import { UnitValueTransformationPipe } from '../../../pipes/unit-value-transformation/unit-value-transformation.pipe'; @@ -36,7 +36,7 @@ export class CheckInFormMetricComponent implements AfterViewInit { getErrorKeysOfFormField(name: string) { const errors = this.dialogForm.get(name)?.errors; - return errors == null ? [] : Object.keys(errors); + return errors === null ? [] : Object.keys(errors!); } ngAfterViewInit(): void { diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts index 2d62e0f75d..e1e31e2f94 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component.ts @@ -19,7 +19,7 @@ export class CheckInFormOrdinalComponent implements OnInit { protected readonly Zone = Zone; ngOnInit(): void { - if (this.dialogForm.controls['value'].value == '') { + if (this.dialogForm.controls['value'].value === '') { this.dialogForm.controls['value'].setValue(Zone.FAIL); } } From 6fa774334e9f71a8607bc34f6e0b8b79f0f7dbaf Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 12:49:43 +0200 Subject: [PATCH 89/97] delete unused import --- .../check-in-form-metric/check-in-form-metric.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index d2e1fa453b..b59a90a481 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -1,5 +1,5 @@ import { AfterViewInit, ChangeDetectionStrategy, Component, Input } from '@angular/core'; -import { FormGroup, ValidationErrors } from '@angular/forms'; +import { FormGroup } from '@angular/forms'; import errorMessages from '../../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; import { UnitValueTransformationPipe } from '../../../pipes/unit-value-transformation/unit-value-transformation.pipe'; From 0ef3c5b85713d3de48e65e2b4910abdc66cd579c Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 13:30:08 +0200 Subject: [PATCH 90/97] delete unused test loader --- .../check-in-form-metric.component.spec.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts index b44386994f..ca36b80377 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts @@ -4,8 +4,6 @@ import { CheckInFormMetricComponent } from './check-in-form-metric.component'; import { UnitValueTransformationPipe } from '../../../pipes/unit-value-transformation/unit-value-transformation.pipe'; import { checkInMetric, keyResultMetric } from '../../../testData'; import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; -import { HarnessLoader } from '@angular/cdk/testing'; -import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { MatDialogModule } from '@angular/material/dialog'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatSelectModule } from '@angular/material/select'; @@ -16,7 +14,6 @@ import { Unit } from '../../../types/enums/Unit'; describe('CheckInFormComponent', () => { let component: CheckInFormMetricComponent; let fixture: ComponentFixture; - let loader: HarnessLoader; beforeEach(() => { TestBed.configureTestingModule({ @@ -40,7 +37,6 @@ describe('CheckInFormComponent', () => { confidence: new FormControl(5, [Validators.required, Validators.min(1), Validators.max(10)]), }); fixture.detectChanges(); - loader = TestbedHarnessEnvironment.loader(fixture); }); it('should create', () => { From 616cf622f5b59df805b80ac1b666b76ed84d1613 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 13:50:27 +0200 Subject: [PATCH 91/97] parse value with new implemented pipe --- frontend/src/app/app.module.ts | 3 +++ .../check-in-form-metric.component.spec.ts | 6 ------ .../check-in-form-metric.component.ts | 14 ++++++++------ .../check-in-form/check-in-form.component.ts | 12 +++++++----- .../parse-unit-value/parse-unit-value.pipe.spec.ts | 8 ++++++++ .../parse-unit-value/parse-unit-value.pipe.ts | 11 +++++++++++ 6 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.spec.ts create mode 100644 frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.ts index e1d5c5dbbb..72b9c61175 100644 --- a/frontend/src/app/app.module.ts +++ b/frontend/src/app/app.module.ts @@ -56,6 +56,7 @@ import { KeyResultDialogComponent } from './key-result-dialog/key-result-dialog. import { ConfirmDialogComponent } from './shared/dialog/confirm-dialog/confirm-dialog.component'; import { CheckInFormComponent } from './shared/dialog/checkin/check-in-form/check-in-form.component'; import { UnitLabelTransformationPipe } from './shared/pipes/unit-label-transformation/unit-label-transformation.pipe'; +import { ParseUnitValuePipe } from './shared/pipes/parse-unit-value/parse-unit-value.pipe'; function initOauthFactory(configService: ConfigService, oauthService: OAuthService) { return async () => { @@ -111,6 +112,7 @@ export const MY_FORMATS = { CheckInFormComponent, UnitLabelTransformationPipe, ConfirmDialogComponent, + ParseUnitValuePipe, ], imports: [ CommonModule, @@ -162,6 +164,7 @@ export const MY_FORMATS = { { provide: OAuthStorage, useFactory: storageFactory }, { provide: APP_INITIALIZER, useFactory: initOauthFactory, deps: [ConfigService, OAuthService], multi: true }, UnitValueTransformationPipe, + ParseUnitValuePipe, ], bootstrap: [AppComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts index ca36b80377..065d9ebb7e 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts @@ -63,10 +63,4 @@ describe('CheckInFormComponent', () => { component.formatValue(); expect(component.dialogForm.controls['value'].value).toBe(checkInMetric.value!.toString()); })); - - it('should parse value correctly', waitForAsync(async () => { - component.keyResult = { ...keyResultMetric, unit: Unit.CHF }; - component.dialogForm.controls['value'].setValue(checkInMetric.value + '.-'); - expect(component.parseValue()).toBe(checkInMetric.value); - })); }); diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts index b59a90a481..6217849397 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.ts @@ -4,6 +4,7 @@ import errorMessages from '../../../../../assets/errors/error-messages.json'; import { KeyResultMetric } from '../../../types/model/KeyResultMetric'; import { UnitValueTransformationPipe } from '../../../pipes/unit-value-transformation/unit-value-transformation.pipe'; import { CheckInMin } from '../../../types/model/CheckInMin'; +import { ParseUnitValuePipe } from '../../../pipes/parse-unit-value/parse-unit-value.pipe'; @Component({ selector: 'app-check-in-form-metric', @@ -20,14 +21,15 @@ export class CheckInFormMetricComponent implements AfterViewInit { dialogForm!: FormGroup; protected readonly errorMessages: any = errorMessages; - constructor(private pipe: UnitValueTransformationPipe) {} + constructor( + private pipe: UnitValueTransformationPipe, + private parserPipe: ParseUnitValuePipe, + ) {} formatValue() { - this.dialogForm?.controls['value'].setValue(this.pipe.transform(this.parseValue(), this.keyResult.unit)); - } - - parseValue(): number { - return +this.dialogForm?.controls['value'].value?.replaceAll('%', '').replaceAll('.-', '')!; + this.dialogForm?.controls['value'].setValue( + this.pipe.transform(this.parserPipe.transform(this.dialogForm?.controls['value'].value), this.keyResult.unit), + ); } isTouchedOrDirty(name: string) { 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 99023c894b..c59217f179 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 @@ -5,6 +5,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { KeyResult } from '../../../types/model/KeyResult'; import { KeyResultOrdinal } from '../../../types/model/KeyResultOrdinal'; import { CheckInMin } from '../../../types/model/CheckInMin'; +import { ParseUnitValuePipe } from '../../../pipes/parse-unit-value/parse-unit-value.pipe'; @Component({ selector: 'app-check-in-form', @@ -27,6 +28,7 @@ export class CheckInFormComponent { constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, + public parserPipe: ParseUnitValuePipe, ) { this.currentDate = new Date(); this.keyResult = data.keyResult; @@ -57,15 +59,15 @@ export class CheckInFormComponent { this.dialogForm.controls.confidence.setValue(this.checkIn.confidence); let checkIn: any = { ...this.dialogForm.value, keyResultId: this.keyResult.id }; if (this.keyResult.keyResultType === 'metric') { - checkIn = { ...this.dialogForm.value, value: this.parseValue(), keyResultId: this.keyResult.id }; + checkIn = { + ...this.dialogForm.value, + value: this.parserPipe.transform(this.dialogForm?.controls['value'].value!), + keyResultId: this.keyResult.id, + }; } this.dialogRef.close({ data: checkIn }); } - parseValue(): number { - return +this.dialogForm?.controls['value'].value?.replaceAll('%', '').replaceAll('.-', '')!; - } - getKeyResultMetric(): KeyResultMetric { return this.keyResult as KeyResultMetric; } diff --git a/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.spec.ts b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.spec.ts new file mode 100644 index 0000000000..8d18277a19 --- /dev/null +++ b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.spec.ts @@ -0,0 +1,8 @@ +import { ParseUnitValuePipe } from './parse-unit-value.pipe'; + +describe('ParseUnitValuePipe', () => { + it('create an instance', () => { + const pipe = new ParseUnitValuePipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts new file mode 100644 index 0000000000..1dbee0b542 --- /dev/null +++ b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts @@ -0,0 +1,11 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'parseUnitValue' +}) +export class ParseUnitValuePipe implements PipeTransform { + + transform(value: string): number { + return +value.replaceAll('%', '').replaceAll('.-', '')!; + } +} From 0f11e178a722b381df3eb19b38d3016f3b329ba5 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 13:50:49 +0200 Subject: [PATCH 92/97] format new implemented pipe --- .../app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts index 1dbee0b542..5db64c51fa 100644 --- a/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts +++ b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts @@ -1,10 +1,9 @@ import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ - name: 'parseUnitValue' + name: 'parseUnitValue', }) export class ParseUnitValuePipe implements PipeTransform { - transform(value: string): number { return +value.replaceAll('%', '').replaceAll('.-', '')!; } From 888afb926f34930e7449188cebafd2429b09f71a Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 14:45:00 +0200 Subject: [PATCH 93/97] fix tests by adding created pipe as provider to test suites --- .../check-in-form-metric.component.spec.ts | 3 ++- .../checkin/check-in-form/check-in-form.component.spec.ts | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts index 065d9ebb7e..f2ada76627 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component.spec.ts @@ -10,6 +10,7 @@ import { MatSelectModule } from '@angular/material/select'; import { MatInputModule } from '@angular/material/input'; import { MatRadioModule } from '@angular/material/radio'; import { Unit } from '../../../types/enums/Unit'; +import { ParseUnitValuePipe } from '../../../pipes/parse-unit-value/parse-unit-value.pipe'; describe('CheckInFormComponent', () => { let component: CheckInFormMetricComponent; @@ -26,7 +27,7 @@ describe('CheckInFormComponent', () => { ReactiveFormsModule, ], declarations: [CheckInFormMetricComponent], - providers: [UnitValueTransformationPipe], + providers: [UnitValueTransformationPipe, ParseUnitValuePipe], }); fixture = TestBed.createComponent(CheckInFormMetricComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts index 5a0c6811a0..bdf2f8baa4 100644 --- a/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts +++ b/frontend/src/app/shared/dialog/checkin/check-in-form/check-in-form.component.spec.ts @@ -11,6 +11,7 @@ import { ReactiveFormsModule } from '@angular/forms'; import { MatInputModule } from '@angular/material/input'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatCheckboxModule } from '@angular/material/checkbox'; +import { ParseUnitValuePipe } from '../../../pipes/parse-unit-value/parse-unit-value.pipe'; const dialogMock = { close: jest.fn(), @@ -36,6 +37,7 @@ describe('CheckInFormComponent', () => { providers: [ { provide: MAT_DIALOG_DATA, useValue: { keyResult: {} } }, { provide: MatDialogRef, useValue: dialogMock }, + ParseUnitValuePipe, ], declarations: [CheckInFormComponent], }); From e76731e5c4478685c1099003b119e8b8897fbbef Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 15:09:38 +0200 Subject: [PATCH 94/97] implement regex which replaces non number characters --- .../app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts | 3 ++- frontend/src/app/shared/regexLibrary.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts index 5db64c51fa..571861a362 100644 --- a/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts +++ b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.ts @@ -1,10 +1,11 @@ import { Pipe, PipeTransform } from '@angular/core'; +import { CHAR_REGEX } from '../../regexLibrary'; @Pipe({ name: 'parseUnitValue', }) export class ParseUnitValuePipe implements PipeTransform { transform(value: string): number { - return +value.replaceAll('%', '').replaceAll('.-', '')!; + return +value.replace(CHAR_REGEX, ''); } } diff --git a/frontend/src/app/shared/regexLibrary.ts b/frontend/src/app/shared/regexLibrary.ts index 812d6cc364..4ab3ae50dc 100644 --- a/frontend/src/app/shared/regexLibrary.ts +++ b/frontend/src/app/shared/regexLibrary.ts @@ -1,2 +1,3 @@ export const PERCENT_REGEX = '^-?[0-9][0-9]?(\\.[0-9]*)?$|^100$'; export const NUMBER_REGEX = '^-?[0-9][0-9]*.?[0-9]*?$'; +export const CHAR_REGEX = /[^0-9.]/g; From cc53b657f5d7c5a78b8ae51b2743600d26c59930 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 15:13:38 +0200 Subject: [PATCH 95/97] add tests to check if parse-pipe works correctly --- .../parse-unit-value.pipe.spec.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.spec.ts b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.spec.ts index 8d18277a19..481b73b0ee 100644 --- a/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.spec.ts +++ b/frontend/src/app/shared/pipes/parse-unit-value/parse-unit-value.pipe.spec.ts @@ -5,4 +5,24 @@ describe('ParseUnitValuePipe', () => { const pipe = new ParseUnitValuePipe(); expect(pipe).toBeTruthy(); }); + + it('should replace characters at end of string', () => { + const pipe = new ParseUnitValuePipe(); + expect(pipe.transform('200HelloWorld')).toBe(200); + }); + + it('should replace characters at beginning of string', () => { + const pipe = new ParseUnitValuePipe(); + expect(pipe.transform('HelloWorld200')).toBe(200); + }); + + it('should replace characters between strings', () => { + const pipe = new ParseUnitValuePipe(); + expect(pipe.transform("200'000")).toBe(200000); + }); + + it('should replace special characters', () => { + const pipe = new ParseUnitValuePipe(); + expect(pipe.transform('1050&%ç*')).toBe(1050); + }); }); From ba7b6ad8b2cef4f809c4379e23b3263b23aeef28 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 15:18:38 +0200 Subject: [PATCH 96/97] implement test for unit-transformation-pipe --- .../unit-transformation.pipe.spec.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts b/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts index c5eb31501a..9578c36a56 100644 --- a/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts +++ b/frontend/src/app/shared/pipes/unit-value-transformation/unit-transformation.pipe.spec.ts @@ -1,8 +1,39 @@ import { UnitValueTransformationPipe } from './unit-value-transformation.pipe'; +import { Unit } from '../../types/enums/Unit'; describe('UnitTransformationPipe', () => { it('create an instance', () => { const pipe = new UnitValueTransformationPipe(); expect(pipe).toBeTruthy(); }); + + it('should format as Percent', () => { + const pipe = new UnitValueTransformationPipe(); + expect(pipe.transform(380, Unit.PERCENT)).toBe('380%'); + }); + + it('should format as Number', () => { + const pipe = new UnitValueTransformationPipe(); + expect(pipe.transform(380, Unit.NUMBER)).toBe('380'); + }); + + it('should format as FTE', () => { + const pipe = new UnitValueTransformationPipe(); + expect(pipe.transform(380, Unit.FTE)).toBe('380'); + }); + + it('should format as CHF without double value', () => { + const pipe = new UnitValueTransformationPipe(); + expect(pipe.transform(380, Unit.CHF)).toBe('380.-'); + }); + + it('should format as CHF as double value', () => { + const pipe = new UnitValueTransformationPipe(); + expect(pipe.transform(380.987, Unit.CHF)).toBe('380.99'); + }); + + it('should return with no format if unit is not preset one', () => { + const pipe = new UnitValueTransformationPipe(); + expect(pipe.transform(140, 'MEMBERS')).toBe('140'); + }); }); From 6b8eb3c3b807532f8b52f5c590b24f3d4c1ebb79 Mon Sep 17 00:00:00 2001 From: megli2 Date: Wed, 4 Oct 2023 15:22:38 +0200 Subject: [PATCH 97/97] add tests for label transformation --- .../unit-label-transformation.pipe.spec.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts index bd96a3d46f..5654bf7314 100644 --- a/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts +++ b/frontend/src/app/shared/pipes/unit-label-transformation/unit-label-transformation.pipe.spec.ts @@ -1,8 +1,35 @@ import { UnitLabelTransformationPipe } from './unit-label-transformation.pipe'; +import { Unit } from '../../types/enums/Unit'; describe('UnitLabelTransformationPipe', () => { it('create an instance', () => { const pipe = new UnitLabelTransformationPipe(); expect(pipe).toBeTruthy(); }); + + it('Format Percent label', () => { + const pipe = new UnitLabelTransformationPipe(); + expect(pipe.transform(Unit.PERCENT)).toBe(''); + }); + + it('Format FTE label', () => { + const pipe = new UnitLabelTransformationPipe(); + expect(pipe.transform(Unit.FTE)).toBe(Unit.FTE); + }); + + it('Format CHF label', () => { + const pipe = new UnitLabelTransformationPipe(); + expect(pipe.transform(Unit.CHF)).toBe(Unit.CHF); + }); + + it('Format Number label', () => { + const pipe = new UnitLabelTransformationPipe(); + expect(pipe.transform(Unit.NUMBER)).toBe('Zahl'); + }); + + it('Format non-default label', () => { + const pipe = new UnitLabelTransformationPipe(); + const nonDefaultUnit = 'MEMBERS'; + expect(pipe.transform(nonDefaultUnit)).toBe(nonDefaultUnit); + }); });