From a6dad57ee236a1d127ab45aba7db9ba1e1fbe551 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Fri, 6 Oct 2023 12:20:17 +0530 Subject: [PATCH 01/16] #2004 - extended the summary to include average in Educational material --- .../educational-material.component.html | 18 +++-- .../educational-material.component.spec.ts | 60 ++++++++++++++++- .../educational-material.component.ts | 67 +++++++++++++++---- src/app/core/config/config-fix.ts | 9 +++ 4 files changed, 136 insertions(+), 18 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html index 289052eca4..727ac3e31f 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html @@ -5,9 +5,17 @@ > -
- Total: {{ summary }} +
+ + + + Total: {{ summary }}
+
+
+ + + Average: {{ avgSummary }} + + +
diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts index 2e8e639b56..a789f671ba 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts @@ -6,8 +6,10 @@ import { MockedTestingModule } from "../../../../utils/mocked-testing.module"; import { EducationalMaterial } from "../model/educational-material"; import { ConfigurableEnumValue } from "../../../../core/basic-datatypes/configurable-enum/configurable-enum.interface"; import { EntityMapperService } from "../../../../core/entity/entity-mapper/entity-mapper.service"; -import { Subject } from "rxjs"; +import { of, Subject } from "rxjs"; import { UpdatedEntity } from "../../../../core/entity/model/entity-update"; +import { ActivatedRoute } from "@angular/router"; +import { RouteData } from "app/core/config/dynamic-routing/view-config.interface"; describe("EducationalMaterialComponent", () => { let component: EducationalMaterialComponent; @@ -26,7 +28,33 @@ describe("EducationalMaterialComponent", () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [EducationalMaterialComponent, MockedTestingModule.withState()], + providers: [ + { + provide: ActivatedRoute, + useValue: { + data: of({ + config: { + entity: "Child", + panels: [ + { + title: "Educational Materials", + summary: [ + { + Total: "Total", + }, + { + Average: "Average", + }, + ], + }, + ], + }, + }), + }, + }, + ], }).compileComponents(); + const entityMapper = TestBed.inject(EntityMapperService); spyOn(entityMapper, "receiveUpdates").and.returnValue(updates); })); @@ -95,6 +123,36 @@ describe("EducationalMaterialComponent", () => { const newRecord = component.newRecordFactory(); expect(newRecord.child).toBe(child.getId()); }); + it("produces an empty summary when there are no records", () => { + component.records = []; + component.updateSummary(); + expect(component.summary).toHaveSize(0); + }); + + it("should set summaryTitle based on panel title", () => { + setRecordsAndGenerateSummary([{ Total: "Total" }, { Average: "Average" }]) + + const routeData: RouteData = { + config: { + panels: [ + { + title: "Educational Materials", + summary: [ + { + Total: "Total", + }, + { + Average: "Average", + }, + ], + }, + ], + }, + }; + + component.getSummaryList(); + expect(component.summaryTitle).toEqual([{ Total: "Total" }, { Average: "Average" }]); + }); it("should update the summary when entity updates are received", async () => { const update1 = EducationalMaterial.create({ diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index feba170e3e..953a012890 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -1,4 +1,5 @@ import { Component, Input, OnInit } from "@angular/core"; +import { NgFor, NgIf, } from "@angular/common"; import { EducationalMaterial } from "../model/educational-material"; import { Child } from "../../model/child"; import { FormFieldConfig } from "../../../../core/common-components/entity-form/entity-form/FormConfig"; @@ -8,6 +9,9 @@ import { applyUpdate } from "../../../../core/entity/model/entity-update"; import { filter } from "rxjs/operators"; import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { EntitySubrecordComponent } from "../../../../core/common-components/entity-subrecord/entity-subrecord/entity-subrecord.component"; +import { EntityListConfig } from "app/core/entity-list/EntityListConfig"; +import { ActivatedRoute } from "@angular/router"; +import { RouteData } from "app/core/config/dynamic-routing/view-config.interface"; /** * Displays educational materials of a child, such as a pencil, rulers, e.t.c @@ -18,13 +22,16 @@ import { EntitySubrecordComponent } from "../../../../core/common-components/ent @Component({ selector: "app-educational-material", templateUrl: "./educational-material.component.html", - imports: [EntitySubrecordComponent], + imports: [EntitySubrecordComponent,NgIf,NgFor], standalone: true, }) export class EducationalMaterialComponent implements OnInit { @Input() entity: Child; records: EducationalMaterial[] = []; summary = ""; + avgSummary = ""; + summaryTitle: { [key: string]: string }[] + listConfig: EntityListConfig; @Input() config: { columns: FormFieldConfig[] } = { columns: [ @@ -35,7 +42,8 @@ export class EducationalMaterialComponent implements OnInit { ], }; - constructor(private entityMapper: EntityMapperService) { + constructor(private entityMapper: EntityMapperService, + private route: ActivatedRoute ) { this.entityMapper .receiveUpdates(EducationalMaterial) .pipe( @@ -65,6 +73,7 @@ export class EducationalMaterialComponent implements OnInit { (mat) => mat.child === this.entity.getId(), ); this.updateSummary(); + } newRecordFactory = () => { @@ -83,15 +92,49 @@ export class EducationalMaterialComponent implements OnInit { * human-readable format */ updateSummary() { - const summary = new Map(); - this.records.forEach((m) => { - const previousValue = summary.has(m.materialType.label) - ? summary.get(m.materialType.label) - : 0; - summary.set(m.materialType.label, previousValue + m.materialAmount); - }); - this.summary = [...summary] - .map(([key, value]) => key + ": " + value) - .join(", "); + const summary = new Map(); + const average = new Map(); + + // Initialize summary and average maps in a single loop + for (const m of this.records) { + if (m.materialType) { + const label = m.materialType.label; + const amount = m.materialAmount; + + if (!summary.has(label)) { + summary.set(label, { count: 0, sum: 0 }); + } + + const labelData = summary.get(label); + labelData.count++; + labelData.sum += amount; + } + } + + // Calculate averages and build summary strings + const summaryArray: string[] = []; + const avgSummaryArray: string[] = []; + + for (const [label, labelData] of summary.entries()) { + const avg = labelData.sum / labelData.count; + average.set(label, avg); + + summaryArray.push(`${label}: ${labelData.sum}`); + avgSummaryArray.push(`${label}: ${avg}`); + } + + this.summary = summaryArray.join(", "); + this.avgSummary = avgSummaryArray.join(", "); + this.getSummaryList(); + } + + + getSummaryList(){ + this.route.data.subscribe( + (data: RouteData) => (this.listConfig = data.config), + ); + this.summaryTitle = this.listConfig['panels'] + .find((panel: { title: string })=> panel.title === "Educational Materials").summary; + } } diff --git a/src/app/core/config/config-fix.ts b/src/app/core/config/config-fix.ts index b179821a6d..0e03c98188 100644 --- a/src/app/core/config/config-fix.ts +++ b/src/app/core/config/config-fix.ts @@ -714,6 +714,15 @@ export const defaultJsonConfig = { "title": "", "component": "EducationalMaterial" } + ], + "summary": [ + { + "Total": $localize `:Total item Count:Total` + }, + + { + "Average": $localize `:Average Per Item:Average` + } ] }, { From 5f08b3364255118e58df93b3498eb198f6da1c16 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Fri, 6 Oct 2023 12:24:34 +0530 Subject: [PATCH 02/16] #2004 - extended the summary to include average in Educational material --- .../educational-material.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 953a012890..c73b156d38 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -110,8 +110,7 @@ export class EducationalMaterialComponent implements OnInit { labelData.sum += amount; } } - - // Calculate averages and build summary strings + const summaryArray: string[] = []; const avgSummaryArray: string[] = []; From 3034b9c35773df441306091dcab5891525a0b803 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Fri, 6 Oct 2023 12:38:31 +0530 Subject: [PATCH 03/16] #2004 - extended the summary to include average in Educational material --- .../educational-material.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index c73b156d38..1f6a0d23ba 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -22,7 +22,11 @@ import { RouteData } from "app/core/config/dynamic-routing/view-config.interface @Component({ selector: "app-educational-material", templateUrl: "./educational-material.component.html", - imports: [EntitySubrecordComponent,NgIf,NgFor], + imports: [ + EntitySubrecordComponent, + NgIf, + NgFor + ], standalone: true, }) export class EducationalMaterialComponent implements OnInit { @@ -110,7 +114,7 @@ export class EducationalMaterialComponent implements OnInit { labelData.sum += amount; } } - + const summaryArray: string[] = []; const avgSummaryArray: string[] = []; From 3a38701dad07a86f5a721b4cd979e13ec575defd Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Fri, 6 Oct 2023 14:10:32 +0530 Subject: [PATCH 04/16] #2004-rounding off the numbers in average --- .../educational-material.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 1f6a0d23ba..f391533382 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -98,7 +98,7 @@ export class EducationalMaterialComponent implements OnInit { updateSummary() { const summary = new Map(); const average = new Map(); - + // Initialize summary and average maps in a single loop for (const m of this.records) { if (m.materialType) { @@ -119,9 +119,9 @@ export class EducationalMaterialComponent implements OnInit { const avgSummaryArray: string[] = []; for (const [label, labelData] of summary.entries()) { - const avg = labelData.sum / labelData.count; + const avg = parseFloat((labelData.sum / labelData.count).toPrecision(2)); average.set(label, avg); - + summaryArray.push(`${label}: ${labelData.sum}`); avgSummaryArray.push(`${label}: ${avg}`); } From 3a6abe4bcc12d1fec051e5060eabf47710ec2333 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Mon, 9 Oct 2023 13:54:41 +0530 Subject: [PATCH 05/16] remove unused code --- .../educational-material.component.html | 2 +- .../educational-material.component.spec.ts | 21 +------------------ .../educational-material.component.ts | 13 +++++------- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html index 727ac3e31f..089bb78334 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html @@ -14,7 +14,7 @@ - Average: {{ avgSummary }} + Average: {{ avgSummary }} diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts index a789f671ba..1a3885cce7 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts @@ -9,7 +9,6 @@ import { EntityMapperService } from "../../../../core/entity/entity-mapper/entit import { of, Subject } from "rxjs"; import { UpdatedEntity } from "../../../../core/entity/model/entity-update"; import { ActivatedRoute } from "@angular/router"; -import { RouteData } from "app/core/config/dynamic-routing/view-config.interface"; describe("EducationalMaterialComponent", () => { let component: EducationalMaterialComponent; @@ -123,6 +122,7 @@ describe("EducationalMaterialComponent", () => { const newRecord = component.newRecordFactory(); expect(newRecord.child).toBe(child.getId()); }); + it("produces an empty summary when there are no records", () => { component.records = []; component.updateSummary(); @@ -131,25 +131,6 @@ describe("EducationalMaterialComponent", () => { it("should set summaryTitle based on panel title", () => { setRecordsAndGenerateSummary([{ Total: "Total" }, { Average: "Average" }]) - - const routeData: RouteData = { - config: { - panels: [ - { - title: "Educational Materials", - summary: [ - { - Total: "Total", - }, - { - Average: "Average", - }, - ], - }, - ], - }, - }; - component.getSummaryList(); expect(component.summaryTitle).toEqual([{ Total: "Total" }, { Average: "Average" }]); }); diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index f391533382..59154cc70b 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -99,7 +99,6 @@ export class EducationalMaterialComponent implements OnInit { const summary = new Map(); const average = new Map(); - // Initialize summary and average maps in a single loop for (const m of this.records) { if (m.materialType) { const label = m.materialType.label; @@ -117,11 +116,10 @@ export class EducationalMaterialComponent implements OnInit { const summaryArray: string[] = []; const avgSummaryArray: string[] = []; - + for (const [label, labelData] of summary.entries()) { const avg = parseFloat((labelData.sum / labelData.count).toPrecision(2)); average.set(label, avg); - summaryArray.push(`${label}: ${labelData.sum}`); avgSummaryArray.push(`${label}: ${avg}`); } @@ -131,13 +129,12 @@ export class EducationalMaterialComponent implements OnInit { this.getSummaryList(); } - - getSummaryList(){ + getSummaryList() { this.route.data.subscribe( (data: RouteData) => (this.listConfig = data.config), ); - this.summaryTitle = this.listConfig['panels'] - .find((panel: { title: string })=> panel.title === "Educational Materials").summary; - + + this.summaryTitle = this.listConfig['panels'] + .find((panel: { title: string })=> panel.title === "Educational Materials").summary; } } From 0bc4d32b8b11238c0abedc264a9f16539a3df7db Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Mon, 9 Oct 2023 14:01:06 +0530 Subject: [PATCH 06/16] remove unused code --- .../educational-material.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 59154cc70b..015d6ce789 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -1,5 +1,5 @@ import { Component, Input, OnInit } from "@angular/core"; -import { NgFor, NgIf, } from "@angular/common"; +import { NgFor, NgIf } from "@angular/common"; import { EducationalMaterial } from "../model/educational-material"; import { Child } from "../../model/child"; import { FormFieldConfig } from "../../../../core/common-components/entity-form/entity-form/FormConfig"; From a287546f74cb8db052b57b64455bd7ad02a60c0e Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Mon, 9 Oct 2023 19:41:41 +0530 Subject: [PATCH 07/16] #2004 - refactor and cleanup --- .../educational-material.component.ts | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 015d6ce789..f40407630d 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -77,7 +77,6 @@ export class EducationalMaterialComponent implements OnInit { (mat) => mat.child === this.entity.getId(), ); this.updateSummary(); - } newRecordFactory = () => { @@ -98,43 +97,46 @@ export class EducationalMaterialComponent implements OnInit { updateSummary() { const summary = new Map(); const average = new Map(); - - for (const m of this.records) { - if (m.materialType) { - const label = m.materialType.label; - const amount = m.materialAmount; - + + this.records.forEach((m) => { + const { materialType, materialAmount } = m; + + if (materialType.label) { + const label = materialType.label; + if (!summary.has(label)) { summary.set(label, { count: 0, sum: 0 }); } - + const labelData = summary.get(label); labelData.count++; - labelData.sum += amount; + labelData.sum += materialAmount; + } + }); + + const summaryArray: string[] = Array.from(summary.entries()).map( + ([label, labelData]) => `${label}: ${labelData.sum}` + ); + + const avgSummaryArray: string[] = Array.from(summary.entries()).map( + ([label, labelData]) => { + const avg = parseFloat((labelData.sum / labelData.count).toFixed(2)); + average.set(label, avg); + return `${label}: ${avg}`; } - } - - const summaryArray: string[] = []; - const avgSummaryArray: string[] = []; - - for (const [label, labelData] of summary.entries()) { - const avg = parseFloat((labelData.sum / labelData.count).toPrecision(2)); - average.set(label, avg); - summaryArray.push(`${label}: ${labelData.sum}`); - avgSummaryArray.push(`${label}: ${avg}`); - } - + ); + this.summary = summaryArray.join(", "); this.avgSummary = avgSummaryArray.join(", "); this.getSummaryList(); } - + getSummaryList() { - this.route.data.subscribe( - (data: RouteData) => (this.listConfig = data.config), - ); + this.route.data.subscribe((data: RouteData) => { + this.listConfig = data.config; - this.summaryTitle = this.listConfig['panels'] - .find((panel: { title: string })=> panel.title === "Educational Materials").summary; + this.summaryTitle = this.listConfig['panels'] + .find((panel: { title: string })=> panel.title === "Educational Materials").summary; + }); } } From 89973f9ef1997675716d757a689bcae566a6d118 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Mon, 9 Oct 2023 20:02:06 +0530 Subject: [PATCH 08/16] #2004 - refactor for codeclimate --- .../educational-material.component.ts | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index f40407630d..08f9dc519b 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -100,31 +100,21 @@ export class EducationalMaterialComponent implements OnInit { this.records.forEach((m) => { const { materialType, materialAmount } = m; + const label = materialType?.label; - if (materialType.label) { - const label = materialType.label; - - if (!summary.has(label)) { - summary.set(label, { count: 0, sum: 0 }); - } - - const labelData = summary.get(label); - labelData.count++; - labelData.sum += materialAmount; + if (label) { + summary.set(label, (summary.get(label) || { count: 0, sum: 0 })); + summary.get(label)!.count++; + summary.get(label)!.sum += materialAmount; } }); - const summaryArray: string[] = Array.from(summary.entries()).map( - ([label, labelData]) => `${label}: ${labelData.sum}` - ); - - const avgSummaryArray: string[] = Array.from(summary.entries()).map( - ([label, labelData]) => { - const avg = parseFloat((labelData.sum / labelData.count).toFixed(2)); - average.set(label, avg); - return `${label}: ${avg}`; - } - ); + const summaryArray = Array.from(summary.entries(), ([label, { sum }]) => `${label}: ${sum}`); + const avgSummaryArray = Array.from(summary.entries(), ([label, { count, sum }]) => { + const avg = parseFloat((sum / count).toFixed(2)); + average.set(label, avg); + return `${label}: ${avg}`; + }); this.summary = summaryArray.join(", "); this.avgSummary = avgSummaryArray.join(", "); From cc6d6971c83060831d83b1f5a37a6f3a6e3d2bb4 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Wed, 11 Oct 2023 12:23:37 +0530 Subject: [PATCH 09/16] 2004 - updated config-fix file for summary and using services to fetch summary data --- .../educational-material.component.html | 14 +++++-------- .../educational-material.component.ts | 17 +++------------ src/app/core/config/config-fix.ts | 21 +++++++++---------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html index 089bb78334..098480b5b9 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html @@ -6,16 +6,12 @@
- - - - Total: {{ summary }}
-
+ + + Total: {{ totalSummary }}
- - - Average: {{ avgSummary }} - + + Average: {{ avgSummary }}
diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 08f9dc519b..668efa2d8a 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -11,7 +11,6 @@ import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { EntitySubrecordComponent } from "../../../../core/common-components/entity-subrecord/entity-subrecord/entity-subrecord.component"; import { EntityListConfig } from "app/core/entity-list/EntityListConfig"; import { ActivatedRoute } from "@angular/router"; -import { RouteData } from "app/core/config/dynamic-routing/view-config.interface"; /** * Displays educational materials of a child, such as a pencil, rulers, e.t.c @@ -30,11 +29,11 @@ import { RouteData } from "app/core/config/dynamic-routing/view-config.interface standalone: true, }) export class EducationalMaterialComponent implements OnInit { + @Input() summary: any[]; @Input() entity: Child; records: EducationalMaterial[] = []; - summary = ""; + totalSummary = ""; avgSummary = ""; - summaryTitle: { [key: string]: string }[] listConfig: EntityListConfig; @Input() config: { columns: FormFieldConfig[] } = { @@ -116,17 +115,7 @@ export class EducationalMaterialComponent implements OnInit { return `${label}: ${avg}`; }); - this.summary = summaryArray.join(", "); + this.totalSummary = summaryArray.join(", "); this.avgSummary = avgSummaryArray.join(", "); - this.getSummaryList(); - } - - getSummaryList() { - this.route.data.subscribe((data: RouteData) => { - this.listConfig = data.config; - - this.summaryTitle = this.listConfig['panels'] - .find((panel: { title: string })=> panel.title === "Educational Materials").summary; - }); } } diff --git a/src/app/core/config/config-fix.ts b/src/app/core/config/config-fix.ts index 0e03c98188..3c9d8b4df8 100644 --- a/src/app/core/config/config-fix.ts +++ b/src/app/core/config/config-fix.ts @@ -712,17 +712,16 @@ export const defaultJsonConfig = { "components": [ { "title": "", - "component": "EducationalMaterial" - } - ], - "summary": [ - { - "Total": $localize `:Total item Count:Total` - }, - - { - "Average": $localize `:Average Per Item:Average` - } + "component": "EducationalMaterial", + "config": { + "summary": [ + { + "type": "boolean", + total: true, average: true + } + ] + } + }, ] }, { From 580fbb993772ad1b63eb090ff5021c237097867d Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Wed, 11 Oct 2023 12:48:32 +0530 Subject: [PATCH 10/16] #2004 - Removed unit test for router from educational material --- .../educational-material.component.html | 4 +- .../educational-material.component.spec.ts | 41 +------------------ .../educational-material.component.ts | 6 +-- src/app/core/config/config-fix.ts | 2 +- 4 files changed, 7 insertions(+), 46 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html index 098480b5b9..a0a126ea6a 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html @@ -6,9 +6,9 @@
- + - Total: {{ totalSummary }}
+ Total: {{ summary }}
Average: {{ avgSummary }}
diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts index 1a3885cce7..2e8e639b56 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts @@ -6,9 +6,8 @@ import { MockedTestingModule } from "../../../../utils/mocked-testing.module"; import { EducationalMaterial } from "../model/educational-material"; import { ConfigurableEnumValue } from "../../../../core/basic-datatypes/configurable-enum/configurable-enum.interface"; import { EntityMapperService } from "../../../../core/entity/entity-mapper/entity-mapper.service"; -import { of, Subject } from "rxjs"; +import { Subject } from "rxjs"; import { UpdatedEntity } from "../../../../core/entity/model/entity-update"; -import { ActivatedRoute } from "@angular/router"; describe("EducationalMaterialComponent", () => { let component: EducationalMaterialComponent; @@ -27,33 +26,7 @@ describe("EducationalMaterialComponent", () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [EducationalMaterialComponent, MockedTestingModule.withState()], - providers: [ - { - provide: ActivatedRoute, - useValue: { - data: of({ - config: { - entity: "Child", - panels: [ - { - title: "Educational Materials", - summary: [ - { - Total: "Total", - }, - { - Average: "Average", - }, - ], - }, - ], - }, - }), - }, - }, - ], }).compileComponents(); - const entityMapper = TestBed.inject(EntityMapperService); spyOn(entityMapper, "receiveUpdates").and.returnValue(updates); })); @@ -123,18 +96,6 @@ describe("EducationalMaterialComponent", () => { expect(newRecord.child).toBe(child.getId()); }); - it("produces an empty summary when there are no records", () => { - component.records = []; - component.updateSummary(); - expect(component.summary).toHaveSize(0); - }); - - it("should set summaryTitle based on panel title", () => { - setRecordsAndGenerateSummary([{ Total: "Total" }, { Average: "Average" }]) - component.getSummaryList(); - expect(component.summaryTitle).toEqual([{ Total: "Total" }, { Average: "Average" }]); - }); - it("should update the summary when entity updates are received", async () => { const update1 = EducationalMaterial.create({ child: child.getId(), diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 668efa2d8a..729fca4d34 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -29,10 +29,10 @@ import { ActivatedRoute } from "@angular/router"; standalone: true, }) export class EducationalMaterialComponent implements OnInit { - @Input() summary: any[]; + @Input() summaries: any[]; @Input() entity: Child; records: EducationalMaterial[] = []; - totalSummary = ""; + summary = ""; avgSummary = ""; listConfig: EntityListConfig; @@ -115,7 +115,7 @@ export class EducationalMaterialComponent implements OnInit { return `${label}: ${avg}`; }); - this.totalSummary = summaryArray.join(", "); + this.summary = summaryArray.join(", "); this.avgSummary = avgSummaryArray.join(", "); } } diff --git a/src/app/core/config/config-fix.ts b/src/app/core/config/config-fix.ts index 3c9d8b4df8..6be1cd34c3 100644 --- a/src/app/core/config/config-fix.ts +++ b/src/app/core/config/config-fix.ts @@ -714,7 +714,7 @@ export const defaultJsonConfig = { "title": "", "component": "EducationalMaterial", "config": { - "summary": [ + "summaries": [ { "type": "boolean", total: true, average: true From a416a5825897ea8193c1913643a51e84107bb29f Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Wed, 11 Oct 2023 12:58:20 +0530 Subject: [PATCH 11/16] #2004 - removed unused imports --- .../educational-material.component.ts | 6 +----- src/app/core/config/config-fix.ts | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 729fca4d34..aa7a18a9ed 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -9,8 +9,6 @@ import { applyUpdate } from "../../../../core/entity/model/entity-update"; import { filter } from "rxjs/operators"; import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy"; import { EntitySubrecordComponent } from "../../../../core/common-components/entity-subrecord/entity-subrecord/entity-subrecord.component"; -import { EntityListConfig } from "app/core/entity-list/EntityListConfig"; -import { ActivatedRoute } from "@angular/router"; /** * Displays educational materials of a child, such as a pencil, rulers, e.t.c @@ -34,7 +32,6 @@ export class EducationalMaterialComponent implements OnInit { records: EducationalMaterial[] = []; summary = ""; avgSummary = ""; - listConfig: EntityListConfig; @Input() config: { columns: FormFieldConfig[] } = { columns: [ @@ -45,8 +42,7 @@ export class EducationalMaterialComponent implements OnInit { ], }; - constructor(private entityMapper: EntityMapperService, - private route: ActivatedRoute ) { + constructor(private entityMapper: EntityMapperService) { this.entityMapper .receiveUpdates(EducationalMaterial) .pipe( diff --git a/src/app/core/config/config-fix.ts b/src/app/core/config/config-fix.ts index 6be1cd34c3..c4f345e0e3 100644 --- a/src/app/core/config/config-fix.ts +++ b/src/app/core/config/config-fix.ts @@ -721,7 +721,7 @@ export const defaultJsonConfig = { } ] } - }, + } ] }, { From f5f9424feb981d9b1644389768ebf0a54a969ac3 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Wed, 11 Oct 2023 22:59:52 +0530 Subject: [PATCH 12/16] 2004 - added unit test upadated config-fix file --- .../educational-material.component.html | 12 ++--- .../educational-material.component.spec.ts | 54 +++++++++++++++++++ .../educational-material.component.ts | 26 +++++---- src/app/core/config/config-fix.ts | 4 +- 4 files changed, 76 insertions(+), 20 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html index a0a126ea6a..30c1b8cb22 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html @@ -6,12 +6,10 @@
- - - Total: {{ summary }}
-
- - Average: {{ avgSummary }}
-
+ + Total: {{ summary }}
+
+ + Average: {{ avgSummary }}
diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts index 2e8e639b56..64339d0fe3 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts @@ -35,6 +35,7 @@ describe("EducationalMaterialComponent", () => { fixture = TestBed.createComponent(EducationalMaterialComponent); component = fixture.componentInstance; component.entity = child; + component.summaries =[{total: true, average: true}]; fixture.detectChanges(); }); @@ -46,6 +47,7 @@ describe("EducationalMaterialComponent", () => { component.records = []; component.updateSummary(); expect(component.summary).toHaveSize(0); + expect(component.avgSummary).toHaveSize(0); }); function setRecordsAndGenerateSummary( @@ -58,6 +60,7 @@ describe("EducationalMaterialComponent", () => { it("produces a singleton summary when there is a single record", () => { setRecordsAndGenerateSummary({ materialType: PENCIL, materialAmount: 1 }); expect(component.summary).toEqual(`${PENCIL.label}: 1`); + expect(component.avgSummary).toEqual(`${PENCIL.label}: 1`); }); it("produces a summary of all records when they are all different", () => { @@ -66,6 +69,7 @@ describe("EducationalMaterialComponent", () => { { materialType: RULER, materialAmount: 1 }, ); expect(component.summary).toEqual(`${PENCIL.label}: 2, ${RULER.label}: 1`); + expect(component.avgSummary).toEqual(`${PENCIL.label}: 2, ${RULER.label}: 1`); }); it("produces a summary of all records when there are duplicates", () => { @@ -74,7 +78,57 @@ describe("EducationalMaterialComponent", () => { { materialType: RULER, materialAmount: 1 }, { materialType: PENCIL, materialAmount: 3 }, ); + + expect(component.summary).toEqual(`${PENCIL.label}: 4, ${RULER.label}: 1`); + expect(component.avgSummary).toEqual(`${PENCIL.label}: 2, ${RULER.label}: 1`); + }); + + it("produces summary of all records when average is false and total is true", () => { + setRecordsAndGenerateSummary( + { materialType: PENCIL, materialAmount: 1 }, + { materialType: RULER, materialAmount: 1 }, + { materialType: PENCIL, materialAmount: 3 }, + component.summaries =[{total: true, average: false}], + ); + + expect(component.summary).toEqual(`${PENCIL.label}: 4, ${RULER.label}: 1`); + expect(component.avgSummary).toEqual(``); + }); + + it("produces summary of all records when average is true and total is false", () => { + setRecordsAndGenerateSummary( + { materialType: PENCIL, materialAmount: 1 }, + { materialType: RULER, materialAmount: 1 }, + { materialType: PENCIL, materialAmount: 3 }, + component.summaries =[{total: false, average: true}], + ); + + expect(component.summary).toEqual(``); + expect(component.avgSummary).toEqual(`${PENCIL.label}: 2, ${RULER.label}: 1`); + }); + + it("produces summary of all records when both average and total are false", () => { + setRecordsAndGenerateSummary( + { materialType: PENCIL, materialAmount: 1 }, + { materialType: RULER, materialAmount: 1 }, + { materialType: PENCIL, materialAmount: 3 }, + component.summaries =[{total: false, average: false}], + ); + + expect(component.summary).toEqual(``); + expect(component.avgSummary).toEqual(``); + }); + + it("produces summary of all records when both average and total are true", () => { + setRecordsAndGenerateSummary( + { materialType: PENCIL, materialAmount: 1 }, + { materialType: RULER, materialAmount: 1 }, + { materialType: PENCIL, materialAmount: 3 }, + component.summaries =[{total: true, average: true}], + ); + expect(component.summary).toEqual(`${PENCIL.label}: 4, ${RULER.label}: 1`); + expect(component.avgSummary).toEqual(`${PENCIL.label}: 2, ${RULER.label}: 1`); }); it("loads all education data associated with a child and updates the summary", async () => { diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index aa7a18a9ed..e03540d2e9 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -27,8 +27,8 @@ import { EntitySubrecordComponent } from "../../../../core/common-components/ent standalone: true, }) export class EducationalMaterialComponent implements OnInit { - @Input() summaries: any[]; @Input() entity: Child; + @Input() summaries: any[]; records: EducationalMaterial[] = []; summary = ""; avgSummary = ""; @@ -103,15 +103,19 @@ export class EducationalMaterialComponent implements OnInit { summary.get(label)!.sum += materialAmount; } }); - - const summaryArray = Array.from(summary.entries(), ([label, { sum }]) => `${label}: ${sum}`); - const avgSummaryArray = Array.from(summary.entries(), ([label, { count, sum }]) => { - const avg = parseFloat((sum / count).toFixed(2)); - average.set(label, avg); - return `${label}: ${avg}`; - }); - - this.summary = summaryArray.join(", "); - this.avgSummary = avgSummaryArray.join(", "); + + if(this.summaries[0]?.total=== true) { + const summaryArray = Array.from(summary.entries(), ([label, { sum }]) => `${label}: ${sum}`); + this.summary = summaryArray.join(", "); + } + + if(this.summaries[0]?.average=== true) { + const avgSummaryArray = Array.from(summary.entries(), ([label, { count, sum }]) => { + const avg = parseFloat((sum / count).toFixed(2)); + average.set(label, avg); + return `${label}: ${avg}`; + }); + this.avgSummary = avgSummaryArray.join(", "); + } } } diff --git a/src/app/core/config/config-fix.ts b/src/app/core/config/config-fix.ts index c4f345e0e3..ce696e626c 100644 --- a/src/app/core/config/config-fix.ts +++ b/src/app/core/config/config-fix.ts @@ -716,8 +716,8 @@ export const defaultJsonConfig = { "config": { "summaries": [ { - "type": "boolean", - total: true, average: true + total: true, + average: true, } ] } From bbba60e665b74b9e3d9a2d0906258fc2c74aaa23 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Thu, 12 Oct 2023 11:44:46 +0530 Subject: [PATCH 13/16] 2004 - fixed typo in test scenario message --- .../educational-material.component.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts index 64339d0fe3..eb5e0a4b8f 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts @@ -107,7 +107,7 @@ describe("EducationalMaterialComponent", () => { expect(component.avgSummary).toEqual(`${PENCIL.label}: 2, ${RULER.label}: 1`); }); - it("produces summary of all records when both average and total are false", () => { + it("does not produces summary of all records when both average and total are false", () => { setRecordsAndGenerateSummary( { materialType: PENCIL, materialAmount: 1 }, { materialType: RULER, materialAmount: 1 }, From aa8e96ee9a32be3573724ae38e6044ca1e0afdb8 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Thu, 12 Oct 2023 16:00:20 +0530 Subject: [PATCH 14/16] 2004 - updated the summaries in the config-fix file and their corresponding elements --- .../educational-material.component.html | 4 ++-- .../educational-material.component.spec.ts | 12 ++++++------ .../educational-material.component.ts | 6 +++--- src/app/core/config/config-fix.ts | 4 +--- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html index 30c1b8cb22..abfd833c5c 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.html @@ -7,9 +7,9 @@
- Total: {{ summary }}
+ Total: {{ summary }}
- Average: {{ avgSummary }}
+ Average: {{ avgSummary }}
diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts index eb5e0a4b8f..9068e33c8e 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.spec.ts @@ -35,7 +35,7 @@ describe("EducationalMaterialComponent", () => { fixture = TestBed.createComponent(EducationalMaterialComponent); component = fixture.componentInstance; component.entity = child; - component.summaries =[{total: true, average: true}]; + component.summaries = {total: true, average: true}; fixture.detectChanges(); }); @@ -84,11 +84,11 @@ describe("EducationalMaterialComponent", () => { }); it("produces summary of all records when average is false and total is true", () => { + component.summaries = { total: true, average: false } setRecordsAndGenerateSummary( { materialType: PENCIL, materialAmount: 1 }, { materialType: RULER, materialAmount: 1 }, { materialType: PENCIL, materialAmount: 3 }, - component.summaries =[{total: true, average: false}], ); expect(component.summary).toEqual(`${PENCIL.label}: 4, ${RULER.label}: 1`); @@ -96,11 +96,11 @@ describe("EducationalMaterialComponent", () => { }); it("produces summary of all records when average is true and total is false", () => { + component.summaries = { total: false, average: true }; setRecordsAndGenerateSummary( { materialType: PENCIL, materialAmount: 1 }, { materialType: RULER, materialAmount: 1 }, { materialType: PENCIL, materialAmount: 3 }, - component.summaries =[{total: false, average: true}], ); expect(component.summary).toEqual(``); @@ -108,23 +108,23 @@ describe("EducationalMaterialComponent", () => { }); it("does not produces summary of all records when both average and total are false", () => { + component.summaries = { total: false, average: false }; setRecordsAndGenerateSummary( { materialType: PENCIL, materialAmount: 1 }, { materialType: RULER, materialAmount: 1 }, { materialType: PENCIL, materialAmount: 3 }, - component.summaries =[{total: false, average: false}], ); - + expect(component.summary).toEqual(``); expect(component.avgSummary).toEqual(``); }); it("produces summary of all records when both average and total are true", () => { + component.summaries = { total: true, average: true }; setRecordsAndGenerateSummary( { materialType: PENCIL, materialAmount: 1 }, { materialType: RULER, materialAmount: 1 }, { materialType: PENCIL, materialAmount: 3 }, - component.summaries =[{total: true, average: true}], ); expect(component.summary).toEqual(`${PENCIL.label}: 4, ${RULER.label}: 1`); diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index e03540d2e9..49be03a8cd 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -28,7 +28,7 @@ import { EntitySubrecordComponent } from "../../../../core/common-components/ent }) export class EducationalMaterialComponent implements OnInit { @Input() entity: Child; - @Input() summaries: any[]; + @Input() summaries: any; records: EducationalMaterial[] = []; summary = ""; avgSummary = ""; @@ -104,12 +104,12 @@ export class EducationalMaterialComponent implements OnInit { } }); - if(this.summaries[0]?.total=== true) { + if(this.summaries.total) { const summaryArray = Array.from(summary.entries(), ([label, { sum }]) => `${label}: ${sum}`); this.summary = summaryArray.join(", "); } - if(this.summaries[0]?.average=== true) { + if(this.summaries.average) { const avgSummaryArray = Array.from(summary.entries(), ([label, { count, sum }]) => { const avg = parseFloat((sum / count).toFixed(2)); average.set(label, avg); diff --git a/src/app/core/config/config-fix.ts b/src/app/core/config/config-fix.ts index ce696e626c..afdb7f9881 100644 --- a/src/app/core/config/config-fix.ts +++ b/src/app/core/config/config-fix.ts @@ -714,12 +714,10 @@ export const defaultJsonConfig = { "title": "", "component": "EducationalMaterial", "config": { - "summaries": [ - { + "summaries": { total: true, average: true, } - ] } } ] From ffa044bca70a2dd9a10335859ebbd7a06e346309 Mon Sep 17 00:00:00 2001 From: Brajesh Kumar Date: Thu, 12 Oct 2023 16:31:39 +0530 Subject: [PATCH 15/16] 2004 - changed data type of summaries --- .../educational-material.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 49be03a8cd..1f70c47741 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -28,7 +28,7 @@ import { EntitySubrecordComponent } from "../../../../core/common-components/ent }) export class EducationalMaterialComponent implements OnInit { @Input() entity: Child; - @Input() summaries: any; + @Input() summaries: {total: boolean; average: boolean}; records: EducationalMaterial[] = []; summary = ""; avgSummary = ""; From a8aaa1a3723146a8d5dfa049413ea606b9737dae Mon Sep 17 00:00:00 2001 From: Sebastian Date: Thu, 12 Oct 2023 15:27:34 +0200 Subject: [PATCH 16/16] Update src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts --- .../educational-material.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts index 1f70c47741..5a065632c3 100644 --- a/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts +++ b/src/app/child-dev-project/children/educational-material/educational-material-component/educational-material.component.ts @@ -28,7 +28,7 @@ import { EntitySubrecordComponent } from "../../../../core/common-components/ent }) export class EducationalMaterialComponent implements OnInit { @Input() entity: Child; - @Input() summaries: {total: boolean; average: boolean}; + @Input() summaries: { total?: boolean; average?: boolean } = { total: true }; records: EducationalMaterial[] = []; summary = ""; avgSummary = "";