From 7307cf1ef0da67ceaef88a58ffc8a332ff55f10f Mon Sep 17 00:00:00 2001 From: Benjamin Seber Date: Mon, 28 Oct 2024 16:49:03 +0100 Subject: [PATCH] hide aggregated info when only one person is selected --- .../report/ReportControllerHelper.java | 32 +++++++++++-------- .../templates/reports/user-report.html | 5 ++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main/java/de/focusshift/zeiterfassung/report/ReportControllerHelper.java b/src/main/java/de/focusshift/zeiterfassung/report/ReportControllerHelper.java index 94387b8f..b507fc5d 100644 --- a/src/main/java/de/focusshift/zeiterfassung/report/ReportControllerHelper.java +++ b/src/main/java/de/focusshift/zeiterfassung/report/ReportControllerHelper.java @@ -77,20 +77,24 @@ void addSelectedUserDurationAggregationModelAttributes(Model model, HasWorkDurat final Map plannedByUser = report.plannedWorkingHoursByUser(); final Map deltaByUser = report.deltaDurationByUser(); - final List dtos = plannedByUser.keySet().stream() - .map(userIdComposite -> { - final DeltaWorkingHours delta = deltaByUser.get(userIdComposite); - return new ReportSelectedUserDurationAggregationDto( - userIdComposite.localId().value(), - durationToTimeString(delta.durationInMinutes()), - delta.isNegative(), - durationToTimeString(workedByUser.get(userIdComposite).durationInMinutes()), - durationToTimeString(shouldByUser.get(userIdComposite).durationInMinutes()) - ); - }) - .toList(); - - model.addAttribute("selectedUserDurationAggregation", dtos); + final boolean showAggregatedInformation = report.deltaDurationByUser().size() > 1; + + if (showAggregatedInformation) { + final List dtos = plannedByUser.keySet().stream() + .map(userIdComposite -> { + final DeltaWorkingHours delta = deltaByUser.get(userIdComposite); + return new ReportSelectedUserDurationAggregationDto( + userIdComposite.localId().value(), + durationToTimeString(delta.durationInMinutes()), + delta.isNegative(), + durationToTimeString(workedByUser.get(userIdComposite).durationInMinutes()), + durationToTimeString(shouldByUser.get(userIdComposite).durationInMinutes()) + ); + }) + .toList(); + + model.addAttribute("selectedUserDurationAggregation", dtos); + } } private static SelectableUserDto userToSelectableUserDto(User user, boolean selected) { diff --git a/src/main/resources/templates/reports/user-report.html b/src/main/resources/templates/reports/user-report.html index 660374a9..deb005b1 100644 --- a/src/main/resources/templates/reports/user-report.html +++ b/src/main/resources/templates/reports/user-report.html @@ -60,7 +60,10 @@ >
-
+