displaying fields labels

This commit is contained in:
2023-04-17 14:00:45 +02:00
parent 592f358cab
commit a940012b6e
7 changed files with 97 additions and 18 deletions

View File

@@ -1,4 +1,6 @@
import { defineStore } from 'pinia'
// import REST from '@api/rest-axios'
// import JSONAPI from '@api/json-axios'
import { print } from 'graphql/language/printer'
import gql from 'graphql-tag'
@@ -9,13 +11,15 @@ import GQL from '@api/graphql-axios'
// import JSONAPI from '@api/json-axios'
import ConcernementFields from '@api/gql/concernement.fragment.gql'
// import EntityFields from '@api/gql/entitydef.fragment.gql'
export const ConcernementsStore = defineStore({
id: 'concernements',
state: () => ({
concernements: [],
concernementsByID: {},
opened: false
opened: false,
ct_concernement: {}
}),
getters: {
@@ -46,6 +50,30 @@ export const ConcernementsStore = defineStore({
})
})
},
loadContentTypeDefinition () {
const body = {
query: `
query EntityDef($type: String!, $bundle: String!){
entitydef(type: $type, bundle: $bundle) {
fields {
type
field_name
label
description
}
}
}`,
variables: { type: 'node', bundle: 'concernement' }
}
GQL.post('', body)
.then(({ data: { data: { entitydef }}}) => {
console.log('loadContentTypeDefinition entitydef', entitydef);
entitydef.fields.forEach(field => {
this.ct_concernement[field.field_name] = field;
});
})
},
openCloseConcernement (id, state) {
// console.log('openCloseConcernement', id, state);
this.concernementsByID[id].opened = state;