diff --git a/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.html b/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.html
deleted file mode 100644
index 0cb187e2f0..0000000000
--- a/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.html
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.scss b/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.scss
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.spec.ts b/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.spec.ts
deleted file mode 100644
index c5881318bb..0000000000
--- a/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.spec.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-import {
- ComponentFixture,
- fakeAsync,
- TestBed,
- tick,
- waitForAsync,
-} from "@angular/core/testing";
-import { RecurringActivity } from "../model/recurring-activity";
-import { EntityMapperService } from "../../../core/entity/entity-mapper/entity-mapper.service";
-import {
- mockEntityMapper,
- MockEntityMapperService,
-} from "../../../core/entity/entity-mapper/mock-entity-mapper-service";
-import { UpdatedEntity } from "../../../core/entity/model/entity-update";
-import { Subject } from "rxjs";
-import { School } from "../../schools/model/school";
-
-import { ActivitiesOverviewComponent } from "./activities-overview.component";
-import { MockedTestingModule } from "../../../utils/mocked-testing.module";
-import { FormDialogService } from "../../../core/form-dialog/form-dialog.service";
-
-describe("ActivitiesOverviewComponent", () => {
- let component: ActivitiesOverviewComponent;
- let fixture: ComponentFixture;
-
- let entityMapper: MockEntityMapperService;
-
- beforeEach(waitForAsync(() => {
- entityMapper = mockEntityMapper();
- TestBed.configureTestingModule({
- imports: [ActivitiesOverviewComponent, MockedTestingModule.withState()],
- providers: [
- { provide: EntityMapperService, useValue: entityMapper },
- { provide: FormDialogService, useValue: null },
- ],
- }).compileComponents();
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(ActivitiesOverviewComponent);
- component = fixture.componentInstance;
- component.entity = new School();
- fixture.detectChanges();
- });
-
- it("should create", () => {
- expect(component).toBeTruthy();
- });
-
- it("should fetch all and only recurring activities having the selected school as a linkedGroup", async () => {
- const school1 = new School("school1");
- const activity1 = new RecurringActivity();
- activity1.linkedGroups = ["school1"];
- const activity2 = new RecurringActivity();
- activity2.linkedGroups = ["school1", "school2"];
- const activity3 = new RecurringActivity();
- activity3.linkedGroups = ["school3"];
- entityMapper.addAll([activity1, activity2, activity3]);
-
- component.entity = school1;
- await component.ngOnInit();
- expect(component.records).toEqual([activity1, activity2]);
- });
-
- it("should create a new recurring activity having the current school as a linkedGroup", () => {
- component.entity = new School("school1");
- const newRecurringActivity = component.generateNewRecordFactory();
- expect(newRecurringActivity().linkedGroups).toEqual(["school1"]);
- });
-
- it("should remove the recurring activity from the table view if the current school is removed as a group of this recurring activity", fakeAsync(() => {
- const school1 = new School("school1");
- const activity1 = new RecurringActivity();
- activity1.linkedGroups = ["school1"];
- const activity2 = new RecurringActivity();
- activity2.linkedGroups = ["school1", "school2", "school3"];
- entityMapper.addAll([activity1, activity2]);
- const subject = new Subject>();
- spyOn(entityMapper, "receiveUpdates").and.returnValue(subject);
- component.entity = school1;
- component.ngOnInit();
- tick();
-
- expect(component.records).toEqual([activity1, activity2]);
-
- activity2.linkedGroups = ["school2", "school3"];
- subject.next({ entity: activity2, type: "update" });
- tick();
-
- expect(component.records).toEqual([activity1]);
- }));
-});
diff --git a/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.ts b/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.ts
index e67e89f7e3..4d5e5e6e0d 100644
--- a/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.ts
+++ b/src/app/child-dev-project/attendance/activities-overview/activities-overview.component.ts
@@ -1,23 +1,28 @@
-import { Component, Input, OnInit } from "@angular/core";
+import { Component, OnInit } from "@angular/core";
import { RecurringActivity } from "../model/recurring-activity";
-import { FormFieldConfig } from "../../../core/common-components/entity-form/entity-form/FormConfig";
-import { EntityMapperService } from "../../../core/entity/entity-mapper/entity-mapper.service";
-import { Entity } from "../../../core/entity/model/entity";
import { DynamicComponent } from "../../../core/config/dynamic-components/dynamic-component.decorator";
-import { delay } from "rxjs";
+import { RelatedEntitiesComponent } from "../../../core/entity-details/related-entities/related-entities.component";
import { EntitySubrecordComponent } from "../../../core/common-components/entity-subrecord/entity-subrecord/entity-subrecord.component";
-import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
+import { ColumnConfig } from "../../../core/common-components/entity-subrecord/entity-subrecord/entity-subrecord-config";
-@UntilDestroy()
+/**
+ * @deprecated configure a RelatedEntitiesComponent instead
+ */
@DynamicComponent("ActivitiesOverview")
@Component({
selector: "app-activities-overview",
- templateUrl: "./activities-overview.component.html",
- styleUrls: ["./activities-overview.component.scss"],
+ templateUrl:
+ "../../../core/entity-details/related-entities/related-entities.component.html",
imports: [EntitySubrecordComponent],
standalone: true,
})
-export class ActivitiesOverviewComponent implements OnInit {
+export class ActivitiesOverviewComponent
+ extends RelatedEntitiesComponent
+ implements OnInit
+{
+ entityType = RecurringActivity.ENTITY_TYPE;
+ property = "linkedGroups";
+
titleColumn = {
id: "title",
edit: "EditTextWithAutocomplete",
@@ -27,49 +32,16 @@ export class ActivitiesOverviewComponent implements OnInit {
relevantValue: "",
},
};
- @Input() columns: FormFieldConfig[] = [
+ _columns: ColumnConfig[] = [
this.titleColumn,
- { id: "type" },
- { id: "assignedTo" },
- { id: "linkedGroups" },
- { id: "excludedParticipants" },
+ "type",
+ "assignedTo",
+ "linkedGroups",
+ "excludedParticipants",
];
- @Input() entity: Entity;
- records: RecurringActivity[] = [];
-
- constructor(private entityMapper: EntityMapperService) {}
-
async ngOnInit() {
this.titleColumn.additional.relevantValue = this.entity.getId();
- await this.initLinkedActivities();
-
- this.entityMapper
- .receiveUpdates(RecurringActivity)
- // using short delay to make sure the EntitySubrecord's `receiveUpdates` code is executed before this
- .pipe(delay(0), untilDestroyed(this))
- .subscribe((updateEntity) => {
- if (updateEntity.type === "update") {
- this.initLinkedActivities();
- }
- });
- }
-
- private async initLinkedActivities() {
- this.records = await this.entityMapper
- .loadType(RecurringActivity)
- .then((activities) =>
- activities.filter((activity) =>
- activity.linkedGroups.includes(this.entity.getId()),
- ),
- );
- }
-
- generateNewRecordFactory(): () => RecurringActivity {
- return () => {
- const newRecurringActivity = new RecurringActivity();
- newRecurringActivity.linkedGroups.push(this.entity.getId());
- return newRecurringActivity;
- };
+ await super.ngOnInit();
}
}