Skip to content

Commit ffa150f

Browse files
committed
fix(attendance): display absent participants even if added via group
fixes #2618
1 parent 2666517 commit ffa150f

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,47 @@ describe("AttendanceWeekDashboardComponent", () => {
9090
]);
9191
});
9292

93+
it("should display children also if added via activity group or manually", async () => {
94+
const absentChild = new TestEntity();
95+
const mondayLastWeek = moment().startOf("isoWeek").subtract(7, "days");
96+
const e1 = EventNote.create(mondayLastWeek.toDate());
97+
const e2 = EventNote.create(moment(e1.date).add(1, "day").toDate());
98+
const absentStatus = defaultAttendanceStatusTypes.find(
99+
(s) => s.countAs === AttendanceLogicalStatus.ABSENT,
100+
);
101+
[e1, e2].forEach((e) => {
102+
e.addChild(absentChild);
103+
e.getAttendance(absentChild).status = absentStatus;
104+
});
105+
const activity = new RecurringActivity();
106+
delete activity.participants; // no participants set directly on RecurringActivity
107+
const attendance = ActivityAttendance.create(new Date(), [e1, e2]);
108+
attendance.activity = activity;
109+
mockAttendanceService.getAllActivityAttendancesForPeriod.and.resolveTo([
110+
attendance,
111+
]);
112+
113+
await component.ngOnInit();
114+
115+
expect(component.entries).toEqual([
116+
[
117+
{
118+
childId: absentChild.getId(),
119+
activity: activity,
120+
attendanceDays: [
121+
// sundays are excluded
122+
e1.getAttendance(absentChild),
123+
e2.getAttendance(absentChild),
124+
undefined,
125+
undefined,
126+
undefined,
127+
undefined,
128+
],
129+
},
130+
],
131+
]);
132+
});
133+
93134
function expectTimePeriodCalled(from: moment.Moment, to: moment.Moment) {
94135
mockAttendanceService.getAllActivityAttendancesForPeriod.calls.reset();
95136

src/app/child-dev-project/attendance/dashboard-widgets/attendance-week-dashboard/attendance-week-dashboard.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export class AttendanceWeekDashboardComponent
140140
}
141141

142142
const results: AttendanceWeekRow[] = [];
143-
for (const participant of att.activity.participants) {
143+
for (const participant of att.participants) {
144144
const eventAttendances = [];
145145

146146
let day = moment(from);

src/app/child-dev-project/attendance/model/activity-attendance.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ export class ActivityAttendance extends Entity {
5353
*/
5454
activity: RecurringActivity;
5555

56+
/**
57+
* List of (actual, recorded in at least one event) participants.
58+
*/
59+
get participants(): string[] {
60+
return Array.from(new Set(this.events.flatMap((event) => event.children)));
61+
}
62+
5663
/**
5764
* Mapping child ids to a map with all *logical* status as object keys and their counts as values.
5865
*/

0 commit comments

Comments
 (0)