Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/306 check in erfassen und bearbeiten #427

Merged
merged 97 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
9473029
generate check in dialog
Vakmeth Sep 26, 2023
5793787
format generated dialog
Vakmeth Sep 26, 2023
7091427
implement structure
Vakmeth Sep 26, 2023
435f5f3
change width of dialog and implement formgroup and corresponding meth…
Vakmeth Sep 26, 2023
6075fd7
change size of textarea to match figma
Vakmeth Sep 26, 2023
1d0745c
align content by adding all elements inside mat-dialog-content tag
Vakmeth Sep 26, 2023
f16b475
finish basic structure of metric and ordinal check-in
Vakmeth Sep 27, 2023
048de70
rename component because we have to implement a different dialog for …
Vakmeth Sep 27, 2023
080b7cd
implement and align metric components of dialog
Vakmeth Sep 27, 2023
8fb88db
restyle confidence component and add margin to match figma mockup
Vakmeth Sep 27, 2023
3c019d3
increase width of slider and delete console log
Vakmeth Sep 27, 2023
a86ff5a
implement correct formating of default value with custom pipe
Vakmeth Sep 27, 2023
842f11c
format pipe file
Vakmeth Sep 27, 2023
5ba1670
implement formgroup with validators and add form control names in tem…
Vakmeth Sep 27, 2023
ff63a2f
fix button position by wrapping buttons into custom flexed div
Vakmeth Sep 27, 2023
a6e174a
set confidence value from confidence component after clicked on submi…
Vakmeth Sep 27, 2023
eeced45
implement method to update value with correct label whenever focues o…
Vakmeth Sep 27, 2023
9df627a
add parseValue function to be able to return value in save method
Vakmeth Sep 27, 2023
16cfc49
implement workflow of creating checkIn in frontend
Vakmeth Sep 27, 2023
a14d3d6
fix error of missing keyResultId in checkIn
Vakmeth Sep 27, 2023
b7da170
update keyResultDetail after creating new checkIn and rename method o…
Vakmeth Sep 28, 2023
1a27a0e
add option to differ between ordinal and metric checkIn dialog
Vakmeth Sep 28, 2023
2f6bfe1
add check to do create request only if created form data is not undef…
Vakmeth Sep 28, 2023
47ae5d0
format error message of input field
Vakmeth Sep 28, 2023
27f9e95
create check-in-form-ordinal component and let detail of keyresult op…
Vakmeth Sep 28, 2023
a473855
format generated files
Vakmeth Sep 28, 2023
f5429a3
include option of not posting check-in if cancel button was clicked
Vakmeth Sep 28, 2023
a4b39f0
move check-in dialogs into seperate folder and create component for c…
Vakmeth Sep 28, 2023
aa84bd3
format base-informations component
Vakmeth Sep 28, 2023
a5183e2
implement structure of base form component
Vakmeth Sep 28, 2023
f60825f
solve type error of validations
Vakmeth Sep 28, 2023
f3211b3
implement continue logic
Vakmeth Sep 28, 2023
ca51d2b
center continue text inside button
Vakmeth Sep 28, 2023
aee872b
fix pipe error of not converting strings by defining value as 0 if st…
Vakmeth Sep 28, 2023
0b9f729
generate new custom input component
Vakmeth Sep 28, 2023
0be272e
format new custom input component
Vakmeth Sep 28, 2023
9218946
fix input positioning
Vakmeth Sep 28, 2023
56286f4
move submit function to clickevent of submit button
Vakmeth Sep 28, 2023
2702143
fix positioning of keyresult information and mat-action buttons
Vakmeth Sep 28, 2023
6529635
implement basic html structure of check-in ordinal form component
Vakmeth Sep 28, 2023
2294e9b
implement parent component which inserts ordinal or metric input
Vakmeth Sep 28, 2023
b5a5035
format new generated files
Vakmeth Sep 28, 2023
46d4f9e
build up typescript of check-in-ordinal component
Vakmeth Sep 28, 2023
27e20b2
insert confidence component into check-in-ordinal form
Vakmeth Sep 28, 2023
9e44f02
fix unset confidence value because of order of commands in saveCheckI…
Vakmeth Sep 28, 2023
1a6f1e8
add label which tells user the dialog step
Vakmeth Sep 28, 2023
5b242a1
add radio button group style
Vakmeth Sep 28, 2023
32bf995
implement radio-button zones
Vakmeth Sep 29, 2023
251220e
implement post action for ordinal check-ins
Vakmeth Sep 29, 2023
1f15f60
format created enum
Vakmeth Sep 29, 2023
8163577
rename zone of KeyResultOrdinalDto to value
Vakmeth Sep 29, 2023
d7e46ea
implement enum which holds unit values and use it in unit-transformat…
Vakmeth Sep 29, 2023
20189c8
implement pipe to transform label of unit into wanted string
Vakmeth Sep 29, 2023
7752376
format generated pipe
Vakmeth Sep 29, 2023
9db46af
fix error of confidence not updating on keyresult detail component
Vakmeth Sep 29, 2023
8b4c348
use constant of constantLibrary in check-in-history to format date
Vakmeth Sep 29, 2023
3c16d9b
open dialog on click to menu
Vakmeth Sep 29, 2023
4c359f3
load all values into form from edited check-in except confidence
Vakmeth Sep 29, 2023
2e19291
fix error of confidence component not setting check-in confidence bec…
Vakmeth Sep 29, 2023
c017613
update check-in in frontend
Vakmeth Sep 29, 2023
836d720
create insert script for new data with of new quarter
Vakmeth Oct 2, 2023
ed552a6
do request only if result of update dialog is not undefined and not null
Vakmeth Oct 2, 2023
2383903
implement option to delete check-ins in frontend
Vakmeth Oct 2, 2023
6dca4c1
format new confirm-dialog which pops up when user tries to delete che…
Vakmeth Oct 2, 2023
c171ffa
implement endpoint to delete check-in by id
Vakmeth Oct 2, 2023
60d6bd7
add okr-tool objectives to bbt
Vakmeth Oct 2, 2023
3d10e3f
implement updating logic after check-in has been deleted
Vakmeth Oct 2, 2023
c89fcad
fix error of post not working when there are no check-ins and optimiz…
Vakmeth Oct 2, 2023
d5955f3
prevent check-in history from opening if no other check-in exists aft…
Vakmeth Oct 2, 2023
0093462
set value of ordinal by default to fail
Vakmeth Oct 2, 2023
44446c4
optimize imports in confidence component
Vakmeth Oct 2, 2023
2b81cb8
rewrite comments
Vakmeth Oct 2, 2023
09dd5a8
fix backend tests
Vakmeth Oct 2, 2023
50e4755
fix frontend tests by adding necessary imports and providers
Vakmeth Oct 3, 2023
107a398
implement test for check-in-base-information form
Vakmeth Oct 3, 2023
88a6a99
resolve clean up feedback
Vakmeth Oct 3, 2023
a311f71
format cleaned up logic in component
Vakmeth Oct 3, 2023
4b947fb
write tests for check-in-form and clean up code
Vakmeth Oct 3, 2023
b7db68d
remove unused if statement
Vakmeth Oct 3, 2023
4fe71cc
implement tests for check-in-form-metric component
Vakmeth Oct 3, 2023
d47e79c
add test in check-in-form-ordinal component
Vakmeth Oct 4, 2023
57321fc
implement tests of confirm-dialog
Vakmeth Oct 4, 2023
aa5ed57
add test of custom-input
Vakmeth Oct 4, 2023
49a03fc
give title to confirmdialog when deleting keyresult and change check-…
Vakmeth Oct 4, 2023
7722f9d
format after bug fixes
Vakmeth Oct 4, 2023
10355fb
disable submit button when form is not valid
Vakmeth Oct 4, 2023
9168a83
delete unused comments
Vakmeth Oct 4, 2023
f49f67a
use === instead of == in checks
Vakmeth Oct 4, 2023
6fa7743
delete unused import
Vakmeth Oct 4, 2023
0ef3c5b
delete unused test loader
Vakmeth Oct 4, 2023
616cf62
parse value with new implemented pipe
Vakmeth Oct 4, 2023
0f11e17
format new implemented pipe
Vakmeth Oct 4, 2023
888afb9
fix tests by adding created pipe as provider to test suites
Vakmeth Oct 4, 2023
e76731e
implement regex which replaces non number characters
Vakmeth Oct 4, 2023
cc53b65
add tests to check if parse-pipe works correctly
Vakmeth Oct 4, 2023
ba7b6ad
implement test for unit-transformation-pipe
Vakmeth Oct 4, 2023
6b8eb3c
add tests for label transformation
Vakmeth Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,13 @@ public ResponseEntity<CheckInDto> 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);
}
}
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions backend/src/test/java/ch/puzzle/okr/KeyResultTestHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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\"}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down Expand Up @@ -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)))
Expand Down
20 changes: 20 additions & 0 deletions frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ 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 { CheckInFormMetricComponent } from './shared/dialog/checkin/check-in-form-metric/check-in-form-metric.component';
import { UnitValueTransformationPipe } from './shared/pipes/unit-value-transformation/unit-value-transformation.pipe';
import { CheckInFormOrdinalComponent } from './shared/dialog/checkin/check-in-form-ordinal/check-in-form-ordinal.component';
import { CheckInBaseInformationsComponent } from './shared/dialog/checkin/check-in-base-informations/check-in-base-informations.component';
import { CustomInputComponent } from './shared/custom/custom-input/custom-input.component';
import { 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';
import { ParseUnitValuePipe } from './shared/pipes/parse-unit-value/parse-unit-value.pipe';

function initOauthFactory(configService: ConfigService, oauthService: OAuthService) {
return async () => {
Expand Down Expand Up @@ -95,6 +103,16 @@ export const MY_FORMATS = {
ApplicationBannerComponent,
KeyResultDialogComponent,
ConfirmDialogComponent,
CheckInFormComponent,
CheckInFormMetricComponent,
UnitValueTransformationPipe,
CheckInFormOrdinalComponent,
CheckInBaseInformationsComponent,
CustomInputComponent,
CheckInFormComponent,
UnitLabelTransformationPipe,
ConfirmDialogComponent,
ParseUnitValuePipe,
],
imports: [
CommonModule,
Expand Down Expand Up @@ -145,6 +163,8 @@ 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 },
UnitValueTransformationPipe,
ParseUnitValuePipe,
],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/app/confidence/confidence.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<div class="d-flex align-items-center gap-1 confidence-container" *ngIf="keyResult?.lastCheckIn?.confidence">
<div class="d-flex align-items-center gap-1 confidence-container" *ngIf="checkIn.confidence">
<div
[ngClass]="edit ? 'keyResult-attribute-edit' : 'keyResult-attribute-show'"
[ngStyle]="{ 'background-color': backgroundColor }"
>
<p [ngClass]="edit ? 'fw-normal' : 'fw-bold'" data-testid="confidence">
{{ keyResult.lastCheckIn?.confidence }}/{{ max }}
</p>
<p [ngClass]="edit ? 'fw-normal' : 'fw-bold'" data-testid="confidence">{{ checkIn.confidence }}/{{ max }}</p>
</div>

<mat-slider *ngIf="edit" [max]="max" [min]="min" [step]="1" [showTickMarks]="true" color="accent">
<input matSliderThumb [(ngModel)]="keyResult.lastCheckIn!.confidence" />
<input matSliderThumb [(ngModel)]="checkIn.confidence" />
</mat-slider>
</div>
4 changes: 4 additions & 0 deletions frontend/src/app/confidence/confidence.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ p {
width: 63px;
height: 23px;
}

mat-slider {
min-width: 370px;
}
8 changes: 4 additions & 4 deletions frontend/src/app/confidence/confidence.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
});

Expand All @@ -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();
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/app/confidence/confidence.component.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -13,12 +11,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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
Expand Down
21 changes: 17 additions & 4 deletions frontend/src/app/keyresult-detail/keyresult-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ <h1 class="mb-2 title">{{ keyResult.title }}</h1>
<div class="d-flex justify-content-between mb-2 align-items-center">
<div>
<p class="text-small">Confidence</p>
<app-confidence [keyResult]="keyResult" [edit]="false" [backgroundColor]="'#F5F5F5'"></app-confidence>
<app-confidence
*ngIf="keyResult.lastCheckIn"
[checkIn]="keyResult.lastCheckIn!"
[edit]="false"
[backgroundColor]="'#F5F5F5'"
></app-confidence>
</div>
</div>
<div class="d-flex gap-4 mb-5 flex-row jus">
Expand Down Expand Up @@ -49,14 +54,22 @@ <h1 class="mb-2 title">{{ keyResult.title }}</h1>
</div>
</ng-container>
</div>
<div *ngIf="keyResult.lastCheckIn?.createdOn" class="mb-3">
<div *ngIf="keyResult.lastCheckIn?.modifiedOn" class="mb-3">
<h2 class="sub-title-keyresult fw-bold mb-2">
Letztes Check-in ({{ keyResult.lastCheckIn?.modifiedOn | date: "dd.MM.yyy" }})
</h2>
<p>{{ keyResult.lastCheckIn?.changeInfo }}</p>
</div>
<div *ngIf="!keyResult.lastCheckIn?.modifiedOn && keyResult.lastCheckIn?.createdOn" class="mb-3">
<h2 class="sub-title-keyresult fw-bold mb-2">
Letztes Check-in ({{ keyResult.lastCheckIn?.createdOn | date: "dd.MM.yyy" }})
</h2>
<p>{{ keyResult.lastCheckIn?.changeInfo }}</p>
</div>
<span class="d-flex justify-content-start mb-3">
<button class="add-button" mat-button (click)="checkInHistory()">Alle Check-ins anzeigen</button>
<button *ngIf="keyResult.lastCheckIn" class="add-button" mat-button (click)="checkInHistory()">
Alle Check-ins anzeigen
</button>
</span>

<div class="mb-3">
Expand All @@ -65,6 +78,6 @@ <h2 class="sub-title-keyresult fw-bold">Beschrieb</h2>
</div>
<div class="d-flex align-items-center flex-row-reverse justify-content-end gap-3">
<button class="add-button" mat-button (click)="openEditKeyResultDialog()">Key Result bearbeiten</button>
<button mat-flat-button color="primary">Check-in erfassen</button>
<button mat-flat-button color="primary" (click)="openCheckInForm()">Check-in erfassen</button>
</div>
</div>
51 changes: 48 additions & 3 deletions frontend/src/app/keyresult-detail/keyresult-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ 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 { CheckInService } from '../shared/services/check-in.service';
import { CheckInFormComponent } from '../shared/dialog/checkin/check-in-form/check-in-form.component';

@Component({
selector: 'app-keyresult-detail',
Expand All @@ -20,10 +23,33 @@ 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.reopenCheckInHistoryDialog.subscribe((result) => {
/* 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();
}
/* 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) => {
this.keyResult = fullKeyResult;
this.changeDetectorRef.markForCheck();
if (this.keyResult.lastCheckIn != null) {
this.checkInHistory();
}
});
}
return;
}
this.checkInHistory();
});
}

ngOnChanges() {
this.keyResultService.getFullKeyResult(this.keyResultId).subscribe((fullKeyResult) => {
Expand All @@ -35,16 +61,18 @@ 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: {
keyResultId: this.keyResult.id,
keyResult: this.keyResult,
},
});

dialogRef.afterClosed().subscribe(() => {});
}

Expand Down Expand Up @@ -79,4 +107,21 @@ export class KeyresultDetailComponent implements OnChanges {
this.changeDetectorRef.markForCheck();
});
}

openCheckInForm() {
const dialogRef = this.dialog.open(CheckInFormComponent, {
data: {
keyResult: this.keyResult,
},
width: '719px',
});
dialogRef.afterClosed().subscribe((result) => {
if (result != undefined && result != '') {
this.checkInService.createCheckIn(result.data).subscribe((createdCheckIn) => {
this.keyResult = { ...this.keyResult, lastCheckIn: createdCheckIn };
this.changeDetectorRef.detectChanges();
});
}
});
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/keyresult/keyresult.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="d-flex align-items-center flex-wrap justify-content-end">
<p class="sub-title">Confidence</p>
<app-confidence [edit]="false" [keyResult]="keyResult" class="ms-2"></app-confidence>
<app-confidence [edit]="false" [checkIn]="keyResult.lastCheckIn!" class="ms-2"></app-confidence>
</div>
</div>
<div *ngIf="keyResult.lastCheckIn == null" class="sub-title">Noch kein Check-in vorhanden</div>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/keyresult/keyresult.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ 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: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<form [formGroup]="formGroup">
<input matInput formControlName="{{ formControlNameGiven }}" />
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
input {
height: 32px;
}
Loading