entite are opening well in all modes

This commit is contained in:
2023-09-20 12:28:19 +02:00
parent fbde40263f
commit 139db3516a
5 changed files with 120 additions and 64 deletions

View File

@@ -17,11 +17,20 @@ import PuissanceAgir from '@components/contents/PuissanceAgir.vue';
import Doleancer from '@components/contents/Doleancer.vue';
export default {
// props: {
// cid: {
// type: Number
// },
// eid: {
// type: Number
// }
// },
props: ['cid', 'eid'],
data(){
return {
entite: null,
// entite: null,
superposition_id: null,
superposition: null,
opened_besoin_id: null,
arrowup_path: mdiArrowUp
}
@@ -32,31 +41,24 @@ export default {
'concernements_loaded',
'allSuperpositions_byid']),
...mapState(CommonStore,['cartouch_width']),
// superposition_id () {
// console.log('superposition_id computed');
// if(this.$route.query.superposition_id){
// return this.$route.query.superposition_id
// } else {
// return null;
// }
// },
superposition () {
console.log('superposition computed', this.superposition_id);
if(this.superposition_id){
let sid = this.$route.query.superposition_id;
let ids = sid.match(/(\d+)_(\d+)__(\d+)_(\d+)/i)
let couple_key = `${ids[1]}-${ids[3]}`
console.log('superposition_id', sid, couple_key, ids);
if (this.allSuperpositions_byid[couple_key][sid]) {
let s = this.allSuperpositions_byid[couple_key][sid]
console.log(s);
return s;
}else{
return null;
}
} else {
return null;
//
main_cid_eid () {
let r = {
cid: this.cid,
eid: null
};
if (this.eid) {
r.eid = this.eid
} else if (this.map_mode === "superposition" && this.superposition) {
this.superposition.forEach(s => {
// routeview param -> props do not respect type (Number), this.cid should be number
if(s.cid === parseInt(this.cid)){
r.eid = s.eid;
}
});
}
return r;
},
superposed_cid_eid () {
if (this.superposition) {
@@ -83,7 +85,18 @@ export default {
console.log("superposition", this.superposition);
if(this.map_mode === "superposition" && this.$route.query.superposition_id){
// get superposition_id and superposition object
this.superposition_id = this.$route.query.superposition_id;
console.log('this.superposition_id', this.superposition_id);
if(this.superposition_id){
let ids = this.superposition_id.match(/(\d+)_(\d+)__(\d+)_(\d+)/i)
let couple_key = `${ids[1]}-${ids[3]}`
// console.log('superposition_id', this.superposition_id, couple_key, ids);
if (this.allSuperpositions_byid[couple_key][this.superposition_id]) {
this.superposition = this.allSuperpositions_byid[couple_key][this.superposition_id]
console.log("this.superposition", this.superposition);
}
}
// as we have two content to show multiply the cartouch with by 2
// necessary for mapitem opening scale and position
this.setCartoucheWidth(2)
@@ -95,8 +108,8 @@ export default {
// when we arrived directly to the url, load the entite
// this.eid provided by route params
if (!this.entity && this.eid) {
this.openEntity();
if (this.map_mode === "terraindevie" && this.eid) {
this.openEntite();
}
},
watch: {
@@ -113,10 +126,10 @@ export default {
eid: {
handler (n, o){
if(n){
this.openEntity()
this.openEntite()
}else{
this.entite = false;
this.setOpenedEntityId(null);
// this.entite = false;
this.setOpenedEntiteId(null);
}
},
deep: true
@@ -124,32 +137,32 @@ export default {
},
methods: {
...mapActions(ConcernementsStore,['openCloseConcernements',
'setOpenedEntityId',
'setOpenedEntiteId',
'setMapMode',
'resetConcernementOpened']),
...mapActions(CommonStore,['setCartoucheWidth']),
openEntity(){
this.setOpenedEntityId(parseInt(this.eid))
this.loadEntite()
},
loadEntite(){
const ast = gql`{
entite (id: ${this.eid}) {
...EntiteFields
}
}
${EntiteFields}
`
console.log('ast', ast);
GQL.post('', { query: print(ast) })
.then(({data: { data: { entite }}}) => {
console.log('load entite loaded', entite)
this.entite = entite
})
.catch(error => {
console.warn('Issue with load entite', error)
})
openEntite(){
this.setOpenedEntiteId(parseInt(this.eid))
// this.loadEntite()
},
// loadEntite(){
// const ast = gql`{
// entite (id: ${this.eid}) {
// ...EntiteFields
// }
// }
// ${EntiteFields}
// `
// console.log('ast', ast);
// GQL.post('', { query: print(ast) })
// .then(({data: { data: { entite }}}) => {
// console.log('load entite loaded', entite)
// this.entite = entite
// })
// .catch(error => {
// console.warn('Issue with load entite', error)
// })
// },
closeConcernement(){
this.resetConcernementOpened();
}
@@ -166,7 +179,7 @@ export default {
<template>
<section v-if="opened_concernement" class="concernement">
<TerrainDeVie v-if="map_mode === 'terraindevie' || map_mode === 'action'|| map_mode === 'superposition'" :cid="cid" :eid="eid" :entite="entite"/>
<TerrainDeVie v-if="map_mode === 'terraindevie' || map_mode === 'action'|| map_mode === 'superposition'" :cid="main_cid_eid.cid" :eid="main_cid_eid.eid"/>
<PuissanceAgir v-if="map_mode === 'puissancedagir'" :id="cid"/>
<Doleancer v-if="map_mode === 'doleancer'" :id="cid"/>
</section>