Skip to content

Commit

Permalink
Release 3.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSlimvReal authored Feb 1, 2024
2 parents cb5f14e + f86ca9d commit 9f84fc6
Show file tree
Hide file tree
Showing 96 changed files with 435 additions and 592 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"util": "^0.12.5",
"uuid": "^9.0.1",
"webpack": "5.89.0",
"zone.js": "~0.14.2"
"zone.js": "~0.14.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const demoChildren = [
];

const simpleEvent = Note.create(new Date(), "some meeting");
demoChildren.forEach((c) => simpleEvent.addChild(c.getId()));
demoChildren.forEach((c) => simpleEvent.addChild(c));

const longEvent = Note.create(new Date(), "another meeting");
longEvent.text =
Expand All @@ -40,12 +40,11 @@ longEvent.category = {
label: "Guardians Meeting",
isMeeting: true,
};
demoChildren.forEach((c) => longEvent.addChild(c.getId()));
demoChildren.forEach((c) => longEvent.addChild(c));

const activityEvent = Note.create(new Date(), "Coaching Batch C");
activityEvent.relatesTo =
RecurringActivity.create("Coaching Batch C").getId(true);
demoChildren.forEach((c) => activityEvent.addChild(c.getId()));
activityEvent.relatesTo = RecurringActivity.create("Coaching Batch C").getId();
demoChildren.forEach((c) => activityEvent.addChild(c));

export const OneTimeEvent = Template.bind({});
OneTimeEvent.args = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AttendanceService } from "../../attendance.service";
import { EventNote } from "../../model/event-note";
import { MockedTestingModule } from "../../../../utils/mocked-testing.module";
import { TEST_USER } from "../../../../core/user/demo-user-generator.service";
import { User } from "../../../../core/user/user";

describe("RollCallSetupComponent", () => {
let component: RollCallSetupComponent;
Expand Down Expand Up @@ -64,8 +65,12 @@ describe("RollCallSetupComponent", () => {
flush();

expect(component.existingEvents.length).toBe(2);
expect(component.existingEvents[0].authors).toEqual([TEST_USER]);
expect(component.existingEvents[1].authors).toEqual([TEST_USER]);
expect(component.existingEvents[0].authors).toEqual([
`${User.ENTITY_TYPE}:${TEST_USER}`,
]);
expect(component.existingEvents[1].authors).toEqual([
`${User.ENTITY_TYPE}:${TEST_USER}`,
]);
}));

it("should only show active activities", fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class RollCallSetupComponent implements OnInit {
private async createEventForActivity(
activity: RecurringActivity,
): Promise<NoteForActivitySetup> {
if (this.existingEvents.find((e) => e.relatesTo === activity.getId(true))) {
if (this.existingEvents.find((e) => e.relatesTo === activity.getId())) {
return undefined;
}

Expand All @@ -166,7 +166,7 @@ export class RollCallSetupComponent implements OnInit {
let score = 0;

const activityAssignedUsers = this.allActivities.find(
(a) => a.getId(true) === event.relatesTo,
(a) => a.getId() === event.relatesTo,
)?.assignedTo;
// use parent activities' assigned users and only fall back to event if necessary
const assignedUsers = activityAssignedUsers ?? event.authors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const demoChildren = [
DemoChildGenerator.generateEntity("2"),
DemoChildGenerator.generateEntity("3"),
];
demoChildren.forEach((c) => demoEvent.addChild(c.getId()));
demoChildren.forEach((c) => demoEvent.addChild(c));

const demoActivities = [
DemoActivityGeneratorService.generateActivityForChildren(demoChildren),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe("RollCallComponent", () => {
it("should not record attendance if childId does not exist", fakeAsync(() => {
const nonExistingChildId = "notExistingChild";
const noteWithNonExistingChild = new Note();
noteWithNonExistingChild.addChild(participant1.getId());
noteWithNonExistingChild.addChild(participant1);
noteWithNonExistingChild.addChild(nonExistingChildId);
component.eventEntity = noteWithNonExistingChild;

Expand All @@ -113,8 +113,8 @@ describe("RollCallComponent", () => {

it("should correctly assign the attendance", fakeAsync(() => {
const note = new Note("noteWithAttendance");
note.addChild(participant1.getId());
note.addChild(participant2.getId());
note.addChild(participant1);
note.addChild(participant2);

component.eventEntity = note;
component.ngOnChanges(dummyChanges);
Expand All @@ -124,16 +124,16 @@ describe("RollCallComponent", () => {
tick(1000);
component.markAttendance(ABSENT);

expect(note.getAttendance(participant1.getId()).status).toEqual(PRESENT);
expect(note.getAttendance(participant2.getId()).status).toEqual(ABSENT);
expect(note.getAttendance(participant1).status).toEqual(PRESENT);
expect(note.getAttendance(participant2).status).toEqual(ABSENT);
flush();
}));

it("should mark roll call as done when all existing children are finished", fakeAsync(() => {
const note = new Note();
note.addChild(participant1.getId());
note.addChild(participant1);
note.addChild("notExistingChild");
note.addChild(participant2.getId());
note.addChild(participant2);

spyOn(component.complete, "emit");
component.eventEntity = note;
Expand Down Expand Up @@ -245,7 +245,7 @@ describe("RollCallComponent", () => {
) {
const event = new Note();
for (const p of participantsInput) {
event.addChild(p.getId());
event.addChild(p);
}
component.eventEntity = event;
component.ngOnChanges(dummyChanges);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ describe("AttendanceCalendarComponent", () => {
const childWithoutAttendance = new Child("childWithoutAttendance");
const note = new Note();
note.date = new Date();
note.addChild(attendedChild.getId());
note.addChild(absentChild.getId());
note.addChild(childWithoutAttendance.getId());
note.addChild(attendedChild);
note.addChild(absentChild);
note.addChild(childWithoutAttendance);
const presentAttendance = defaultAttendanceStatusTypes.find(
(it) => it.id === "PRESENT",
);
const absentAttendance = defaultAttendanceStatusTypes.find(
(it) => it.id === "ABSENT",
);
note.getAttendance(attendedChild.getId()).status = presentAttendance;
note.getAttendance(absentChild.getId()).status = absentAttendance;
note.getAttendance(attendedChild).status = presentAttendance;
note.getAttendance(absentChild).status = absentAttendance;
component.records = [note];

component.selectDay(new Date());
Expand Down
25 changes: 13 additions & 12 deletions src/app/child-dev-project/attendance/attendance.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ChildSchoolRelation } from "../children/model/childSchoolRelation";
import { Child } from "../children/model/child";
import { Note } from "../notes/model/note";
import { DatabaseTestingModule } from "../../utils/database-testing.module";
import { Entity } from "../../core/entity/model/entity";

describe("AttendanceService", () => {
let service: AttendanceService;
Expand Down Expand Up @@ -41,10 +42,10 @@ describe("AttendanceService", () => {
activity1 = RecurringActivity.create("activity 1");
activity2 = RecurringActivity.create("activity 2");

e1_1 = createEvent(moment("2020-01-01").toDate(), activity1.getId(true));
e1_2 = createEvent(moment("2020-01-02").toDate(), activity1.getId(true));
e1_3 = createEvent(moment("2020-03-02").toDate(), activity1.getId(true));
e2_1 = createEvent(moment("2020-01-01").toDate(), activity2.getId(true));
e1_1 = createEvent(moment("2020-01-01").toDate(), activity1.getId());
e1_2 = createEvent(moment("2020-01-02").toDate(), activity1.getId());
e1_3 = createEvent(moment("2020-03-02").toDate(), activity1.getId());
e2_1 = createEvent(moment("2020-01-01").toDate(), activity2.getId());

TestBed.configureTestingModule({
imports: [DatabaseTestingModule],
Expand Down Expand Up @@ -186,15 +187,13 @@ describe("AttendanceService", () => {

expect(actualAttendences).toHaveSize(2);
expectEntitiesToMatch(
actualAttendences.find(
(t) => t.activity.getId(true) === activity1.getId(true),
).events,
actualAttendences.find((t) => t.activity.getId() === activity1.getId())
.events,
[e1_1, e1_2],
);
expectEntitiesToMatch(
actualAttendences.find(
(t) => t.activity.getId(true) === activity2.getId(true),
).events,
actualAttendences.find((t) => t.activity.getId() === activity2.getId())
.events,
[e2_1],
);

Expand Down Expand Up @@ -300,7 +299,6 @@ describe("AttendanceService", () => {
const event = await service.createEventForActivity(activity, date);

expect(mockQueryRelationsOf).toHaveBeenCalledWith(
"school",
linkedSchool.getId(),
date,
);
Expand All @@ -319,7 +317,10 @@ describe("AttendanceService", () => {
duplicateChildRelation.childId = duplicateChild.getId();
duplicateChildRelation.schoolId = linkedSchool.getId();
const anotherRelation = new ChildSchoolRelation();
anotherRelation.childId = "another child id";
anotherRelation.childId = Entity.createPrefixedId(
Child.ENTITY_TYPE,
"another_child_id",
);
anotherRelation.schoolId = linkedSchool.getId();
await entityMapper.saveAll([duplicateChildRelation, anotherRelation]);

Expand Down
15 changes: 5 additions & 10 deletions src/app/child-dev-project/attendance/attendance.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,7 @@ export class AttendanceService {
return attMonth;
}

const events = await this.getEventsForActivity(
activity.getId(true),
sinceDate,
);
const events = await this.getEventsForActivity(activity.getId(), sinceDate);

for (const event of events) {
const record = getOrCreateAttendancePeriod(event);
Expand Down Expand Up @@ -232,10 +229,8 @@ export class AttendanceService {
childId,
);

const visitedSchools = await this.childrenService.queryActiveRelationsOf(
"child",
childId,
);
const visitedSchools =
await this.childrenService.queryActiveRelationsOf(childId);
for (const currentRelation of visitedSchools) {
const activitiesThroughRelation = await this.dbIndexing.queryIndexDocs(
RecurringActivity,
Expand Down Expand Up @@ -266,7 +261,7 @@ export class AttendanceService {
date,
);
instance.schools = activity.linkedGroups;
instance.relatesTo = activity.getId(true);
instance.relatesTo = activity.getId();
instance.category = activity.type;
return instance;
}
Expand Down Expand Up @@ -296,7 +291,7 @@ export class AttendanceService {
): Promise<string[]> {
const childIdPromises = linkedGroups.map((groupId) =>
this.childrenService
.queryActiveRelationsOf("school", groupId, date)
.queryActiveRelationsOf(groupId, date)
.then((relations) =>
relations.map((r) => r.childId).filter((id) => !!id),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DemoActivityEventsGeneratorService extends DemoDataGenerator<EventN
const eventNote = EventNote.create(date, activity.title);
eventNote.authors = activity.assignedTo;
eventNote.category = activity.type;
eventNote.relatesTo = activity.getId(true); // relatesTo requires the id including prefix!
eventNote.relatesTo = activity.getId();

for (const participantId of activity.participants) {
eventNote.addChild(participantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,6 @@ export function generateEventWithAttendance(
event.getAttendance(att[0]).remarks = att[2];
}
}
event.relatesTo = activity?.getId(true);
event.relatesTo = activity?.getId();
return event;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { Component, Input } from "@angular/core";
import { Aser } from "../model/aser";
import { ChildrenService } from "../../children.service";
import { Child } from "../../model/child";
import { DynamicComponent } from "../../../../core/config/dynamic-components/dynamic-component.decorator";
import { EntitiesTableComponent } from "../../../../core/common-components/entities-table/entities-table.component";

import { FormFieldConfig } from "../../../../core/common-components/entity-form/FormConfig";
import { RelatedEntitiesComponent } from "../../../../core/entity-details/related-entities/related-entities.component";
import { EntityMapperService } from "../../../../core/entity/entity-mapper/entity-mapper.service";
import { EntityRegistry } from "../../../../core/entity/database-entity.decorator";
import { ScreenWidthObserver } from "../../../../utils/media/screen-size-observer.service";

@DynamicComponent("Aser")
@Component({
Expand All @@ -33,21 +29,14 @@ export class AserComponent extends RelatedEntitiesComponent<Aser> {
{ id: "remarks", visibleFrom: "md" },
];

constructor(
private childrenService: ChildrenService,
entityMapper: EntityMapperService,
entityRegistry: EntityRegistry,
screenWidthObserver: ScreenWidthObserver,
) {
super(entityMapper, entityRegistry, screenWidthObserver);
}

override async initData() {
this.data = (
await this.childrenService.getAserResultsOfChild(this.entity.getId())
).sort(
(a, b) =>
(b.date ? b.date.valueOf() : 0) - (a.date ? a.date.valueOf() : 0),
);
super
.initData()
.then(() =>
this.data.sort(
(a, b) =>
(b.date ? b.date.valueOf() : 0) - (a.date ? a.date.valueOf() : 0),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import moment from "moment";
import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
import { DynamicComponent } from "../../../../core/config/dynamic-components/dynamic-component.decorator";
import {
ScreenWidthObserver,
ScreenSize,
ScreenWidthObserver,
} from "../../../../utils/media/screen-size-observer.service";
import { NgForOf, SlicePipe } from "@angular/common";
import { AttendanceBlockComponent } from "../../../attendance/attendance-block/attendance-block.component";
Expand Down
Loading

0 comments on commit 9f84fc6

Please sign in to comment.