Skip to content

Commit

Permalink
feat: conditional hierarchy fetch mvoed to dedicated service method
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Jan 16, 2025
1 parent 88355b9 commit e6847b0
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 28 deletions.
6 changes: 6 additions & 0 deletions frontend/app/services/hierarchy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ export class HierarchyService {
this.isLoading = false;
}

getHierarchyFromZh(zh) {
if (zh.properties.main_id_rb) {
this.getHierarchy(zh.properties.id_zh);
}
}

// get current zone humides
getHierarchy(zhId) {
this.isLoading = true;
Expand Down
5 changes: 1 addition & 4 deletions frontend/app/zh-forms/tabs/tab0/zh-form-tab0.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,7 @@ export class ZhFormTab0Component implements OnInit {
closeButton: true,
positionClass: 'toast-top-right',
});
console.log(this._currentZh);
if (this._currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this._currentZh.properties.id_zh);
}
this.hierarchy.getHierarchyFromZh(this._currentZh);
this.nextTab.emit(1);
});
},
Expand Down
4 changes: 1 addition & 3 deletions frontend/app/zh-forms/tabs/tab1/zh-form-tab1.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ export class ZhFormTab1Component implements OnInit {
this._toastr.success('Vos données sont bien enregistrées', '', {
positionClass: 'toast-top-right',
});
if (this.currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this.currentZh.properties.id_zh);
}
this.hierarchy.getHierarchyFromZh(this.currentZh);
this.nextTab.emit(2);
});
},
Expand Down
7 changes: 1 addition & 6 deletions frontend/app/zh-forms/tabs/tab2/zh-form-tab2.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,7 @@ export class ZhFormTab2Component implements OnInit, AfterViewInit {
this._toastr.success('Vos données sont bien enregistrées', '', {
positionClass: 'toast-top-right',
});
if (this.currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this.currentZh.properties.id_zh);
}
if (this.currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this.currentZh.properties.id_zh);
}
this.hierarchy.getHierarchyFromZh(this.currentZh);
this.nextTab.emit(3);
});
},
Expand Down
4 changes: 1 addition & 3 deletions frontend/app/zh-forms/tabs/tab3/zh-form-tab3.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,7 @@ export class ZhFormTab3Component implements OnInit {
this._toastr.success('Vos données sont bien enregistrées', '', {
positionClass: 'toast-top-right',
});
if (this.currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this.currentZh.properties.id_zh);
}
this.hierarchy.getHierarchyFromZh(this.currentZh);
this.nextTab.emit(4);
});
},
Expand Down
4 changes: 1 addition & 3 deletions frontend/app/zh-forms/tabs/tab4/zh-form-tab4.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,7 @@ export class ZhFormTab4Component implements OnInit {
this._toastr.success('Vos données sont bien enregistrées', '', {
positionClass: 'toast-top-right',
});
if (this.currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this.currentZh.properties.id_zh);
}
this.hierarchy.getHierarchyFromZh(this.currentZh);
this.nextTab.emit(5);
});
},
Expand Down
4 changes: 1 addition & 3 deletions frontend/app/zh-forms/tabs/tab5/zh-form-tab5.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1145,9 +1145,7 @@ export class ZhFormTab5Component implements OnInit {
this._toastr.success('Vos données sont bien enregistrées', '', {
positionClass: 'toast-top-right',
});
if (this.currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this.currentZh.properties.id_zh);
}
this.hierarchy.getHierarchyFromZh(this.currentZh);
this.nextTab.emit(6);
});
},
Expand Down
4 changes: 1 addition & 3 deletions frontend/app/zh-forms/tabs/tab6/zh-form-tab6.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -992,9 +992,7 @@ export class ZhFormTab6Component implements OnInit {
this._toastr.success('Vos données sont bien enregistrées', '', {
positionClass: 'toast-top-right',
});
if (this.currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this.currentZh.properties.id_zh);
}
this.hierarchy.getHierarchyFromZh(this.currentZh);
this.nextTab.emit(7);
});
},
Expand Down
4 changes: 1 addition & 3 deletions frontend/app/zh-forms/tabs/tab7/zh-form-tab7.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,7 @@ export class ZhFormTab7Component implements OnInit {
this._toastr.success('Vos données sont bien enregistrées', '', {
positionClass: 'toast-top-right',
});
if (this.currentZh.properties.main_id_rb) {
this.hierarchy.getHierarchy(this.currentZh.properties.id_zh);
}
this.hierarchy.getHierarchyFromZh(this.currentZh);
this.nextTab.emit(8);
});
},
Expand Down

0 comments on commit e6847b0

Please sign in to comment.