managed routing home->concernement->entite->concernement->home AND direct url loading

This commit is contained in:
2023-04-19 16:17:09 +02:00
parent b551daa561
commit 45e8f31bd8
5 changed files with 96 additions and 54 deletions

View File

@@ -107,7 +107,6 @@ export default {
methods: {
...mapActions(ConcernementsStore,['openCloseConcernements']),
...mapActions(ConcernementsStore,['resetConcernementOpened']),
...mapActions(ConcernementsStore,['openEntite']),
animate () {
this.canvasMap.ctx.clearRect(0, 0, this.canvasMap.canvas.width, this.canvasMap.canvas.height)
// this.canvasMap.canvas.dispatchEvent(this.animateEvent)
@@ -179,33 +178,36 @@ export default {
// no concernement is yet opened, we deal concernements
if (!this.opened) {
let clickedIDs = [];
query.forEach(body => {
// console.log('body id:', body.id);
clickedIDs.push(body.id);
});
// open/close all concernements
this.openCloseConcernements(clickedIDs)
// if no concernement opened retrun to home (closing concernement contents opened)
// and reset the opened state in concernement store
if (!clickedIDs.length) {
this.resetConcernementOpened();
this.$router.push({name: 'home'});
if (query.length) {
// open/close all concernements
this.openCloseConcernements(query[0].id)
// push route
this.$router.push({name: 'concernement', params: {id: query[0].id}});
}
}
// concernement is already opened, we deal with entités
if (this.opened) {
let clickedBodies = [];
query.forEach(body => {
// console.log('body id:', body.id);
if (body.item_type === "entite") {
clickedBodies.push(body);
if (query.length) {
let clickedEntityBodies = [];
query.forEach(body => {
// console.log('body id:', body.id);
if (body.item_type === "entite") {
clickedEntityBodies.push(body);
}
});
if (clickedEntityBodies.length) {
// we have clicked on an entite
this.$router.push({name: 'concernement', params: {id: this.opened.id, eid: clickedEntityBodies[0].id}});
} else {
// otherwise we close the entite and come back to the concernement
this.$router.push({name: 'concernement', params: {id: this.opened.id}});
}
});
if (clickedBodies.length) {
this.openEntite(clickedBodies[0].cid, clickedBodies[0].id)
} else {
// if no concernement opened retrun to home (closing concernement contents opened)
// and reset the opened state in concernement store
this.resetConcernementOpened();
this.$router.push({name: 'home'});
}
}
}