From 8ff581d5facce919fa108beecd4221404d1bfe15 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 27 Oct 2021 16:29:54 +0200 Subject: [PATCH] vue_visgraph: add links array state in store --- .../Resources/public/vuejs/VisGraph/App.vue | 1 + .../Resources/public/vuejs/VisGraph/store.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue index 7be18e6eb..916fb05ef 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/App.vue @@ -38,6 +38,7 @@ export default { ...mapGetters(['nodes', 'edges']), ...mapState(['households', 'courses', 'excludedNodesIds' //'persons', + //'links, //'relationships', //'householdLoadingIds', //'courseLoadedIds', diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js index 25d044afb..310315946 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js @@ -11,6 +11,7 @@ const store = createStore({ households: [], courses: [], relationships: [], + links: [], householdLoadingIds: [], courseLoadedIds: [], excludedNodesIds: [] @@ -35,6 +36,9 @@ const store = createStore({ }, edges(state) { let edges = [] + state.links.forEach(l => { + edges.push(l) + }) state.relationships.forEach(r => { edges.push(r) }) @@ -60,6 +64,10 @@ const store = createStore({ console.log('+ addCourse', course.id) state.courses.push(adapt2vis(course)) }, + addLink(state, link) { + console.log('+ addLink from', link.from, 'to', link.to) + state.links.push(link) + }, addRelationship(state, relationship) { console.log('+ addRelationship from', relationship.from, 'to', relationship.to) state.relationships.push(relationship) @@ -134,7 +142,7 @@ const store = createStore({ const members = household.members.filter(v => household.current_members_id.includes(v.id)) members.forEach(m => { //console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id) - commit('addRelationship', { + commit('addLink', { from: `${m.person.type}_${m.person.id}`, to: `household_${m.person.current_household_id}`, id: `p${m.person.id}-h${m.person.current_household_id}`, @@ -189,7 +197,7 @@ const store = createStore({ let currentParticipations = course.participations.filter(p => p.endDate === null) console.log(' participations', currentParticipations.length) currentParticipations.forEach(p => { - commit('addRelationship', { + commit('addLink', { from: `${p.person.type}_${p.person.id}`, to: `${course.id}`, id: `p${p.person.id}-c`+ course.id.split('_')[2], @@ -202,7 +210,6 @@ const store = createStore({ }) }, - /** * Fetch Relationship */