From 3c89094e827025d1d9e4629cec7f4552ce856358 Mon Sep 17 00:00:00 2001 From: Jeremie BRISON <ext.sopra.jbrison@grandlyon.com> Date: Wed, 4 Nov 2020 10:02:53 +0100 Subject: [PATCH] fix(search) : fix equipments filters --- .../modal-filter/modal-filter.component.html | 12 ++++++++++-- .../modal-filter/modal-filter.component.ts | 13 ++++++++----- .../components/search/search.component.ts | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/app/structure-list/components/modal-filter/modal-filter.component.html b/src/app/structure-list/components/modal-filter/modal-filter.component.html index 803b9225d..0b42de3f0 100644 --- a/src/app/structure-list/components/modal-filter/modal-filter.component.html +++ b/src/app/structure-list/components/modal-filter/modal-filter.component.html @@ -16,9 +16,17 @@ <label> <input type="checkbox" - [checked]="getIndex(module.id, c.name) > -1" + [checked]=" + c.name !== 'Équipements et services proposés' + ? getIndex(module.id, c.name) > -1 + : getIndex('True', module.id) > -1 + " [value]="module.id" - (change)="onCheckboxChange($event, c.name)" + (change)=" + c.name !== 'Équipements et services proposés' + ? onCheckboxChange($event, c.name, false) + : onCheckboxChange($event, module.id, true) + " /> <span class="customCheck"></span> <div class="label">{{ module.text }}</div> diff --git a/src/app/structure-list/components/modal-filter/modal-filter.component.ts b/src/app/structure-list/components/modal-filter/modal-filter.component.ts index d8b0096bb..5bab3d8d2 100644 --- a/src/app/structure-list/components/modal-filter/modal-filter.component.ts +++ b/src/app/structure-list/components/modal-filter/modal-filter.component.ts @@ -35,8 +35,8 @@ export class ModalFilterComponent implements OnInit { } // Management of the checkbox event (Check / Uncheck) - public onCheckboxChange(event, categ: string): void { - const checkValue: string = event.target.value; + public onCheckboxChange(event, categ: string, isSpecial: boolean): void { + const checkValue: string = isSpecial ? 'True' : event.target.value; if (event.target.checked) { this.checkedModules.push(new Module(checkValue, categ)); } else { @@ -46,13 +46,16 @@ export class ModalFilterComponent implements OnInit { } } } - // Clear only filters in the current modal public clearFilters(): void { this.categories.forEach((categ: Category) => { categ.modules.forEach((module: Module) => { - if (this.getIndex(module.id, categ.name) > -1) { - this.checkedModules.splice(this.getIndex(module.id, categ.name), 1); + const index = this.getIndex(module.id, categ.name); + const indexSpecial = this.getIndex('True', module.id); + if (index > -1) { + this.checkedModules.splice(index, 1); + } else if (indexSpecial > -1) { + this.checkedModules.splice(indexSpecial, 1); } }); }); diff --git a/src/app/structure-list/components/search/search.component.ts b/src/app/structure-list/components/search/search.component.ts index c795a7188..a811558f6 100644 --- a/src/app/structure-list/components/search/search.component.ts +++ b/src/app/structure-list/components/search/search.component.ts @@ -75,7 +75,7 @@ export class SearchComponent implements OnInit { public fetchResults(checkedModules: Module[]): void { const inputTerm = this.searchForm.get('searchTerm').value; - + console.log(checkedModules); // Check if some modules is checked in filters if (this.checkedModulesFilter !== checkedModules) { // First btn -- GitLab