Skip to content

Commit

Permalink
2004 - updated config-fix file for summary and using services to fetc…
Browse files Browse the repository at this point in the history
…h summary data
  • Loading branch information
Brajesh Kumar authored and Brajesh Kumar committed Oct 11, 2023
1 parent 268c56f commit d1a4f7c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
</app-entity-subrecord>

<div class="margin-top-large">
<ng-container *ngFor="let title of summaryTitle">
<ng-container *ngIf="title.Total">
<span i18n="Total amount|Total amount of education material including a summary">
<strong>Total:</strong> {{ summary }} <br>
</span>
<ng-container *ngFor="let item of summary">
<ng-container *ngIf="item.total">
<strong>Total:</strong> {{ totalSummary }} <br>
</ng-container>
<ng-container *ngIf="title.Average">
<span i18n="Average amount|Average amount of education material including a summary">
<strong>Average:</strong> {{ avgSummary }}
</span>
<ng-container *ngIf="item.average">
<strong>Average:</strong> {{ avgSummary }} <br>
</ng-container>
</ng-container>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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[] } = {
Expand Down Expand Up @@ -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<EntityListConfig>) => {
this.listConfig = data.config;

this.summaryTitle = this.listConfig['panels']
.find((panel: { title: string })=> panel.title === "Educational Materials").summary;
});
}
}
21 changes: 10 additions & 11 deletions src/app/core/config/config-fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
},
]
},
{
Expand Down

0 comments on commit d1a4f7c

Please sign in to comment.