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 22, 2024
1 parent 7174d7c commit 8e80733
Show file tree
Hide file tree
Showing 3 changed files with 51 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,15 @@ 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 8e80733

Please sign in to comment.