Skip to content

Commit

Permalink
#1704 comments after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazarii Ivasyshyn committed Nov 9, 2022
1 parent 310910a commit 29ff349
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export class DirectionsInstitutionHierarchiesListComponent implements OnInit, On
}

ngOnInit(): void {
this.loadDirectionInstitutionHierarchiesData();
}

private loadDirectionInstitutionHierarchiesData() {
this.store.dispatch([new GetFieldDescriptionByInstitutionId(this.institution.id),
new GetAllInstitutionsHierarchy()]);

Expand All @@ -39,14 +43,13 @@ export class DirectionsInstitutionHierarchiesListComponent implements OnInit, On
distinctUntilChanged(),
takeUntil(this.destroy$)
).subscribe((institutionFieldDesc: InstitutionFieldDescription[]) => {
this.store.snapshot
this.displayedColumns = institutionFieldDesc.map((ins: InstitutionFieldDescription) => ins.title);
});
this.institutionsHierarchies$.pipe(
filter((institutiionHierarchies: InstituitionHierarchy[]) => !!institutiionHierarchies),
distinctUntilChanged(),
map((institutionHierarchies: InstituitionHierarchy[]) =>
this.createDirectionTableRecords(institutionHierarchies.filter(i => i.institution.title == this.institution.title))
this.createDirectionTableRecords(institutionHierarchies.filter(ins => ins.institution.title === this.institution.title))
),
takeUntil(this.destroy$)
).subscribe(() => {
Expand All @@ -59,7 +62,7 @@ export class DirectionsInstitutionHierarchiesListComponent implements OnInit, On
if (institutionalHierarchies) {
this.institutionalHierarchies = institutionalHierarchies;
this.records = [];
const firstLevelInstitutions = this.institutionalHierarchies.filter((ins: InstituitionHierarchy) => ins.hierarchyLevel == 1);
const firstLevelInstitutions = this.institutionalHierarchies.filter((ins: InstituitionHierarchy) => ins.hierarchyLevel === 1);
firstLevelInstitutions.forEach((ins: InstituitionHierarchy) => {
let records: string[] = [];
this.createDirectionTableRecord(ins, [...records]);
Expand All @@ -69,7 +72,7 @@ export class DirectionsInstitutionHierarchiesListComponent implements OnInit, On

private createDirectionTableRecord(parent: InstituitionHierarchy, records: string[]) {
records.push(parent.title);
let children = this.institutionalHierarchies.filter((ins: InstituitionHierarchy) => ins.parentId == parent.id);
let children = this.institutionalHierarchies.filter((ins: InstituitionHierarchy) => ins.parentId === parent.id);
if (!children.length) {
this.records.push(records);
}
Expand Down

0 comments on commit 29ff349

Please sign in to comment.