Skip to content

Commit

Permalink
hide aggregated info when only one person is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
bseber committed Nov 15, 2024
1 parent 5766b56 commit 7307cf1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,24 @@ void addSelectedUserDurationAggregationModelAttributes(Model model, HasWorkDurat
final Map<UserIdComposite, PlannedWorkingHours> plannedByUser = report.plannedWorkingHoursByUser();
final Map<UserIdComposite, DeltaWorkingHours> deltaByUser = report.deltaDurationByUser();

final List<ReportSelectedUserDurationAggregationDto> 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<ReportSelectedUserDurationAggregationDto> 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) {
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/templates/reports/user-report.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
>
<div th:replace="~{__${chartFragment}__}"></div>
</div>
<div class="xs:px-4 w-full overflow-x-auto">
<div
th:if="${selectedUserDurationAggregation != null}"
class="xs:px-4 w-full overflow-x-auto"
>
<table class="report-person-detail-table">
<thead>
<tr>
Expand Down

0 comments on commit 7307cf1

Please sign in to comment.