click on entite opened the entite in concernement cartouche

This commit is contained in:
2023-04-19 11:04:57 +02:00
parent 440e6d9f15
commit a47ed7b772
7 changed files with 110 additions and 23 deletions

View File

@@ -3,14 +3,18 @@
import { mapActions, mapState } from 'pinia'
import { ConcernementsStore } from '@stores/concernements'
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'
export default {
props: ['id'],
// data(){
// return {
// block: null
// }
// },
props: ['id', 'eid'],
data(){
return {
entite: null
}
},
computed: {
...mapState(ConcernementsStore,['opened']),
...mapState(ConcernementsStore,['ct_concernement'])
@@ -19,8 +23,34 @@ export default {
// console.log("Concernement view created, id", this.opened.id);
// this.loadStatics()
},
watch: {
eid: {
handler (n, o){
this.loadEntite()
},
deep: true
},
},
methods: {
// ...mapActions(StaticsStore,['loadStatics'])
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: {
}
@@ -30,6 +60,7 @@ export default {
<template>
<section class="concernement">
<div v-if="this.entite">{{ entite.title }}</div>
<header>
<label>{{ this.ct_concernement.title.description }}</label>
<h2>{{ opened.title }}</h2>