Skip to content

Commit 75b88c9

Browse files
authored
fix: make 'All Teams' button work as expected #1675
1 parent 896d5b7 commit 75b88c9

File tree

8 files changed

+33
-29
lines changed

8 files changed

+33
-29
lines changed

backend/src/main/java/ch/puzzle/okr/controller/EvaluationViewController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public EvaluationViewController(EvaluationViewMapper evaluationViewMapper,
3737
@ApiResponse(responseCode = "404", description = "The quarter or one of the teams were not found", content = @Content),
3838
@ApiResponse(responseCode = "401", description = "Not Authorized", content = @Content) })
3939
@GetMapping("")
40-
public ResponseEntity<EvaluationDto> getEvaluation(@RequestParam(name = "team")
40+
public ResponseEntity<EvaluationDto> getEvaluation(@RequestParam(name = "team", required = false)
4141
@Parameter(description = "List of Team ids the statistics are requested for") List<Long> teamIds,
4242
@RequestParam(name = "quarter")
4343
@Parameter(description = "Quarter id the statistics are requested for ") Long quarterId) {

backend/src/main/java/ch/puzzle/okr/service/validation/EvaluationViewValidationService.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@ public class EvaluationViewValidationService
1515
ValidationBase<EvaluationView, RowId, EvaluationViewRepository, EvaluationViewPersistenceService> {
1616

1717
private final QuarterValidationService quarterValidationService;
18-
private final TeamValidationService teamValidationService;
1918

2019
EvaluationViewValidationService(EvaluationViewPersistenceService persistenceService,
21-
QuarterValidationService quarterValidationService,
22-
TeamValidationService teamValidationService) {
20+
QuarterValidationService quarterValidationService) {
2321
super(persistenceService);
2422
this.quarterValidationService = quarterValidationService;
25-
this.teamValidationService = teamValidationService;
2623
}
2724

2825
public void validateOnGet(TeamQuarterFilter filter) {
29-
if (filter.quarterId() == null || filter.teamIds().isEmpty()) {
26+
if (filter.quarterId() == null) {
3027
throw new OkrResponseStatusException(HttpStatus.BAD_REQUEST,
31-
"Es muss mindestens 1 Team und 1 Quartal ausgewählt sein");
28+
"Es muss mindestens 1 Quartal ausgewählt sein");
3229
}
33-
filter.teamIds().forEach(teamValidationService::validateOnGet);
3430
quarterValidationService.validateOnGet(filter.quarterId());
3531
}
3632

backend/src/test/java/ch/puzzle/okr/service/validation/EvaluationViewValidationServiceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class EvaluationViewValidationServiceTest {
2626
void shouldCallProperMethodsToValidateOnGet() {
2727
TeamQuarterFilter ids = new TeamQuarterFilter(List.of(1L, 2L), 1L);
2828
evaluationViewValidationService.validateOnGet(ids);
29-
verify(teamValidationService, times(2)).validateOnGet(any());
3029
verify(quarterValidationService, times(1)).validateOnGet(any());
3130
}
3231
}

frontend/src/app/shared/application-page/application-page.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
>
77
<!-- <ng-content select="content"></ng-content>-->
88
<ng-content></ng-content>
9-
<div *ngIf="(elements$ | async)?.length === 0" class="d-flex align-items-center flex-column pt-5 gap-5">
9+
@if ((elements$ | async)?.length === 0 || getFilterPageChange().teamIds.length === 0) {
10+
<div class="d-flex align-items-center flex-column pt-5 gap-5">
1011
<p id="no-team-text">Kein Team ausgewählt</p>
1112
<img
1213
src="{{ backgroundLogoSrc$ | async }}"
@@ -15,5 +16,6 @@
1516
class="puzzle-logo"
1617
/>
1718
</div>
19+
}
1820
</div>
1921
<router-outlet></router-outlet>

frontend/src/app/statistics/statistics-information/statistics-information.component.spec.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,18 @@ describe('StatisticsInformationComponent', () => {
3333
[0,
3434
50,
3535
'0px'],
36-
[10,
36+
[0.5,
3737
50,
38-
'1000px'], // 10 * 100 = 1000px
38+
'25px'], // 0.5 * 50 = 25px
3939
[1,
4040
50,
41-
'100px'], // 1 * 100 = 100px
42-
[25,
41+
'50px'], // 1 * 50 = 50px
42+
[0.75,
4343
50,
44-
'2500px'], // 25 * 100 = 2500px
45-
[10,
46-
100,
47-
'1000px'], // 10 * 100 = 1000px (maxHeightInPx doesn't affect the result)
48-
[5,
44+
'37.5px'], // 0.75 * 50 = 37.5px
45+
[0.5,
4946
20,
50-
'500px'] // 5 * 100 = 500px
47+
'10px'] // 0.5 * 20 = 10px
5148
])('with chartValue %i and maxHeightInPx %i, should return %s', (chartValue, maxHeightInPx, expectedHeight) => {
5249
component.chartValue = chartValue;
5350
component.maxHeightInPx = maxHeightInPx;

frontend/src/app/statistics/statistics-information/statistics-information.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export class StatisticsInformationComponent {
2020
@Input() maxHeightInPx = 50;
2121

2222
get chartHeight(): string {
23-
const percentage = this.chartValue / this.maxHeightInPx * 100;
24-
const heightInPx = percentage * this.maxHeightInPx;
23+
// Chart value is already a percentage. We can expect it to never be higher than 1.
24+
const heightInPx = this.chartValue * this.maxHeightInPx;
2525
return heightInPx + 'px';
2626
}
2727
}

frontend/src/app/statistics/statistics.component.html

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@ <h1> Auswertung </h1>
2020
Quartal
2121
<app-quarter-filter [showBacklog]="false"></app-quarter-filter>
2222
</div>
23-
<app-team-filter [minTeams]="1"></app-team-filter>
23+
<app-team-filter></app-team-filter>
2424
</div>
2525

2626

27-
<div *ngIf="statistics| async as statistics;" class="d-flex flex-column ">
27+
@if (activeFilter?.teamIds?.length != 0) {
28+
@if (statistics | async; as statistics) {
29+
<div class="d-flex flex-column ">
30+
@if (statistics.objectiveAmount == 0 && statistics.keyResultAmount == 0) {
2831
<div
2932
class="alert alert-warning bg-warning-subtle"
30-
*ngIf="statistics.objectiveAmount ==0 && statistics.keyResultAmount ==0"
3133
[attr.data-testId]="'no-data-banner'"
3234
>
3335
Für dieses Team ist im ausgewählten Zeitraum kein Objective vorhanden.
3436
</div>
37+
}
3538
<div class="row row-cols-1 row-cols-md-2 row-cols-xxl-3 g-4">
3639
<app-statistics-card [title]="'Objectives und Key Results'" [attr.data-testId]="'objectives-key-results'">
3740
<app-statistics-information [topContent]="'Objectives'"> {{ statistics.objectiveAmount }}
@@ -74,9 +77,9 @@ <h1> Auswertung </h1>
7477
</app-statistics-information>
7578
</app-statistics-card>
7679

80+
@if (krRelation(statistics.keyResultsMetricAmount, statistics.keyResultsOrdinalAmount); as relation) {
7781
<app-statistics-card
7882
[attr.data-testId]="'kr-type-relation'"
79-
*ngIf="krRelation(statistics.keyResultsMetricAmount, statistics.keyResultsOrdinalAmount) as relation"
8083
[title]="'Verhältnis metrische vs. ordinale Key Results'"
8184
[barProgress]="relation.metric"
8285
[barColorPreset]="'relation'"
@@ -88,12 +91,13 @@ <h1> Auswertung </h1>
8891
{{ statistics.keyResultsOrdinalAmount }}
8992
</app-statistics-information>
9093
</app-statistics-card>
94+
}
9195

96+
@if (krProgressRelation(statistics); as relation) {
9297
<app-statistics-card
9398
[attr.data-testId]="'kr-progress-relation'"
9499
[title]="'Verteilung der Key Results'"
95100
[subtitle]="'Nur eingecheckte Key Results berücksichtigt'"
96-
*ngIf="krProgressRelation(statistics) as relation"
97101
>
98102
<app-statistics-information
99103
[topContent]="statistics.keyResultsInFailAmount"
@@ -132,8 +136,11 @@ <h1> Auswertung </h1>
132136
{{ relation.stretch | percent : '1.0-1' }}
133137
</app-statistics-information>
134138
</app-statistics-card>
139+
}
135140
</div>
136141
</div>
142+
}
143+
}
137144
</div>
138145

139146
</app-application-page>

frontend/src/app/statistics/statistics.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ export class StatisticsComponent {
1414

1515
statistics = new Observable<Statistics>();
1616

17-
loadOverview(filterpage: FilterPageChange) {
17+
activeFilter: FilterPageChange | undefined;
18+
19+
loadOverview(filterPage: FilterPageChange) {
20+
this.activeFilter = filterPage;
1821
this.statistics = this.evaluationService
19-
.getStatistics(filterpage.quarterId, filterpage.teamIds)
22+
.getStatistics(filterPage.quarterId, filterPage.teamIds)
2023
.pipe(catchError(() => {
2124
return EMPTY;
2225
}));

0 commit comments

Comments
 (0)