Skip to content

Commit

Permalink
fix(attendance): display absent participants even if added via group
Browse files Browse the repository at this point in the history
fixes #2618
  • Loading branch information
sleidig committed Oct 23, 2024
1 parent 2666517 commit 4f5546c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,47 @@ describe("AttendanceWeekDashboardComponent", () => {
]);
});

it("should display children also if added via activity group or manually", async () => {
const absentChild = new TestEntity();
const mondayLastWeek = moment().startOf("isoWeek").subtract(7, "days");
const e1 = EventNote.create(mondayLastWeek.toDate());
const e2 = EventNote.create(moment(e1.date).add(1, "day").toDate());
const absentStatus = defaultAttendanceStatusTypes.find(
(s) => s.countAs === AttendanceLogicalStatus.ABSENT,
);
[e1, e2].forEach((e) => {
e.addChild(absentChild);
e.getAttendance(absentChild).status = absentStatus;
});
const activity = new RecurringActivity();
delete activity.participants; // no participants set directly on RecurringActivity
const attendance = ActivityAttendance.create(new Date(), [e1, e2]);
attendance.activity = activity;
mockAttendanceService.getAllActivityAttendancesForPeriod.and.resolveTo([
attendance,
]);

await component.ngOnInit();

expect(component.entries).toEqual([
[
{
childId: absentChild.getId(),
activity: activity,
attendanceDays: [
// sundays are excluded
e1.getAttendance(absentChild),
e2.getAttendance(absentChild),
undefined,
undefined,
undefined,
undefined,
],
},
],
]);
});

function expectTimePeriodCalled(from: moment.Moment, to: moment.Moment) {
mockAttendanceService.getAllActivityAttendancesForPeriod.calls.reset();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class AttendanceWeekDashboardComponent
}

const results: AttendanceWeekRow[] = [];
for (const participant of att.activity.participants) {
for (const participant of att.participants) {
const eventAttendances = [];

let day = moment(from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export class ActivityAttendance extends Entity {
*/
activity: RecurringActivity;

/**
* List of (actual, recorded in at least one event) participants.
*/
get participants(): string[] {
return Array.from(new Set(this.events.flatMap((event) => event.children)));
}

/**
* Mapping child ids to a map with all *logical* status as object keys and their counts as values.
*/
Expand Down

0 comments on commit 4f5546c

Please sign in to comment.