entite are opening well in all modes
This commit is contained in:
parent
fbde40263f
commit
139db3516a
@ -72,6 +72,7 @@ export default {
|
||||
this.id = this.mapitem.id;
|
||||
this.concernement = this.mapitem.concernement;
|
||||
this.cid = this.concernement.id;
|
||||
console.log('mapitem this.cid', this.cid);
|
||||
this.active_revision = this.concernement.active_revision;
|
||||
|
||||
// console.log(`ConcernementsMapItem ${this.id} created`);
|
||||
@ -1388,7 +1389,7 @@ export default {
|
||||
// wait for routing to be finished before opening the mapItem
|
||||
await this.$router.push({
|
||||
name: 'concernement',
|
||||
params: {cid: this.cid},
|
||||
params: {cid: parseInt(this.cid)},
|
||||
query: {
|
||||
mapitemid: this.id,
|
||||
superposition_id: this.mapitem.superposition_ids[0]
|
||||
@ -1429,8 +1430,12 @@ export default {
|
||||
// we have clicked on an entite
|
||||
this.$router.push({
|
||||
name: 'concernement',
|
||||
params: {cid: this.cid, eid: result.item.item_id},
|
||||
query: {
|
||||
mapitemid: this.id,
|
||||
superposition_id: this.mapitem.superposition_ids[0]
|
||||
},
|
||||
hash: `#${this.map_mode}`,
|
||||
params: {id: this.cid, mapitemid: this.id, eid: result.item.item_id}
|
||||
});
|
||||
break;
|
||||
case "doleancer":
|
||||
|
@ -4,7 +4,7 @@ import { mapActions, mapState } from 'pinia'
|
||||
import { ConcernementsStore } from '@stores/concernements'
|
||||
|
||||
export default {
|
||||
props: ['entite', 'eid'],
|
||||
props: ['concernement', 'entite', 'eid'],
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
@ -15,7 +15,7 @@ export default {
|
||||
'ct_entite']),
|
||||
field_menace_maintien_label (){
|
||||
let str;
|
||||
if (this.opened_concernement.entites_byid[this.eid].menacemaintien < 0) {
|
||||
if (this.concernement.entites_byid[this.eid].menacemaintien < 0) {
|
||||
str = this.ct_entite.field_menace_maintien.description.replace('/maintient', '')
|
||||
} else {
|
||||
str = this.ct_entite.field_menace_maintien.description.replace('menace/', '')
|
||||
@ -24,7 +24,7 @@ export default {
|
||||
},
|
||||
field_sources_label () {
|
||||
let str;
|
||||
if (this.opened_concernement.entites_byid[this.eid].menacemaintien < 0) {
|
||||
if (this.concernement.entites_byid[this.eid].menacemaintien < 0) {
|
||||
str = this.ct_entite.field_sources.description.replace('/ ce maintient', '')
|
||||
} else {
|
||||
str = this.ct_entite.field_sources.description.replace('cette menace /', '')
|
||||
|
@ -5,6 +5,12 @@ import { ConcernementsStore } from '@stores/concernements'
|
||||
import { UserStore } from '@/stores/user'
|
||||
// import { CommonStore } from '@/stores/common'
|
||||
|
||||
import { print } from 'graphql/language/printer'
|
||||
import gql from 'graphql-tag'
|
||||
import GQL from '@api/graphql-axios'
|
||||
import EntiteFields from '@api/gql/entite.fragment.gql'
|
||||
|
||||
|
||||
import CartoucheLayout from '@components/layout/CartoucheLayout.vue';
|
||||
import Entite from '@components/contents/Entite.vue';
|
||||
|
||||
@ -16,10 +22,11 @@ import { mdiChevronRight } from '@mdi/js';
|
||||
import { mdiChevronDown } from '@mdi/js';
|
||||
|
||||
export default {
|
||||
props: ['cid', 'eid', 'entite'],
|
||||
props: ['cid', 'eid'],
|
||||
data(){
|
||||
return {
|
||||
concernement: null,
|
||||
entite: null,
|
||||
history_value: 0,
|
||||
history_slider_ops: null,
|
||||
infos_opened: false,
|
||||
@ -53,8 +60,12 @@ export default {
|
||||
|
||||
console.log(`terraindevie created, cid: ${this.cid}, eid: ${this.eid}, this.concernement:`, this.concernement);
|
||||
|
||||
// revisions
|
||||
|
||||
//entite
|
||||
if (this.eid) {
|
||||
this.loadEntite()
|
||||
}
|
||||
|
||||
// revisions
|
||||
let data=[];
|
||||
this.concernement.revisions.forEach(rev => {
|
||||
if (rev.entites.length > 3) {
|
||||
@ -87,12 +98,37 @@ export default {
|
||||
this.setActiveRevision(this.concernement.id, n);
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
eid: {
|
||||
handler (n, o) {
|
||||
console.log(`TerrainDeVie watch eid o:${o}, n:${n}`);
|
||||
this.loadEntite()
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions(ConcernementsStore, ['setActiveRevision']), // 'loadConcernementsRevisions'
|
||||
onClickInfos(){
|
||||
this.infos_opened = !this.infos_opened;
|
||||
},
|
||||
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)
|
||||
})
|
||||
}
|
||||
},
|
||||
components: {
|
||||
@ -130,7 +166,7 @@ export default {
|
||||
</template>
|
||||
|
||||
<!-- entite -->
|
||||
<Entite v-if="entite" :entite="entite" :eid="eid"/>
|
||||
<Entite v-if="entite" :concernement="concernement" :entite="entite" :eid="eid"/>
|
||||
</template>
|
||||
|
||||
<template v-slot:footer>
|
||||
|
@ -94,7 +94,7 @@ export const ConcernementsStore = defineStore({
|
||||
|
||||
// SUPERPOSITIONS
|
||||
if (entite.entite.superposition.length) {
|
||||
concernement.has_superpositions = true;
|
||||
// create properties for later
|
||||
concernement.superpositions = {};
|
||||
concernement.superposition_constraints_id = {};
|
||||
concernement.all_superposed_concernements_id = [];
|
||||
@ -179,6 +179,8 @@ export const ConcernementsStore = defineStore({
|
||||
temp_allSuperpositions.forEach(s => {
|
||||
if (s[0] && s[0].cid && s[0].eid && s[1] && s[1].cid && s[1].eid) {
|
||||
this.allSuperpositions.push(s);
|
||||
this.concernementsByID[s[0].cid].has_superpositions = true;
|
||||
this.concernementsByID[s[1].cid].has_superpositions = true;
|
||||
}
|
||||
});
|
||||
|
||||
@ -371,7 +373,7 @@ export const ConcernementsStore = defineStore({
|
||||
this.opened_concernement = null;
|
||||
this.openCloseConcernements();
|
||||
},
|
||||
setOpenedEntityId(id){
|
||||
setOpenedEntiteId(id){
|
||||
this.opened_entite_id = id;
|
||||
},
|
||||
setBesoinPaperId(paper_id, cid, bid, rid){
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user