visgraph: an event trigger unfoldPersonsByCourse (store)

This commit is contained in:
2021-11-03 21:15:37 +01:00
parent 8ab0fd59f8
commit 40c5322cba
2 changed files with 39 additions and 3 deletions

View File

@@ -111,6 +111,17 @@ const store = createStore({
},
removeExcludedNode(state, id) {
state.excludedNodesIds = state.excludedNodesIds.filter(e => e !== id)
},
//// unfold
unfoldPerson(state, person) {
console.log('unfoldPerson', person)
if (person.label !== null) {
throw 'person is not expandable'
}
person.label = person._label
delete person._label
delete person.title
}
},
actions: {
@@ -307,16 +318,30 @@ const store = createStore({
},
/**
* Fetch missing person
* Add missing person. node is displayed without label (folded).
* We stop here and listen on events to unfold person and expand its fetch infos
* @param object
* @param person
*/
addMissingPerson({ commit, getters, dispatch }, person) {
commit('markPersonLoaded', person.id)
commit('addPerson', adapt2vis(person, { folded: true }))
},
console.log(' fetch infos for missing', person.id)
//dispatch('fetchInfoForPerson', person)
/**
* Triggered by a vis-network event when clicking on a Course Node.
* Each folded node is unfold, then expanded with fetch infos
* @param object
* @param course
*/
unfoldPersonsByCourse({ commit, dispatch }, course) {
let currentParticipations = course.participations.filter(p => p.endDate === null)
currentParticipations.forEach(p => {
if (p.person.label === null) {
commit('unfoldPerson', p.person)
dispatch('fetchInfoForPerson', p.person)
}
})
},
}
})