mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
visgraph: fix algo problems when expanding graph
This commit is contained in:
parent
19badc0062
commit
55c2aed613
@ -147,7 +147,7 @@ export default {
|
|||||||
]),
|
]),
|
||||||
|
|
||||||
visgraph_data() {
|
visgraph_data() {
|
||||||
//console.log('::: visgraph_data :::', this.nodes.length, 'nodes,', this.edges.length, 'edges')
|
console.log('::: visgraph_data :::', this.nodes.length, 'nodes,', this.edges.length, 'edges')
|
||||||
return {
|
return {
|
||||||
nodes: this.nodes,
|
nodes: this.nodes,
|
||||||
edges: this.edges
|
edges: this.edges
|
||||||
@ -239,7 +239,7 @@ export default {
|
|||||||
|
|
||||||
case 'person':
|
case 'person':
|
||||||
let person = this.nodes.filter(n => n.id === data.nodes[0])[0]
|
let person = this.nodes.filter(n => n.id === data.nodes[0])[0]
|
||||||
console.log('@@@@@@@@ event on selected Person Node @@@@@@@@', person.id)
|
console.log('@@@@@@ event on selected Node', person.id)
|
||||||
if (person.label === null) {
|
if (person.label === null) {
|
||||||
this.$store.commit('unfoldPerson', person)
|
this.$store.commit('unfoldPerson', person)
|
||||||
this.forceUpdateComponent()
|
this.forceUpdateComponent()
|
||||||
@ -248,14 +248,14 @@ export default {
|
|||||||
|
|
||||||
case 'household':
|
case 'household':
|
||||||
let household = this.nodes.filter(n => n.id === data.nodes[0])[0]
|
let household = this.nodes.filter(n => n.id === data.nodes[0])[0]
|
||||||
console.log('######## event on selected Household Node ########', household.id)
|
console.log('@@@@@@ event on selected Node', household.id)
|
||||||
this.$store.dispatch('unfoldPersonsByHousehold', household)
|
this.$store.dispatch('unfoldPersonsByHousehold', household)
|
||||||
this.forceUpdateComponent()
|
this.forceUpdateComponent()
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'accompanying_period':
|
case 'accompanying_period':
|
||||||
let course = this.nodes.filter(n => n.id === data.nodes[0])[0]
|
let course = this.nodes.filter(n => n.id === data.nodes[0])[0]
|
||||||
console.log('&&&&&&&& event on selected AccompanyingCourse Node &&&&&&&&', course.id)
|
console.log('@@@@@@ event on selected Node', course.id)
|
||||||
this.$store.dispatch('unfoldPersonsByCourse', course)
|
this.$store.dispatch('unfoldPersonsByCourse', course)
|
||||||
this.forceUpdateComponent()
|
this.forceUpdateComponent()
|
||||||
break
|
break
|
||||||
@ -277,9 +277,9 @@ export default {
|
|||||||
this.refreshNetwork
|
this.refreshNetwork
|
||||||
},
|
},
|
||||||
toggleLayer(value) {
|
toggleLayer(value) {
|
||||||
//console.log('toggleLayer')
|
|
||||||
this.forceUpdateComponent()
|
|
||||||
let id = value.target.value
|
let id = value.target.value
|
||||||
|
console.log('@@@@@ toggle Layer', id)
|
||||||
|
this.forceUpdateComponent()
|
||||||
if (this.checkedLayers.includes(id)) {
|
if (this.checkedLayers.includes(id)) {
|
||||||
this.removeLayer(id)
|
this.removeLayer(id)
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,40 +64,44 @@ const store = createStore({
|
|||||||
//console.log('getParticipationsByCourse', course_id)
|
//console.log('getParticipationsByCourse', course_id)
|
||||||
const course = state.courses.filter(c => c.id === course_id)[0]
|
const course = state.courses.filter(c => c.id === course_id)[0]
|
||||||
const currentParticipations = course.participations.filter(p => p.endDate === null)
|
const currentParticipations = course.participations.filter(p => p.endDate === null)
|
||||||
const participations = []
|
console.log('get persons in', course_id,
|
||||||
currentParticipations.forEach(p => {
|
currentParticipations.map(p => p.person.id), //currentParticipations.map(p => p.person),
|
||||||
participations.push(p)
|
'with folded', currentParticipations
|
||||||
})
|
.filter(p => p.person.folded === true)
|
||||||
console.log('participations',
|
.map(p => p.person.id)
|
||||||
participations.map(i => i.person.id),
|
|
||||||
participations
|
|
||||||
.filter(i => typeof i.person._id !== 'undefined')
|
|
||||||
.map(i => i.person.id)
|
|
||||||
)
|
)
|
||||||
return participations
|
return currentParticipations
|
||||||
},
|
},
|
||||||
|
|
||||||
getMembersByHousehold: (state) => (household_id) => {
|
getMembersByHousehold: (state) => (household_id) => {
|
||||||
//console.log('getMembersByHousehold', household_id)
|
//console.log('getMembersByHousehold', household_id)
|
||||||
const household = state.households.filter(h => h.id === household_id)[0]
|
const household = state.households.filter(h => h.id === household_id)[0]
|
||||||
const currentMembers = household.members.filter(m => household.current_members_id.includes(m.id))
|
const currentMembers = household.members.filter(m => household.current_members_id.includes(m.id))
|
||||||
const members = []
|
console.log('get persons in', household_id,
|
||||||
currentMembers.forEach(m => {
|
currentMembers.map(m => m.person.id), //currentMembers.map(m => m.person),
|
||||||
members.push(m)
|
'with folded', currentMembers
|
||||||
})
|
.filter(m => m.person.folded === true)
|
||||||
console.log('members',
|
.map(m => m.person.id)
|
||||||
members.map(i => i.person.id),
|
|
||||||
members
|
|
||||||
.filter(i => typeof i.person._id !== 'undefined')
|
|
||||||
.map(i => i.person.id)
|
|
||||||
)
|
)
|
||||||
return members
|
return currentMembers
|
||||||
},
|
},
|
||||||
|
|
||||||
getFoldedPersons: () => (array) => {
|
getFoldedPersons: (state) => (array) => {
|
||||||
return array
|
//console.log('array', array.map(r => r.person.id))
|
||||||
.filter(i => typeof i.person._id !== 'undefined')
|
|
||||||
.map(i => i.person)
|
let folded = []
|
||||||
|
array.forEach(a => {
|
||||||
|
let id = (typeof a.person._id !== 'undefined') ? a.person._id : a.person.id
|
||||||
|
if (state.personLoadedIds.includes(id)) {
|
||||||
|
folded.push(state.persons.filter(person => person._id === id)[0])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log('get FoldedPersons', folded.map(r => r.id))
|
||||||
|
return folded
|
||||||
|
|
||||||
|
//return array
|
||||||
|
// .filter(i => i.person.folded === true) ///// <== tout ce qui passe dans la mutation addPerson reçoit un _id
|
||||||
|
// .map(i => i.person) ///// donc changer le filtrage
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -110,10 +114,13 @@ const store = createStore({
|
|||||||
person._id = person.id
|
person._id = person.id
|
||||||
person.id = `person_${person.id}`
|
person.id = `person_${person.id}`
|
||||||
person.label = `*${person.text}*\n_${getGender(person.gender)} - ${getAge(person.birthdate)}_`
|
person.label = `*${person.text}*\n_${getGender(person.gender)} - ${getAge(person.birthdate)}_`
|
||||||
if (options.folded) {
|
person.folded = false
|
||||||
|
|
||||||
|
if (options.folded) { // used by missing persons
|
||||||
person.title = visMessages.fr.visgraph.click_to_expand
|
person.title = visMessages.fr.visgraph.click_to_expand
|
||||||
person._label = person.label // keep label
|
person._label = person.label // keep label
|
||||||
person.label = null
|
person.label = null
|
||||||
|
person.folded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
state.persons.push(person)
|
state.persons.push(person)
|
||||||
@ -181,23 +188,26 @@ const store = createStore({
|
|||||||
|
|
||||||
//// excluded
|
//// excluded
|
||||||
addExcludedNode(state, id) {
|
addExcludedNode(state, id) {
|
||||||
console.log('exclude list: +', id)
|
console.log('==> exclude list: +', id)
|
||||||
state.excludedNodesIds.push(id)
|
state.excludedNodesIds.push(id)
|
||||||
},
|
},
|
||||||
removeExcludedNode(state, id) {
|
removeExcludedNode(state, id) {
|
||||||
console.log('exclude list: -', id)
|
console.log('<== exclude list: -', id)
|
||||||
state.excludedNodesIds = state.excludedNodesIds.filter(e => e !== id)
|
state.excludedNodesIds = state.excludedNodesIds.filter(e => e !== id)
|
||||||
},
|
},
|
||||||
|
|
||||||
//// unfold
|
//// unfold
|
||||||
unfoldPerson(state, person) {
|
unfoldPerson(state, person) {
|
||||||
//console.log('unfoldPerson', person)
|
if (person.folded === true) {
|
||||||
if (person.label !== null) {
|
console.log('unfoldPerson', person)
|
||||||
throw 'person is not folded'
|
person.label = person._label
|
||||||
|
delete person._label
|
||||||
|
delete person.title
|
||||||
|
person.folded = false
|
||||||
|
} else {
|
||||||
|
console.log('person is not folded', person)
|
||||||
|
//throw 'person is not folded'
|
||||||
}
|
}
|
||||||
person.label = person._label
|
|
||||||
delete person._label
|
|
||||||
delete person.title
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -268,6 +278,7 @@ const store = createStore({
|
|||||||
width: getHouseholdWidth(m),
|
width: getHouseholdWidth(m),
|
||||||
})
|
})
|
||||||
if (!getters.isPersonLoaded(m.person.id)) {
|
if (!getters.isPersonLoaded(m.person.id)) {
|
||||||
|
console.log('addMissingPerson from household', household.id)
|
||||||
dispatch('addMissingPerson', [m.person, household])
|
dispatch('addMissingPerson', [m.person, household])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -302,7 +313,7 @@ const store = createStore({
|
|||||||
//console.log('course', course.id)
|
//console.log('course', course.id)
|
||||||
commit('markCourseLoaded', course.id)
|
commit('markCourseLoaded', course.id)
|
||||||
commit('addCourse', course)
|
commit('addCourse', course)
|
||||||
dispatch('addExcludedNode', course.id) // layer uncheck when added
|
commit('addExcludedNode', course.id) // init: layer uncheck when added
|
||||||
dispatch('addLinkFromPersonsToCourse', course)
|
dispatch('addLinkFromPersonsToCourse', course)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -314,7 +325,7 @@ const store = createStore({
|
|||||||
* @param course
|
* @param course
|
||||||
*/
|
*/
|
||||||
addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
|
addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
|
||||||
let participations = getters.getParticipationsByCourse(course.id)
|
const participations = getters.getParticipationsByCourse(course.id)
|
||||||
console.log('add link for', participations.length, 'participations')
|
console.log('add link for', participations.length, 'participations')
|
||||||
participations.forEach(p => {
|
participations.forEach(p => {
|
||||||
//console.log(p.person.id)
|
//console.log(p.person.id)
|
||||||
@ -400,7 +411,7 @@ const store = createStore({
|
|||||||
commit('markPersonLoaded', person.id)
|
commit('markPersonLoaded', person.id)
|
||||||
commit('addPerson', [person, { folded: true }])
|
commit('addPerson', [person, { folded: true }])
|
||||||
if (getters.isExcludedNode(parent.id)) {
|
if (getters.isExcludedNode(parent.id)) {
|
||||||
commit('addExcludedNode', person.id) //1
|
commit('addExcludedNode', person.id) // init: exclude missing persons if parent is excluded
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -416,15 +427,11 @@ const store = createStore({
|
|||||||
*/
|
*/
|
||||||
unfoldPersonsByCourse({ getters, commit, dispatch }, course) {
|
unfoldPersonsByCourse({ getters, commit, dispatch }, course) {
|
||||||
const participations = getters.getParticipationsByCourse(course.id)
|
const participations = getters.getParticipationsByCourse(course.id)
|
||||||
const folded = getters.getFoldedPersons(participations)
|
getters.getFoldedPersons(participations)
|
||||||
console.log('folded', folded)
|
.forEach(person => {
|
||||||
participations.forEach(p => {
|
console.log('-=. unfold and expand person', person.id)
|
||||||
console.log('participation person', p.person.id)
|
commit('unfoldPerson', person)
|
||||||
if (p.person.label === null) {
|
dispatch('fetchInfoForPerson', person)
|
||||||
console.log(' -> unfold folded')
|
|
||||||
commit('unfoldPerson', p.person)
|
|
||||||
dispatch('fetchInfoForPerson', p.person)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -436,16 +443,11 @@ const store = createStore({
|
|||||||
*/
|
*/
|
||||||
unfoldPersonsByHousehold({ getters, commit, dispatch }, household) {
|
unfoldPersonsByHousehold({ getters, commit, dispatch }, household) {
|
||||||
const members = getters.getMembersByHousehold(household.id)
|
const members = getters.getMembersByHousehold(household.id)
|
||||||
const folded = getters.getFoldedPersons(members)
|
getters.getFoldedPersons(members)
|
||||||
console.log('folded', folded)
|
.forEach(person => {
|
||||||
|
console.log('-=. unfold and expand person', person.id)
|
||||||
members.forEach(m => {
|
commit('unfoldPerson', person)
|
||||||
console.log('member person', m.person.id)
|
dispatch('fetchInfoForPerson', person)
|
||||||
if (m.person.label === null) {
|
|
||||||
console.log(' -> unfold folded')
|
|
||||||
commit('unfoldPerson', m.person)
|
|
||||||
dispatch('fetchInfoForPerson', m.person)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -455,23 +457,21 @@ const store = createStore({
|
|||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
addExcludedNode({ getters, commit }, id) {
|
addExcludedNode({ getters, commit }, id) {
|
||||||
console.log('==> addExcludedNode')
|
console.log('==> ExcludedNode')
|
||||||
commit('addExcludedNode', id)
|
commit('addExcludedNode', id)
|
||||||
switch (splitId(id, 'type')) {
|
switch (splitId(id, 'type')) {
|
||||||
case 'accompanying_period':
|
case 'accompanying_period':
|
||||||
let participations = getters.getParticipationsByCourse(id)
|
const participations = getters.getParticipationsByCourse(id)
|
||||||
participations.forEach(p => {
|
getters.getFoldedPersons(participations)
|
||||||
if (p.person.label === null) {
|
.forEach(person => {
|
||||||
commit('addExcludedNode', p.person.id)
|
commit('addExcludedNode', person.id)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'household':
|
case 'household':
|
||||||
let members = getters.getMembersByHousehold(id)
|
let members = getters.getMembersByHousehold(id)
|
||||||
members.forEach(m => {
|
getters.getFoldedPersons(members)
|
||||||
if (m.person.label === null) {
|
.forEach(person => {
|
||||||
commit('addExcludedNode', m.person.id)
|
commit('addExcludedNode', person.id)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
@ -485,23 +485,21 @@ const store = createStore({
|
|||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
removeExcludedNode({ getters, commit }, id) {
|
removeExcludedNode({ getters, commit }, id) {
|
||||||
console.log('<== removeExcludedNode')
|
console.log('<== ExcludedNode')
|
||||||
commit('removeExcludedNode', id)
|
commit('removeExcludedNode', id)
|
||||||
switch (splitId(id, 'type')) {
|
switch (splitId(id, 'type')) {
|
||||||
case 'accompanying_period':
|
case 'accompanying_period':
|
||||||
let participations = getters.getParticipationsByCourse(id)
|
const participations = getters.getParticipationsByCourse(id)
|
||||||
participations.forEach(p => {
|
getters.getFoldedPersons(participations)
|
||||||
if (p.person.label === null) {
|
.forEach(person => {
|
||||||
commit('removeExcludedNode', p.person.id)
|
commit('removeExcludedNode', person.id)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'household':
|
case 'household':
|
||||||
let members = getters.getMembersByHousehold(id)
|
let members = getters.getMembersByHousehold(id)
|
||||||
members.forEach(m => {
|
getters.getFoldedPersons(members)
|
||||||
if (m.person.label === null) {
|
.forEach(person => {
|
||||||
commit('removeExcludedNode', m.person.id)
|
commit('removeExcludedNode', person.id)
|
||||||
}
|
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user