mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
vue_visgraph: improve household links (edges)
This commit is contained in:
parent
8ff581d5fa
commit
1d1a54f653
@ -3,6 +3,7 @@ const visMessages = {
|
|||||||
visgraph: {
|
visgraph: {
|
||||||
Course: 'Parcours',
|
Course: 'Parcours',
|
||||||
Household: 'Ménage',
|
Household: 'Ménage',
|
||||||
|
Holder: 'Titulaire',
|
||||||
Legend: 'Calques',
|
Legend: 'Calques',
|
||||||
},
|
},
|
||||||
edit: 'Éditer',
|
edit: 'Éditer',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { createStore } from 'vuex'
|
import { createStore } from 'vuex'
|
||||||
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipByPerson } from './api'
|
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipByPerson } from './api'
|
||||||
import { adapt2vis } from './vis-network'
|
import { adapt2vis, getHouseholdLabel, getHouseholdWidth } from './vis-network'
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production'
|
const debug = process.env.NODE_ENV !== 'production'
|
||||||
|
|
||||||
@ -139,8 +139,8 @@ const store = createStore({
|
|||||||
* @param Household household
|
* @param Household household
|
||||||
*/
|
*/
|
||||||
addLinkFromPersonsToHousehold({ commit }, household) {
|
addLinkFromPersonsToHousehold({ commit }, household) {
|
||||||
const members = household.members.filter(v => household.current_members_id.includes(v.id))
|
const currentMembers = household.members.filter(v => household.current_members_id.includes(v.id))
|
||||||
members.forEach(m => {
|
currentMembers.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('addLink', {
|
commit('addLink', {
|
||||||
from: `${m.person.type}_${m.person.id}`,
|
from: `${m.person.type}_${m.person.id}`,
|
||||||
@ -148,9 +148,9 @@ const store = createStore({
|
|||||||
id: `p${m.person.id}-h${m.person.current_household_id}`,
|
id: `p${m.person.id}-h${m.person.current_household_id}`,
|
||||||
arrows: 'from',
|
arrows: 'from',
|
||||||
color: 'pink',
|
color: 'pink',
|
||||||
font: { color: 'pink' },
|
font: { color: '#D04A60' },
|
||||||
label: 'enfant',
|
label: getHouseholdLabel(m),
|
||||||
////group: 'link_person_household',
|
width: getHouseholdWidth(m),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -203,9 +203,8 @@ const store = createStore({
|
|||||||
id: `p${p.person.id}-c`+ course.id.split('_')[2],
|
id: `p${p.person.id}-c`+ course.id.split('_')[2],
|
||||||
arrows: 'to',
|
arrows: 'to',
|
||||||
color: 'orange',
|
color: 'orange',
|
||||||
font: { color: 'orange' },
|
font: { color: 'darkorange' },
|
||||||
label: 'concerné',
|
label: 'concerné',
|
||||||
//group: 'link_person_course',
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
import { visMessages } from './i18n'
|
import { visMessages } from './i18n'
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Vis-network initial data/configuration script
|
* Vis-network initial data/configuration script
|
||||||
* Notes:
|
* Notes:
|
||||||
* Use window.network and window.options to avoid conflict between vue and vis
|
* Use window.network and window.options to avoid conflict between vue and vis
|
||||||
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
|
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
window.network = {};
|
||||||
|
|
||||||
window.options = {
|
window.options = {
|
||||||
locale: 'fr',
|
locale: 'fr',
|
||||||
locales: visMessages,
|
locales: visMessages,
|
||||||
@ -14,7 +16,7 @@ window.options = {
|
|||||||
configure: {
|
configure: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
filter: 'nodes,edges',
|
filter: 'nodes,edges',
|
||||||
container: undefined,
|
//container: undefined,
|
||||||
showButton: true
|
showButton: true
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
@ -46,7 +48,8 @@ window.options = {
|
|||||||
console.log('deleteNode', edgeData)
|
console.log('deleteNode', edgeData)
|
||||||
callback(edgeData);
|
callback(edgeData);
|
||||||
},
|
},
|
||||||
controlNodeStyle: { /*
|
controlNodeStyle: {
|
||||||
|
/*
|
||||||
shape:'dot',
|
shape:'dot',
|
||||||
size: 6,
|
size: 6,
|
||||||
color: {
|
color: {
|
||||||
@ -112,18 +115,16 @@ window.options = {
|
|||||||
shape: 'triangle',
|
shape: 'triangle',
|
||||||
*/
|
*/
|
||||||
color: 'orange',
|
color: 'orange',
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.network = {};
|
/**
|
||||||
|
* Adapt entity to graph (id, label)
|
||||||
/*
|
* rename id in _id and add properties needed by vis
|
||||||
* Adapt entity to graph (id, label)
|
* @param entity
|
||||||
* we rename id in _id
|
* @returns entity
|
||||||
* and add properties needed by vis
|
*/
|
||||||
*/
|
|
||||||
const adapt2vis = (entity) => {
|
const adapt2vis = (entity) => {
|
||||||
entity.group = entity.type
|
entity.group = entity.type
|
||||||
switch (entity.type) {
|
switch (entity.type) {
|
||||||
@ -146,6 +147,38 @@ const adapt2vis = (entity) => {
|
|||||||
return entity
|
return entity
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
/**
|
||||||
adapt2vis
|
* Return member position in household
|
||||||
|
* @param member
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
const getHouseholdLabel = (member) => {
|
||||||
|
let position = member.position.label.fr
|
||||||
|
let holder = member.holder ? ` (${visMessages.fr.visgraph.Holder})` : ''
|
||||||
|
return position + holder
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return edge width for member (depends of position in household)
|
||||||
|
* @param member
|
||||||
|
* @returns string
|
||||||
|
*/
|
||||||
|
const getHouseholdWidth = (member) => {
|
||||||
|
switch (member.position.ordering) {
|
||||||
|
case 1: //adult
|
||||||
|
if (member.holder) {
|
||||||
|
return 6
|
||||||
|
}
|
||||||
|
return 3
|
||||||
|
case 2: //children
|
||||||
|
case 3: //children out of household
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export {
|
||||||
|
adapt2vis,
|
||||||
|
getHouseholdLabel,
|
||||||
|
getHouseholdWidth
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user