diff --git a/frontend/app/zh-hierarchy-search/components/zh-hierarchy-search-table.component.ts b/frontend/app/zh-hierarchy-search/components/zh-hierarchy-search-table.component.ts
index 2121607f..60e3c53c 100644
--- a/frontend/app/zh-hierarchy-search/components/zh-hierarchy-search-table.component.ts
+++ b/frontend/app/zh-hierarchy-search/components/zh-hierarchy-search-table.component.ts
@@ -7,7 +7,7 @@ import { HierarchyField, HierarchyFields, Note, RiverBasin } from '../../models/
import { TableColumn } from '../../commonComponents/table/table-interface';
type Data = {
- kownledges: string[];
+ knowledges: string[];
field: string;
attributes: string;
};
@@ -87,7 +87,9 @@ export class ZhHierarchySearchTableComponent implements OnInit {
this.fields = [];
this.notes = [];
})
- .finally(() => {});
+ .finally(() => {
+ this.updateAttributesAndKnowledgeForm();
+ });
}
}
@@ -110,9 +112,6 @@ export class ZhHierarchySearchTableComponent implements OnInit {
}
fieldChanged(event) {
- this.localForm.controls['attributes'].reset();
- this.localForm.controls['knowledges'].reset();
-
const filteredNotes = this.notes.filter(
(item) =>
(item.volet == event && item.rubrique == null && item.sousrubrique == null) ||
@@ -131,11 +130,29 @@ export class ZhHierarchySearchTableComponent implements OnInit {
this.knowledges = this.getKnowledge(this.attributes[0]);
}
- if (this.attributes.length > 0) {
- this.localForm.controls['attributes'].setValue([this.attributes[0]]);
+ // Update the form
+ this.updateAttributesAndKnowledgeForm();
+ }
+
+ updateAttributesAndKnowledgeForm() {
+ const knowledgeControl = this.localForm.controls['knowledges'];
+ const attributesControl = this.localForm.controls['attributes'];
+
+ attributesControl.reset();
+ knowledgeControl.reset();
+
+ if (this.attributes.length) {
+ attributesControl.enable();
+ attributesControl.setValue([this.attributes[0]]);
+ } else {
+ attributesControl.disable();
}
+
if (this.knowledges.length > 0) {
- this.localForm.controls['knowledges'].setValue([this.knowledges[0]]);
+ knowledgeControl.enable();
+ knowledgeControl.setValue(this.knowledges[0]);
+ } else {
+ knowledgeControl.disable();
}
}
@@ -170,9 +187,17 @@ export class ZhHierarchySearchTableComponent implements OnInit {
const form = this.initialForm();
form.patchValue(this.localForm.value);
this.data.push(form);
- // Reset all form data
- this.reset();
+ let knowledges_array = [];
+ this.data.value.forEach((element) => {
+ if (element['knowledges'] !== null && !Array.isArray(element['knowledges'])) {
+ // avoid object object in 'connaissance' column of the frontend table
+ knowledges_array.push(element['knowledges']);
+ element['knowledges'] = knowledges_array;
+ knowledges_array = [];
+ }
+ });
}
+ this.reset();
}
onDeleteFilter(event) {
diff --git a/frontend/app/zh-hierarchy-search/zh-hierarchy-search.component.html b/frontend/app/zh-hierarchy-search/zh-hierarchy-search.component.html
index 59998786..7f27aed4 100644
--- a/frontend/app/zh-hierarchy-search/zh-hierarchy-search.component.html
+++ b/frontend/app/zh-hierarchy-search/zh-hierarchy-search.component.html
@@ -8,12 +8,12 @@
0; else noZone"
+ *ngIf="riverBasin?.value?.code; else noZone"
>
diff --git a/frontend/app/zh-search/zh-search.component.ts b/frontend/app/zh-search/zh-search.component.ts
index 1755708f..746d995c 100644
--- a/frontend/app/zh-search/zh-search.component.ts
+++ b/frontend/app/zh-search/zh-search.component.ts
@@ -95,6 +95,8 @@ export class ZhSearchComponent implements OnInit {
onReset() {
this._searchService.reset();
// Emit empty object to search all ZH
+ this.hierarchySearchToggled = false;
+ this.advancedSearchToggled = false;
this.onSearch.emit();
}