diff --git a/src/components/Feature/Detail/FeatureTable.vue b/src/components/Feature/Detail/FeatureTable.vue index ba6b36833117d222f154f8b8c4535298c77e23da..66164bea05d85659a651b5d1c31f1dbcaea41116 100644 --- a/src/components/Feature/Detail/FeatureTable.vue +++ b/src/components/Feature/Detail/FeatureTable.vue @@ -237,20 +237,7 @@ export default { featureFields() { return this.fastEditionMode ? this.extra_forms : this.featureData; } - }, - - methods: { - toFeature(link) { - this.$emit('tofeature', { - name: 'details-signalement', - params: { - slug_type_signal: link.feature_to.feature_type_slug, - slug_signal: link.feature_to.feature_id, - }, - }); - }, } - }; </script> diff --git a/src/views/Feature/FeatureDetail.vue b/src/views/Feature/FeatureDetail.vue index 01d47327e04803e0b9800276943a68307bcfc06d..9068857a9ba1f8542588e13f2ecb36970d7da9da 100644 --- a/src/views/Feature/FeatureDetail.vue +++ b/src/views/Feature/FeatureDetail.vue @@ -29,7 +29,6 @@ :feature-type="feature_type" :fast-edition-mode="project.fast_edition_mode" :can-edit-feature="canEditFeature" - @tofeature="pushNgo" /> </div> <div @@ -323,9 +322,14 @@ export default { }, watch: { + /** + * To navigate back or forward to the previous or next URL, the query params in url are updated + * since the route doesn't change, mounted is not called, then the page isn't updated + * To reload page infos we need to call initPage() when query changes + */ '$route.query'(newValue, oldValue) { - if (newValue !== oldValue) { //* Navigate back or forward to the previous or next URL - this.initPage(); //* doesn't update the page at query changes, thus it is done manually here + if (newValue !== oldValue) { + this.initPage(); } }, }, @@ -361,9 +365,12 @@ export default { async initPage() { await this.getPageInfo(); - if (this.currentFeature && this.feature_type && this.feature_type.geom_type !== 'none') { + if(this.feature_type && this.feature_type.geom_type === 'none') { + // setting map to null to ensure map would be created when navigating next to a geographical feature + this.map = null; + } else if (this.currentFeature) { this.initMap(); - } + } }, async getPageInfo() { @@ -421,23 +428,11 @@ export default { this.next(); }, - async reloadPage() { - await this.getPageInfo(); - if (this.feature_type && this.feature_type.geom_type !== 'none') { - mapService.removeFeatures(); - this.addFeatureToMap(); - } else { - // empty map in order to detect if map need to be created again when navigating to a classic feature from a non geographical feature (without map) - this.map = null; - } - }, - pushNgo(newEntry) { - this.$router.push(newEntry) //* update the params or queries in the route/url - .then(() => { - this.reloadPage(); - }) - .catch(() => true); //* catch error if navigation get aborted (in beforeRouteUpdate) + //* update the params or queries in the route/url + this.$router.push(newEntry) + //* catch error if navigation get aborted (in beforeRouteUpdate) + .catch(() => true); }, goBackToProject(message) { @@ -564,7 +559,9 @@ export default { } ).then((response) => { if (response === 'reloadPage') { - this.reloadPage(); + // when query doesn't change we need to reload the page infos with initPage(), + // since it would not be called from the watcher'$route.query' when the query does change + this.initPage(); } }); }