mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
vue_visgraph: add links array state in store
This commit is contained in:
parent
7ad0e2f2c8
commit
8ff581d5fa
@ -38,6 +38,7 @@ export default {
|
|||||||
...mapGetters(['nodes', 'edges']),
|
...mapGetters(['nodes', 'edges']),
|
||||||
...mapState(['households', 'courses', 'excludedNodesIds'
|
...mapState(['households', 'courses', 'excludedNodesIds'
|
||||||
//'persons',
|
//'persons',
|
||||||
|
//'links,
|
||||||
//'relationships',
|
//'relationships',
|
||||||
//'householdLoadingIds',
|
//'householdLoadingIds',
|
||||||
//'courseLoadedIds',
|
//'courseLoadedIds',
|
||||||
|
@ -11,6 +11,7 @@ const store = createStore({
|
|||||||
households: [],
|
households: [],
|
||||||
courses: [],
|
courses: [],
|
||||||
relationships: [],
|
relationships: [],
|
||||||
|
links: [],
|
||||||
householdLoadingIds: [],
|
householdLoadingIds: [],
|
||||||
courseLoadedIds: [],
|
courseLoadedIds: [],
|
||||||
excludedNodesIds: []
|
excludedNodesIds: []
|
||||||
@ -35,6 +36,9 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
edges(state) {
|
edges(state) {
|
||||||
let edges = []
|
let edges = []
|
||||||
|
state.links.forEach(l => {
|
||||||
|
edges.push(l)
|
||||||
|
})
|
||||||
state.relationships.forEach(r => {
|
state.relationships.forEach(r => {
|
||||||
edges.push(r)
|
edges.push(r)
|
||||||
})
|
})
|
||||||
@ -60,6 +64,10 @@ const store = createStore({
|
|||||||
console.log('+ addCourse', course.id)
|
console.log('+ addCourse', course.id)
|
||||||
state.courses.push(adapt2vis(course))
|
state.courses.push(adapt2vis(course))
|
||||||
},
|
},
|
||||||
|
addLink(state, link) {
|
||||||
|
console.log('+ addLink from', link.from, 'to', link.to)
|
||||||
|
state.links.push(link)
|
||||||
|
},
|
||||||
addRelationship(state, relationship) {
|
addRelationship(state, relationship) {
|
||||||
console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
|
console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
|
||||||
state.relationships.push(relationship)
|
state.relationships.push(relationship)
|
||||||
@ -134,7 +142,7 @@ const store = createStore({
|
|||||||
const members = household.members.filter(v => household.current_members_id.includes(v.id))
|
const members = household.members.filter(v => household.current_members_id.includes(v.id))
|
||||||
members.forEach(m => {
|
members.forEach(m => {
|
||||||
//console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id)
|
//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}`,
|
from: `${m.person.type}_${m.person.id}`,
|
||||||
to: `household_${m.person.current_household_id}`,
|
to: `household_${m.person.current_household_id}`,
|
||||||
id: `p${m.person.id}-h${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)
|
let currentParticipations = course.participations.filter(p => p.endDate === null)
|
||||||
console.log(' participations', currentParticipations.length)
|
console.log(' participations', currentParticipations.length)
|
||||||
currentParticipations.forEach(p => {
|
currentParticipations.forEach(p => {
|
||||||
commit('addRelationship', {
|
commit('addLink', {
|
||||||
from: `${p.person.type}_${p.person.id}`,
|
from: `${p.person.type}_${p.person.id}`,
|
||||||
to: `${course.id}`,
|
to: `${course.id}`,
|
||||||
id: `p${p.person.id}-c`+ course.id.split('_')[2],
|
id: `p${p.person.id}-c`+ course.id.split('_')[2],
|
||||||
@ -202,7 +210,6 @@ const store = createStore({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch Relationship
|
* Fetch Relationship
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user