Skip to content
Snippets Groups Projects
Commit ebcc8b7c authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

Merge branch 'feat/occurence-filter-structure' into 'dev'

send actual filters and change endpoint

See merge request web-et-numerique/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_client!114
parents 7f1563e3 b99c290f
No related branches found
No related tags found
3 merge requests!178release V1.10.0,!120Dev,!114send actual filters and change endpoint
...@@ -184,38 +184,41 @@ export class SearchComponent implements OnInit, OnChanges { ...@@ -184,38 +184,41 @@ export class SearchComponent implements OnInit, OnChanges {
// Get the correct list of checkbox/modules depending on the type of modal. // Get the correct list of checkbox/modules depending on the type of modal.
private getData(option: TypeModal): void { private getData(option: TypeModal): void {
if (option === TypeModal.accompaniment) { if (option === TypeModal.accompaniment) {
forkJoin([this.searchService.getCategoriesAccompaniment(), this.searchService.getFakeCounterModule()]).subscribe( forkJoin([
(res) => { this.searchService.getCategoriesAccompaniment(),
const categories: Category[] = res[0]; this.searchService.getFakeCounterModule(this.checkedModulesFilter),
const structureCounter: StructureCounter[] = res[1]; ]).subscribe((res) => {
categories.forEach((category) => { const categories: Category[] = res[0];
category = this.searchService.setCountModules(category, structureCounter); const structureCounter: StructureCounter[] = res[1];
this.categories.push(category); categories.forEach((category) => {
}); category = this.searchService.setCountModules(category, structureCounter);
} this.categories.push(category);
); });
});
} else if (option === TypeModal.training) { } else if (option === TypeModal.training) {
forkJoin([this.searchService.getCategoriesTraining(), this.searchService.getFakeCounterModule()]).subscribe( forkJoin([
(res) => { this.searchService.getCategoriesTraining(),
const categories: Category[] = res[0]; this.searchService.getFakeCounterModule(this.checkedModulesFilter),
const structureCounter: StructureCounter[] = res[1]; ]).subscribe((res) => {
categories.forEach((category) => { const categories: Category[] = res[0];
category = this.searchService.setCountModules(category, structureCounter); const structureCounter: StructureCounter[] = res[1];
this.categories.push(category); categories.forEach((category) => {
}); category = this.searchService.setCountModules(category, structureCounter);
} this.categories.push(category);
); });
});
} else if (option === TypeModal.moreFilters) { } else if (option === TypeModal.moreFilters) {
forkJoin([this.searchService.getCategoriesMoreFilters(), this.searchService.getFakeCounterModule()]).subscribe( forkJoin([
(res) => { this.searchService.getCategoriesMoreFilters(),
const categories: Category[] = res[0]; this.searchService.getFakeCounterModule(this.checkedModulesFilter),
const structureCounter: StructureCounter[] = res[1]; ]).subscribe((res) => {
categories.forEach((category) => { const categories: Category[] = res[0];
category = this.searchService.setCountModules(category, structureCounter); const structureCounter: StructureCounter[] = res[1];
this.categories.push(category); categories.forEach((category) => {
}); category = this.searchService.setCountModules(category, structureCounter);
} this.categories.push(category);
); });
});
} }
} }
} }
...@@ -28,9 +28,9 @@ export class SearchService { ...@@ -28,9 +28,9 @@ export class SearchService {
.pipe(map((data: any[]) => data.map((item) => new Category(item)))); .pipe(map((data: any[]) => data.map((item) => new Category(item))));
} }
public getFakeCounterModule(): Observable<StructureCounter[]> { public getFakeCounterModule(selectedFilters: { id: string; text: string }[]): Observable<StructureCounter[]> {
return this.http return this.http
.get('/api/structures/count') .post('/api/structures/count', selectedFilters)
.pipe(map((data: any[]) => data.map((item) => new StructureCounter(item)))); .pipe(map((data: any[]) => data.map((item) => new StructureCounter(item))));
} }
public setCountModules(category: Category, structureCountTab: StructureCounter[]): Category { public setCountModules(category: Category, structureCountTab: StructureCounter[]): Category {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment