vue_visgraph: add links array state in store

This commit is contained in:
Mathieu Jaumotte 2021-10-27 16:29:54 +02:00
parent 7ad0e2f2c8
commit 8ff581d5fa
2 changed files with 11 additions and 3 deletions

View File

@ -38,6 +38,7 @@ export default {
...mapGetters(['nodes', 'edges']),
...mapState(['households', 'courses', 'excludedNodesIds'
//'persons',
//'links,
//'relationships',
//'householdLoadingIds',
//'courseLoadedIds',

View File

@ -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
*/