Skip to content

Commit

Permalink
#1704 added again action for GetAllInstitutionsHierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazarii Ivasyshyn committed Nov 7, 2022
1 parent 796e23f commit 310910a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/app/shared/services/institutions/institutions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export class InstitutionsService {
return this.http.get<Institution[]>('/api/v1/Institution/GetAll');
}

getAllInstitutionHierarchies(): Observable<InstituitionHierarchy[]> {
return this.http.get<InstituitionHierarchy[]> ('/api/v1/InstitutionHierarchy/GetAll');
}

getAllByInstitutionAndLevel(institutionsId: string, hierarchyLevel: number): Observable<InstituitionHierarchy[]> {
let params = new HttpParams();
params = params.set('institutionId', institutionsId);
Expand Down
5 changes: 5 additions & 0 deletions src/app/shared/store/meta-data.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export class GetAllInstitutions {
constructor() {}
}

export class GetAllInstitutionsHierarchy {
static readonly type = '[meta-data] Get All Institutions Hierarchy';
constructor() {}
}

export class GetAchievementsType {
static readonly type = '[meta-data] Get All Achievement Types';
constructor() {}
Expand Down
28 changes: 26 additions & 2 deletions src/app/shared/store/meta-data.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
GetAchievementsType,
GetAllByInstitutionAndLevel,
GetAllInstitutions,
GetAllInstitutionsHierarchy,
GetCodeficatorById,
GetCodeficatorSearch,
GetFeaturesList,
Expand All @@ -49,6 +50,7 @@ export interface MetaDataStateModel {
featuresList: FeaturesList;
institutions: Institution[];
institutionFieldDesc: InstitutionFieldDescription[];
instituitionsHierarchyAll: InstituitionHierarchy[];
instituitionsHierarchy: InstituitionHierarchy[];
editInstituitionsHierarchy: InstituitionHierarchy[];
codeficatorSearch: Codeficator[];
Expand All @@ -67,6 +69,7 @@ export interface MetaDataStateModel {
featuresList: { release1: true, release2: true, release3: false },
institutions: null,
institutionFieldDesc: null,
instituitionsHierarchyAll: null,
instituitionsHierarchy: null,
editInstituitionsHierarchy: null,
codeficatorSearch: [],
Expand Down Expand Up @@ -111,7 +114,8 @@ export class MetaDataState {
}

@Selector()
static institutions(state: MetaDataStateModel): Institution[] {
static institutions(
state: MetaDataStateModel): Institution[] {
return state.institutions;
}

Expand All @@ -121,7 +125,16 @@ export class MetaDataState {
}

@Selector()
static instituitionsHierarchy(state: MetaDataStateModel): InstituitionHierarchy[] {
static instituitionsHierarchyAll(
state: MetaDataStateModel
): InstituitionHierarchy[] {
return state.instituitionsHierarchyAll;
}

@Selector()
static instituitionsHierarchy(
state: MetaDataStateModel
): InstituitionHierarchy[] {
return state.instituitionsHierarchy;
}

Expand Down Expand Up @@ -209,6 +222,17 @@ export class MetaDataState {
.pipe(tap((institutions: Institution[]) => patchState({ institutions: institutions, isLoading: false })));
}

@Action(GetAllInstitutionsHierarchy)
getAllInstitutionsHierarchy(
{ patchState }: StateContext<MetaDataStateModel>,
{}: GetAllInstitutionsHierarchy
): Observable<InstituitionHierarchy[]> {
patchState({ isLoading: true });
return this.institutionsService
.getAllInstitutionHierarchies()
.pipe(tap((instituitionsHierarchyAll: InstituitionHierarchy[]) => patchState({ instituitionsHierarchyAll: instituitionsHierarchyAll, isLoading: false })));
}

@Action(GetAchievementsType)
getAchievementType({ patchState }: StateContext<MetaDataStateModel>, {}: GetAchievementsType): Observable<AchievementType[]> {
patchState({ isLoading: true });
Expand Down
4 changes: 3 additions & 1 deletion src/app/shell/admin-tools/data/data.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { MaterialModule } from '../../../shared/modules/material.module';
import { DirectionsComponent } from './directions-wrapper/directions/directions.component';
import { CreateDirectionComponent } from './directions-wrapper/directions/create-direction/create-direction.component';
import { DirectionsWrapperComponent } from './directions-wrapper/directions-wrapper.component';
import { DirectionsInstitutionHierarchiesListComponent } from './directions-wrapper/directions-institution-hierarchies-list/directions-institution-hierarchies-list.component';

@NgModule({
declarations: [
Expand All @@ -28,7 +29,8 @@ import { DirectionsWrapperComponent } from './directions-wrapper/directions-wrap
HistoryLogFiltersComponent,
DirectionsComponent,
CreateDirectionComponent,
DirectionsWrapperComponent
DirectionsWrapperComponent,
DirectionsInstitutionHierarchiesListComponent
],
imports: [CommonModule, DataRoutingModule, SharedModule, MaterialModule, FlexLayoutModule],
exports: [DataComponent]
Expand Down

0 comments on commit 310910a

Please sign in to comment.