From 29ff349ea02189e7c57656c4fa2e02a1e44d8e09 Mon Sep 17 00:00:00 2001 From: Nazarii Ivasyshyn Date: Wed, 9 Nov 2022 17:12:02 +0200 Subject: [PATCH] #1704 comments after review --- ...rections-institution-hierarchies-list.component.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.ts b/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.ts index f9594aa992..c76e987fab 100644 --- a/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.ts +++ b/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.ts @@ -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()]); @@ -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(() => { @@ -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]); @@ -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); }