diff --git a/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.html b/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.html index 9cd7c50068..34197ed798 100644 --- a/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.html +++ b/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.html @@ -1,17 +1,38 @@
- + - + + + + + + + + +
+ {{column}} -
{{ element[i] }} +
{{ element.name[i] }}
Напрямок для користувача + + + {{element.directions[0].description}} + + + + +
diff --git a/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.scss b/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.scss index 3eee176ce8..81bc15c404 100644 --- a/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.scss +++ b/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component.scss @@ -1 +1,22 @@ -@import "src/app/shared/styles/tables.scss"; \ No newline at end of file +@import "src/app/shared/styles/tables.scss"; + +table { + width: 100%; + height: 20px; + td, th { + border-style: none; + } + + img { + width: 30px; + height: 30px; + } + + a { + cursor: pointer; + span { + margin-left: 5px; + vertical-align: top; + } + } +} 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 c76e987fab..b024c8b7a8 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 @@ -1,10 +1,16 @@ -import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core'; +import { MatSort } from '@angular/material/sort'; import { MatTableDataSource } from '@angular/material/table'; +import { Router } from '@angular/router'; import { Select, Store } from '@ngxs/store'; import { distinctUntilChanged, filter, map, Observable, Subject, takeUntil } from 'rxjs'; +import { Direction } from '../../../../../shared/models/category.model'; +import { DefaultFilterState } from '../../../../../shared/models/defaultFilterState.model'; import { Institution, InstituitionHierarchy, InstitutionFieldDescription } from '../../../../../shared/models/institution.model'; +import { SetDirections } from '../../../../../shared/store/filter.actions'; import { GetFieldDescriptionByInstitutionId, GetAllInstitutionsHierarchy } from '../../../../../shared/store/meta-data.actions'; import { MetaDataState } from '../../../../../shared/store/meta-data.state'; +import { InsHierarchyTableRecord } from './ins-hierarchy-table-record'; @Component({ @@ -20,14 +26,18 @@ export class DirectionsInstitutionHierarchiesListComponent implements OnInit, On @Select(MetaDataState.institutionFieldDesc) institutionFieldDesc$: Observable; + @ViewChild(MatSort) sort: MatSort; + destroy$: Subject = new Subject(); + staticColumns: string[] = ['Напрямок для користувача','actions']; + columns: string[]; displayedColumns: string[]; institutionalHierarchies: InstituitionHierarchy[]; - records: string[][]; + records: InsHierarchyTableRecord[] = []; isLoaded: boolean = false; dataSource: MatTableDataSource = new MatTableDataSource([{}]); - constructor(private store: Store) { + constructor(private store: Store, private router: Router) { } ngOnInit(): void { @@ -43,8 +53,9 @@ export class DirectionsInstitutionHierarchiesListComponent implements OnInit, On distinctUntilChanged(), takeUntil(this.destroy$) ).subscribe((institutionFieldDesc: InstitutionFieldDescription[]) => { - this.displayedColumns = institutionFieldDesc.map((ins: InstitutionFieldDescription) => ins.title); - }); + this.columns = institutionFieldDesc.map((ins: InstitutionFieldDescription) => ins.title); + this.displayedColumns = [...this.columns, ...this.staticColumns]; + }); this.institutionsHierarchies$.pipe( filter((institutiionHierarchies: InstituitionHierarchy[]) => !!institutiionHierarchies), distinctUntilChanged(), @@ -54,35 +65,41 @@ export class DirectionsInstitutionHierarchiesListComponent implements OnInit, On takeUntil(this.destroy$) ).subscribe(() => { this.isLoaded = true; - this.dataSource = new MatTableDataSource(this.records) + this.dataSource = new MatTableDataSource(this.records); + this.dataSource.sort = this.sort; }); } private createDirectionTableRecords(institutionalHierarchies: InstituitionHierarchy[]) { if (institutionalHierarchies) { this.institutionalHierarchies = institutionalHierarchies; - this.records = []; const firstLevelInstitutions = this.institutionalHierarchies.filter((ins: InstituitionHierarchy) => ins.hierarchyLevel === 1); firstLevelInstitutions.forEach((ins: InstituitionHierarchy) => { - let records: string[] = []; - this.createDirectionTableRecord(ins, [...records]); + let insHierarchyName: string[] = []; + this.createDirectionTableRecord(ins, [...insHierarchyName]); }); } } - private createDirectionTableRecord(parent: InstituitionHierarchy, records: string[]) { - records.push(parent.title); + private createDirectionTableRecord(parent: InstituitionHierarchy, insHierarchyName: string[]) { + insHierarchyName.push(parent.title); let children = this.institutionalHierarchies.filter((ins: InstituitionHierarchy) => ins.parentId === parent.id); if (!children.length) { - this.records.push(records); + this.records.push({name: insHierarchyName, directions: parent.directions}); } else { children.forEach((child: InstituitionHierarchy) => { - this.createDirectionTableRecord(child, [...records]); + this.createDirectionTableRecord(child, [...insHierarchyName]); }) } } + public selectDirection(direction: Direction): void { + this.store.dispatch(new SetDirections([direction.id])); + const filterQueryParams: Partial = { directionIds: [direction.id] }; + this.router.navigate(['result/list'], { queryParams: { filter: filterQueryParams }, replaceUrl: true }); + } + ngOnDestroy(): void { this.destroy$.next(true); this.destroy$.unsubscribe(); diff --git a/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/ins-hierarchy-table-record.ts b/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/ins-hierarchy-table-record.ts new file mode 100644 index 0000000000..1b9ef40482 --- /dev/null +++ b/src/app/shell/admin-tools/data/directions-wrapper/directions-institution-hierarchies-list/ins-hierarchy-table-record.ts @@ -0,0 +1,6 @@ +import { Direction } from "../../../../../shared/models/category.model"; + +export interface InsHierarchyTableRecord { + name: string[]; + directions: Direction[] +} \ No newline at end of file