Skip to content
Snippets Groups Projects
Commit 0922ef18 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

Ensure map is created in fast navigation & removing unused methods

parent 0cba74ed
No related branches found
No related tags found
1 merge request!735REDMINE_ISSUE-19119 | Permettre la gestion de signalements non-géographiques (REDMINE_ISSUE-19667 | La recherche de doublon à l'import de signalement s'applique sur les signalements supprimés)
......@@ -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>
......
......@@ -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();
}
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment