diff --git a/backend/gn_module_zh/blueprint.py b/backend/gn_module_zh/blueprint.py index 28bfd11c..77c0ef35 100644 --- a/backend/gn_module_zh/blueprint.py +++ b/backend/gn_module_zh/blueprint.py @@ -9,7 +9,7 @@ from flask import Blueprint, Response, jsonify, request, send_file, g from flask.helpers import send_file from geojson import FeatureCollection -from werkzeug.exceptions import Forbidden, BadRequest +from werkzeug.exceptions import Forbidden, BadRequest, NotFound from geonature.core.gn_commons.models import TMedias @@ -53,7 +53,7 @@ ) # from .forms import * -from .geometry import set_area, set_geom +from .geometry import set_area, set_geom, get_main_rb from .hierarchy import Hierarchy, get_all_hierarchy_fields from .model.cards import Card from .model.repositories import ZhRepository @@ -225,7 +225,8 @@ def get_complete_info(id_zh): def get_complete_card(id_zh: int) -> Card: ref_geo_config = [ref for ref in blueprint.config["ref_geo_referentiels"] if ref["active"]] - return Card(id_zh, "full", ref_geo_config).__repr__() + main_id_rb = DB.session.scalar(select(TZH.main_id_rb).where(TZH.id_zh == id_zh)) + return Card(id_zh, main_id_rb, "full", ref_geo_config).__repr__() @blueprint.route("/eval/", methods=["GET"]) @@ -599,6 +600,7 @@ def get_tab_data(id_tab): raise BadRequest( "Géométrie manquante", ) + # POST / PATCH if "id_zh" not in form_data.keys(): # set geometry from coordinates @@ -994,7 +996,10 @@ def get_hydro_zones_from_bassin() -> dict: @permissions.check_cruved_scope("R", module_code="ZONES_HUMIDES") def get_hierarchy(id_zh): """Get zh note""" - hierarchy = Hierarchy(id_zh) + main_id_rb = DB.session.scalar(select(TZH.main_id_rb).where(TZH.id_zh == id_zh)) + if not main_id_rb: + raise NotFound("The ZH is not in a river basin") + hierarchy = Hierarchy(id_zh, main_id_rb) return hierarchy.as_dict() diff --git a/backend/gn_module_zh/forms.py b/backend/gn_module_zh/forms.py index c2fed700..d7017b77 100644 --- a/backend/gn_module_zh/forms.py +++ b/backend/gn_module_zh/forms.py @@ -44,6 +44,7 @@ TOwnership, TUrbanPlanningDocs, ) +from .geometry import get_main_rb def update_tzh(data): @@ -65,6 +66,12 @@ def create_zh(form_data, info_role, zh_date, polygon, zh_area, ref_geo_referenti # temporary code code = str(uuid.uuid4())[0:12] + # main river basin + rbs = TZH.get_zh_area_intersected( + "river_basin", func.ST_GeomFromGeoJSON(str(form_data["geom"]["geometry"])) + ) + main_id_rb = get_main_rb(rbs, form_data["geom"]["geometry"]) + # create zh : fill pr_zh.t_zh new_zh = TZH( main_name=form_data["main_name"], @@ -78,6 +85,7 @@ def create_zh(form_data, info_role, zh_date, polygon, zh_area, ref_geo_referenti id_sdage=form_data["sdage"], geom=polygon, area=zh_area, + main_id_rb=main_id_rb, ) DB.session.add(new_zh) DB.session.flush() @@ -111,7 +119,7 @@ def create_zh(form_data, info_role, zh_date, polygon, zh_area, ref_geo_referenti ) # fill cor_zh_rb - post_cor_zh_rb(form_data["geom"]["geometry"], new_zh.id_zh) + post_cor_zh_rb(form_data["geom"]["geometry"], new_zh.id_zh, rbs) # fill cor_zh_hydro post_cor_zh_hydro(form_data["geom"]["geometry"], new_zh.id_zh) # fill cor_zh_fct_area @@ -133,22 +141,6 @@ def create_zh(form_data, info_role, zh_date, polygon, zh_area, ref_geo_referenti return new_zh.id_zh -# except ZHApiError: -# raise -# except Exception as e: -# if e.__class__.__name__ == "DataError": -# raise ZHApiError( -# message="create_zh_post_db_error", -# details=str(e.orig.diag.sqlstate + ": " + e.orig.diag.message_primary), -# status_code=400, -# ) -# exc_type, value, tb = sys.exc_info() -# raise ZHApiError( -# message="create_zh_post_error", -# details=str(exc_type) + ": " + str(e.with_traceback(tb)), -# ) - - def post_cor_lim_list(uuid_lim, criteria): try: # fill pr_zh.cor_lim_list @@ -204,36 +196,12 @@ def post_cor_zh_area(polygon, id_zh, id_type): cover = None DB.session.add(CorZhArea(id_area=element, id_zh=id_zh, cover=cover)) DB.session.flush() - # except Exception as e: - # if e.__class__.__name__ == "DataError": - # raise ZHApiError( - # message="post_cor_zh_area_db_error", - # details=str(e.orig.diag.sqlstate + ": " + e.orig.diag.message_primary), - # ) - # exc_type, value, tb = sys.exc_info() - # raise ZHApiError( - # message="post_cor_zh_area_error", - # details=str(exc_type) + ": " + str(e.with_traceback(tb)), - # ) -def post_cor_zh_rb(geom, id_zh): - # try: - rbs = TZH.get_zh_area_intersected("river_basin", func.ST_GeomFromGeoJSON(str(geom))) +def post_cor_zh_rb(geom, id_zh, rbs): for rb in rbs: DB.session.add(CorZhRb(id_zh=id_zh, id_rb=rb.id_rb)) DB.session.flush() - # except Exception as e: - # if e.__class__.__name__ == "DataError": - # raise ZHApiError( - # message="post_cor_zh_rb_db_error", - # details=str(e.orig.diag.sqlstate + ": " + e.orig.diag.message_primary), - # ) - # exc_type, value, tb = sys.exc_info() - # raise ZHApiError( - # message="post_cor_zh_rb_error", - # details=str(exc_type) + ": " + str(e.with_traceback(tb)), - # ) def post_cor_zh_hydro(geom, id_zh): @@ -292,10 +260,15 @@ def update_zh_tab0(form_data, polygon, area, info_role, zh_date, geo_refs): DB.session.execute(delete(CorLimList).where(CorLimList.id_lim_list == id_lim_list)) post_cor_lim_list(id_lim_list, form_data["critere_delim"]) + main_id_rb = DB.session.get(TZH, form_data["id_zh"]).main_id_rb if is_geom_new: + rbs = TZH.get_zh_area_intersected( + "river_basin", func.ST_GeomFromGeoJSON(str(form_data["geom"]["geometry"])) + ) + main_id_rb = get_main_rb(rbs, form_data["geom"]["geometry"]) update_cor_zh_area(polygon, form_data["id_zh"], geo_refs) - update_cor_zh_rb(form_data["geom"]["geometry"], form_data["id_zh"]) + update_cor_zh_rb(form_data["geom"]["geometry"], form_data["id_zh"], rbs) update_cor_zh_hydro(form_data["geom"]["geometry"], form_data["id_zh"]) ef_area = update_cor_zh_fct_area(form_data["geom"]["geometry"], form_data["id_zh"]) @@ -312,22 +285,12 @@ def update_zh_tab0(form_data, polygon, area, info_role, zh_date, geo_refs): geom=polygon, area=area, ef_area=ef_area, + main_id_rb=main_id_rb, ) ) DB.session.flush() return form_data["id_zh"] - # except Exception as e: - # if e.__class__.__name__ == "DataError": - # raise ZHApiError( - # message="update_tab0_db_error", - # details=str(e.orig.diag.sqlstate + ": " + e.orig.diag.message_primary), - # status_code=400, - # ) - # exc_type, value, tb = sys.exc_info() - # raise ZHApiError( - # message="update_tab0_error", details=str(exc_type) + ": " + str(e.with_traceback(tb)) - # ) def check_polygon(polygon, id_zh): @@ -389,9 +352,9 @@ def update_cor_zh_area(polygon, id_zh, geo_refs): ) -def update_cor_zh_rb(geom, id_zh): +def update_cor_zh_rb(geom, id_zh, rbs): DB.session.execute(delete(CorZhRb).where(CorZhRb.id_zh == id_zh)) - post_cor_zh_rb(geom, id_zh) + post_cor_zh_rb(geom, id_zh, rbs) def update_cor_zh_hydro(geom, id_zh): diff --git a/backend/gn_module_zh/geometry.py b/backend/gn_module_zh/geometry.py index f5d3a1e8..bd1e790a 100644 --- a/backend/gn_module_zh/geometry.py +++ b/backend/gn_module_zh/geometry.py @@ -86,27 +86,15 @@ def set_area(geom): ) -def get_main_rb(query: list) -> int: +def get_main_rb(rbs, geom): rb_id = None area = 0 - for q_ in query: - zh_polygon = DB.session.execute( - select(TZH.geom).where(TZH.id_zh == getattr(q_, "id_zh")) - ).scalar_one() - - rb_polygon = DB.session.execute( - select(TRiverBasin.geom) - .select_from(CorZhRb) - .join(TRiverBasin, TRiverBasin.id_rb == CorZhRb.id_rb) - .where(TRiverBasin.id_rb == getattr(q_, "id_rb")) - .limit(1) - ).scalar_one() - + for q_ in rbs: intersection = DB.session.scalar( select( func.ST_Intersection( - func.ST_GeomFromText(func.ST_AsText(zh_polygon)), - func.ST_GeomFromText(func.ST_AsText(rb_polygon)), + func.ST_GeomFromText(func.ST_AsText(func.ST_GeomFromGeoJSON(str(geom)))), + func.ST_GeomFromText(func.ST_AsText(getattr(q_, "geom"))), ) ) ) diff --git a/backend/gn_module_zh/hierarchy.py b/backend/gn_module_zh/hierarchy.py index 70b670ed..2dc910b0 100644 --- a/backend/gn_module_zh/hierarchy.py +++ b/backend/gn_module_zh/hierarchy.py @@ -1,7 +1,5 @@ import sys from itertools import groupby -from werkzeug.exceptions import NotFound - from geonature.utils.env import DB from pypnnomenclature.models import BibNomenclaturesTypes, TNomenclatures @@ -1134,11 +1132,9 @@ def __str__(self): class Hierarchy(ZH): - def __init__(self, id_zh): + def __init__(self, id_zh, main_id_rb): self.id_zh = id_zh - self.rb_id = self.__get_rb() - if not self.rb_id: - raise NotFound("The ZH is not in a river basin") + self.rb_id = main_id_rb self.is_rules = self.__check_if_rules() self.volet1 = Volet1(self.id_zh, self.rb_id) self.volet2 = Volet2(self.id_zh, self.rb_id) @@ -1162,16 +1158,6 @@ def __get_final_note(self): else: return None - def __get_rb(self): - q_rb = ZH.get_data_by_id(CorZhRb, self.id_zh) - if not q_rb: - return None - if len(q_rb) > 1: - return get_main_rb(q_rb) - return DB.session.execute( - select(CorZhRb.id_rb, TRiverBasin).join(TRiverBasin).where(CorZhRb.id_zh == self.id_zh) - ).scalar_one() - def __check_if_rules(self): try: if not DB.session.scalars( diff --git a/backend/gn_module_zh/migrations/58ab8aba8512_add_main_id_rb_column.py b/backend/gn_module_zh/migrations/58ab8aba8512_add_main_id_rb_column.py new file mode 100644 index 00000000..7923831a --- /dev/null +++ b/backend/gn_module_zh/migrations/58ab8aba8512_add_main_id_rb_column.py @@ -0,0 +1,38 @@ +"""add_main_id_rb_column + +Revision ID: 58ab8aba8512 +Revises: 76e89c793961 +Create Date: 2024-09-11 15:14:12.546662 + +""" + +from alembic import op +import sqlalchemy as sa +from sqlalchemy import Column, Integer + + +# revision identifiers, used by Alembic. +revision = "58ab8aba8512" +down_revision = "76e89c793961" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column( + schema="pr_zh", + table_name="t_zh", + column=Column( + "main_id_rb", + Integer, + nullable=True, + ), + ) + + +def downgrade(): + op.drop_column( + schema="pr_zh", + table_name="t_zh", + column_name="main_id_rb", + ) diff --git a/backend/gn_module_zh/migrations/72a8378567pa_update_main_id_rb.py b/backend/gn_module_zh/migrations/72a8378567pa_update_main_id_rb.py new file mode 100644 index 00000000..b06ac21a --- /dev/null +++ b/backend/gn_module_zh/migrations/72a8378567pa_update_main_id_rb.py @@ -0,0 +1,51 @@ +"""update_main_id_rb + +Revision ID: 72a8378567pa +Revises: 58ab8aba8512 +Create Date: 2024-09-11 17:18:21.165324 + +""" + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = "72a8378567pa" +down_revision = "58ab8aba8512" +branch_labels = None +depends_on = None + + +def upgrade(): + op.execute( + """ + UPDATE pr_zh.t_zh tzh + SET main_id_rb = + ( + SELECT id_rb + FROM ( + SELECT + czr.id_rb AS id_rb, + ST_Area(ST_Intersection( + ST_GeomFromText(ST_AsText((SELECT geom FROM pr_zh.t_zh WHERE id_zh = tzh.id_zh ))), + ST_GeomFromText(ST_AsText(trb.geom)) + )) AS areas + FROM pr_zh.cor_zh_rb czr + LEFT JOIN pr_zh.t_river_basin trb ON trb.id_rb = czr.id_rb + WHERE czr.id_zh = tzh.id_zh + ORDER BY areas DESC + LIMIT 1 + ) AS a + ) + """ + ) + + +def downgrade(): + op.execute( + """ + UPDATE pr_zh.t_zh tzh + SET main_id_rb = null + """ + ) diff --git a/backend/gn_module_zh/migrations/data/script_create_tables.sql b/backend/gn_module_zh/migrations/data/script_create_tables.sql index 1dbd92c6..f89a7685 100644 --- a/backend/gn_module_zh/migrations/data/script_create_tables.sql +++ b/backend/gn_module_zh/migrations/data/script_create_tables.sql @@ -279,6 +279,7 @@ CREATE TABLE pr_zh.t_zh ( remark_is_other_inventory varchar(2000) , main_pict_id integer , area real , + main_id_rb integer , CONSTRAINT pk_t_zh_zh_id PRIMARY KEY ( id_zh ), CONSTRAINT unq_t_zh_code UNIQUE ( code ) , CONSTRAINT unq_t_zh UNIQUE ( zh_uuid ) diff --git a/backend/gn_module_zh/model/cards.py b/backend/gn_module_zh/model/cards.py index 2d4f0ccd..836d01a2 100644 --- a/backend/gn_module_zh/model/cards.py +++ b/backend/gn_module_zh/model/cards.py @@ -499,21 +499,21 @@ def __str__(self): def __get_river_basins(self): return [ name - for (name,) in DB.session.execute( + for name in DB.session.scalars( select(TRiverBasin.name).where( TRiverBasin.id_rb == CorZhRb.id_rb, CorZhRb.id_zh == self.id_zh ) - ).all() + ) ] def __get_hydro_zones(self): return [ name - for name in DB.session.execute( + for name in DB.session.scalars( select(THydroArea.name) .where(THydroArea.id_hydro == CorZhHydro.id_hydro, CorZhHydro.id_zh == self.id_zh) .distinct() - ).all() + ) ] @@ -1004,8 +1004,9 @@ def __str__(self): class Card(ZH): - def __init__(self, id_zh, type, ref_geo_config): + def __init__(self, id_zh, main_id_rb, type, ref_geo_config): self.id_zh = id_zh + self.main_id_rb = main_id_rb self.type = type self.ref_geo_config = ref_geo_config self.properties = self.get_properties() @@ -1018,7 +1019,7 @@ def __init__(self, id_zh, type, ref_geo_config): self.status = Status() self.evaluation = Evaluation() try: - self.hierarchy = Hierarchy(id_zh) + self.hierarchy = Hierarchy(id_zh, main_id_rb) except (NotFound, ZHApiError): self.hierarchy = None @@ -1183,7 +1184,12 @@ def __set_statuses(self): return self.status.__str__() def __set_hierarchy(self): - return self.hierarchy.as_dict() if self.hierarchy is not None else None + return { + "main_basin_name": DB.session.scalar( + select(TRiverBasin.name).where(TRiverBasin.id_rb == self.main_id_rb) + ), + "hierarchy": self.hierarchy.as_dict() if self.hierarchy is not None else None, + } def __set_evaluation(self): self.__set_main_functions() diff --git a/backend/gn_module_zh/model/zh_schema.py b/backend/gn_module_zh/model/zh_schema.py index 4a006581..c37f6aa2 100644 --- a/backend/gn_module_zh/model/zh_schema.py +++ b/backend/gn_module_zh/model/zh_schema.py @@ -247,6 +247,7 @@ class TZH(ZhModel): remark_is_other_inventory = DB.Column(DB.Unicode) main_pict_id = DB.Column(DB.Integer) area = DB.Column(DB.Float) + main_id_rb = DB.Column(DB.Integer, nullable=True) sdage = DB.relationship( TNomenclatures, @@ -314,6 +315,12 @@ def bassin_versant(self): ] return ", ".join([str(item) for item in bassin_versant]) + @hybrid_property + def main_rb_name(self): + return DB.session.scalar( + select(TRiverBasin.name).where(TRiverBasin.id_rb == self.main_id_rb) + ) + @serializable class CorZhArea(DB.Model): diff --git a/frontend/app/services/error-translator.service.ts b/frontend/app/services/error-translator.service.ts index 1402547d..150d64dd 100644 --- a/frontend/app/services/error-translator.service.ts +++ b/frontend/app/services/error-translator.service.ts @@ -116,9 +116,7 @@ export class ErrorTranslatorService { } getFrontError(errorMsg: string): string { - console.log('error:', errorMsg); const frontError: error = this.getError(errorMsg); - console.log(frontError); return frontError ? frontError.front : 'Erreur inconnue'; } diff --git a/frontend/app/services/hierarchy.service.ts b/frontend/app/services/hierarchy.service.ts index 16aefa0d..ab907609 100644 --- a/frontend/app/services/hierarchy.service.ts +++ b/frontend/app/services/hierarchy.service.ts @@ -24,8 +24,8 @@ export class HierarchyService { public currentZh: any; //public hierZh: HierarchyModel = null; public items: ItemModel[]; - public rb_name: string; public isLoading: boolean = false; + public warning: string = ''; constructor( private _dataService: ZhDataService, @@ -38,34 +38,32 @@ export class HierarchyService { } // get current zone humides - getHierarchy(zhId, rb_name) { + getHierarchy(zhId) { this.isLoading = true; - this.rb_name = rb_name; - this._dataService.getHierZh(zhId).subscribe( - (data: HierarchyModel) => { - this.items = this.setItems(data); - }, - (error) => { - this.isLoading = false; - this.items = []; - if (error.status === 404) { - this._toastr.warning("La ZH n'est présente dans aucun bassin versant", '', { - closeButton: true, - }); - } else if (error.status === 400) { - this._toastr.warning( - this._error['errors'].filter((i) => error.error['message'] === i.api)[0].front, - '', - { - closeButton: true, - } - ); + this.warning = ''; + this._dataService + .getHierZh(zhId, { + 'not-to-handle': '1', + }) + .subscribe( + (data: HierarchyModel) => { + this.setItems(data); + }, + (error) => { + this.isLoading = false; + this.items = []; + if (error.status === 404) { + this.warning = "La ZH n'est présente dans aucun bassin versant"; + } else if (error.status === 400) { + this.warning = this._error['errors'].filter( + (i) => error.error['message'] === i.api + )[0].front; + } + }, + () => { + this.isLoading = false; } - }, - () => { - this.isLoading = false; - } - ); + ); } // set list of hierarchy items @@ -347,7 +345,5 @@ export class HierarchyService { note: data.final_note, }); //this.bold_row_values.push("NOTE FINALE"); - - return this.items; } } diff --git a/frontend/app/services/zh-data.service.ts b/frontend/app/services/zh-data.service.ts index bcca0ad7..a7384c42 100644 --- a/frontend/app/services/zh-data.service.ts +++ b/frontend/app/services/zh-data.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; import { BehaviorSubject } from 'rxjs'; import { map } from 'rxjs/operators'; import { ConfigService } from '@geonature/services/config.service'; @@ -115,10 +115,10 @@ export class ZhDataService { return this._api.get(`${this.config.API_ENDPOINT}/zones_humides/${zhId}/taxa`); } - getHierZh(zhId: string) { - return this._api.get( - `${this.config.API_ENDPOINT}/zones_humides/${zhId}/hierarchy` - ); + getHierZh(zhId: string, headers?: HttpHeaders | { [header: string]: string | string[] }) { + return this._api.get(`${this.config.API_ENDPOINT}/zones_humides/${zhId}/hierarchy`, { + headers, + }); } getPdf(zhId: number) { diff --git a/frontend/app/zh-details/hierarchy/hierarchy.component.html b/frontend/app/zh-details/hierarchy/hierarchy.component.html index a5a77ac4..dcc3ef6b 100644 --- a/frontend/app/zh-details/hierarchy/hierarchy.component.html +++ b/frontend/app/zh-details/hierarchy/hierarchy.component.html @@ -1,5 +1,12 @@ -

Bassin versant : {{ data?.river_basin_name }}

+

Bassin versant : {{ main_river_basin }}

+
+ {{ hierarchy.warning }} +
- - + diff --git a/frontend/app/zh-details/zh-details.component.ts b/frontend/app/zh-details/zh-details.component.ts index c0909619..8527fa14 100644 --- a/frontend/app/zh-details/zh-details.component.ts +++ b/frontend/app/zh-details/zh-details.component.ts @@ -6,10 +6,11 @@ import { ZhDataService } from '../services/zh-data.service'; import { ErrorTranslatorService } from '../services/error-translator.service'; import { Rights } from '../models/rights'; import { ToastrService } from 'ngx-toastr'; -import { GeoJSON } from 'leaflet'; +import { Subscription } from 'rxjs'; import * as L from 'leaflet'; import { DetailsModel } from './models/zh-details.model'; +import { HierarchyService } from '../services/hierarchy.service'; @Component({ selector: 'zh-details', @@ -24,10 +25,13 @@ export class ZhDetailsComponent implements OnInit, AfterViewInit { public rights: Rights; public expanded: boolean = false; public onError: boolean = false; + private $_currentZhSub: Subscription; + public currentZh: any; constructor( private _mapService: MapService, private _zhService: ZhDataService, + public hierarchy: HierarchyService, private _route: ActivatedRoute, private _toastr: ToastrService, private _error: ErrorTranslatorService @@ -37,6 +41,16 @@ export class ZhDetailsComponent implements OnInit, AfterViewInit { this.id_zh = this._route.snapshot.params['id']; this.getRights(this.id_zh); this.getData(); + this.getCurrentZh(); + } + + getCurrentZh() { + this._zhService.getZhById(this.id_zh).subscribe((zh: any) => { + if (zh) { + this.currentZh = zh; + this.hierarchy.getHierarchy(zh.id); + } + }); } getRights(idZh: number) { @@ -107,4 +121,8 @@ export class ZhDetailsComponent implements OnInit, AfterViewInit { onWrapAll() { this.expanded = !this.expanded; } + + ngOnDestroy() { + if (this.$_currentZhSub) this.$_currentZhSub.unsubscribe(); + } } diff --git a/frontend/app/zh-forms/tabs/tab9/zh-form-tab9.component.html b/frontend/app/zh-forms/tabs/tab9/zh-form-tab9.component.html index e2e63751..5882a825 100755 --- a/frontend/app/zh-forms/tabs/tab9/zh-form-tab9.component.html +++ b/frontend/app/zh-forms/tabs/tab9/zh-form-tab9.component.html @@ -1,10 +1,29 @@

Hiérarchisation

-
-

Bassin versant : {{ hierarchy.rb_name }}

+

+ Bassin versant principal + + + Une zone humide peut intersecter plusieurs bassins versants. Le bassin versant principal est + celui qui couvre le plus de surface sur la zone humide. Le calcul de la hiérarchisation d'une + zone humide se base UNIQUEMENT sur les règles du bassin versant principal. Pour avoir une + liste complète de tous les bassins versants intersectés par une zone humide, voir l'onglet 3 + de la fiche complète. + + : {{ main_rb_name }} +

+
+ {{ hierarchy.warning }} +
+ +
{ if (zh) { - this.currentZh = zh; - this.hierarchy.getHierarchy(zh.id, zh.properties.bassin_versant); + if (zh.properties.main_rb_name != null) { + this.main_rb_name = zh.properties.main_rb_name; + this.hierarchy.getHierarchy(zh.id); + } else { + this.main_rb_name = 'aucun'; + } } }); } @@ -46,5 +51,6 @@ export class ZhFormTab9Component implements OnInit { ngOnDestroy() { if (this.$_getTabChangeSub) this.$_getTabChangeSub.unsubscribe(); if (this.$_currentZhSub) this.$_currentZhSub.unsubscribe(); + this.hierarchy.warning = ''; } }