306 fix visgraph issues

This commit is contained in:
2021-12-06 14:01:50 +00:00
committed by Julien Fastré
parent 8e8a8c1e70
commit bbc5e94033
8 changed files with 114 additions and 76 deletions

View File

@@ -112,7 +112,7 @@ const store = createStore({
}
})
//console.log('array', array.map(item => item.person.id))
console.log('get persons group', group.map(f => f.id))
//console.log('get persons group', group.map(f => f.id))
return group
},
@@ -120,13 +120,17 @@ const store = createStore({
},
mutations: {
addPerson(state, [person, options]) {
let age = getAge(person)
age = (age === '')? '' : ' - ' + age
let debug = ''
/// Debug mode: uncomment to display person_id on visgraph
//debug = `\nid ${person.id}`
person.group = person.type
person._id = person.id
person.id = `person_${person.id}`
person.label = `*${person.text}*\n_${getGender(person.gender)} - ${getAge(person.birthdate)}_${debug}` //
person.label = `*${person.text}*\n_${getGender(person.gender)}${age}_${debug}`
person.folded = false
// folded is used for missing persons
if (options.folded) {
@@ -161,7 +165,7 @@ const store = createStore({
state.links.push(link)
},
updateLink(state, link) {
console.log('updateLink', link)
//console.log('updateLink', link)
let link_ = {
from: `person_${link.fromPerson.id}`,
to: `person_${link.toPerson.id}`,
@@ -264,7 +268,7 @@ const store = createStore({
fetchInfoForPerson({ dispatch }, person) {
// TODO enfants hors ménages
// example: household 61
// console.log(person.text, 'household', person.current_household_id)
//console.log(person.text, 'household', person.current_household_id)
if (null !== person.current_household_id) {
dispatch('fetchHouseholdForPerson', person)
}
@@ -305,15 +309,16 @@ const store = createStore({
*/
addLinkFromPersonsToHousehold({ commit, getters, dispatch }, household) {
let members = getters.getMembersByHousehold(household.id)
console.log('add link for', members.length, 'members')
//console.log('add link for', members.length, 'members')
members.forEach(m => {
commit('addLink', {
from: `${m.person.type}_${m.person.id}`,
to: `household_${m.person.current_household_id}`,
id: `household_${m.person.current_household_id}-person_${m.person.id}`,
to: `${household.id}`,
id: `${household.id}-person_${m.person.id}`,
arrows: 'from',
color: 'pink',
font: { color: '#D04A60' },
dashes: (getHouseholdWidth(m) === 1)? [0,4] : false, //edge style: [dash, gap, dash, gap]
label: getHouseholdLabel(m),
width: getHouseholdWidth(m),
})
@@ -362,7 +367,7 @@ const store = createStore({
*/
addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
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 => {
//console.log(p.person.id)
commit('addLink', {
@@ -445,7 +450,7 @@ const store = createStore({
* @param array
*/
addMissingPerson({ commit, getters, dispatch }, [person, parent]) {
console.log('! add missing Person', person.id)
//console.log('! add missing Person', person.id)
commit('markPersonLoaded', person.id)
commit('addPerson', [person, { folded: true }])
if (getters.isExcludedNode(parent.id)) {
@@ -467,7 +472,7 @@ const store = createStore({
getters.getPersonsGroup(participations)
.forEach(person => {
if (person.folded === true) {
console.log('-=. unfold and expand person', person.id)
//console.log('-=. unfold and expand person', person.id)
commit('unfoldPerson', person)
dispatch('fetchInfoForPerson', person)
}
@@ -485,7 +490,7 @@ const store = createStore({
getters.getPersonsGroup(members)
.forEach(person => {
if (person.folded === true) {
console.log('-=. unfold and expand person', person.id)
//console.log('-=. unfold and expand person', person.id)
commit('unfoldPerson', person)
dispatch('fetchInfoForPerson', person)
}