This commit is contained in:
Mathieu Jaumotte 2021-10-29 15:32:12 +02:00
parent 80594ed186
commit a9d3d2027b

View File

@ -1,7 +1,6 @@
import { createStore } from 'vuex'
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle } from './vis-network'
import { visMessages } from './i18n'
const debug = process.env.NODE_ENV !== 'production'
@ -113,7 +112,8 @@ const store = createStore({
actions: {
/**
* 1) Add a person in state
* @param Person person
* @param object
* @param person
*/
addPerson({ commit, dispatch }, person) {
commit('markPersonLoaded', person.id)
@ -123,7 +123,8 @@ const store = createStore({
/**
* 2) Fetch infos for this person (hub)
* @param Person person
* @param object
* @param person
*/
fetchInfoForPerson({ dispatch }, person) {
if (null !== person.current_household_id) {
@ -136,7 +137,8 @@ const store = createStore({
/**
* 3) Fetch person current household (if it is not already loading)
* check first isHouseholdLoading to fetch household once
* @param Person person
* @param object
* @param person
*/
fetchHouseholdForPerson({ commit, getters, dispatch }, person) {
console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id))
@ -157,7 +159,8 @@ const store = createStore({
/**
* 4) Add an edge for each household member (household -> person)
* @param Household household
* @param object
* @param household
*/
addLinkFromPersonsToHousehold({ commit, getters, dispatch }, household) {
const currentMembers = household.members.filter(v => household.current_members_id.includes(v.id))
@ -182,7 +185,8 @@ const store = createStore({
/**
* 5) Fetch AccompanyingCourses for the person
* @param Person person
* @param object
* @param person
*/
fetchCoursesByPerson({ commit, dispatch }, person) {
//console.log('fetchCoursesByPerson', person)
@ -196,7 +200,8 @@ const store = createStore({
/**
* 6) Add each distinct course
* @param array courses
* @param object
* @param courses
*/
addCourses({ commit, getters, dispatch }, courses) {
//console.log('addCourse', courses)
@ -214,7 +219,8 @@ const store = createStore({
/**
* 7) Add an edge for each course participation (course <- person)
* @param AccompanyingCourse course
* @param object
* @param course
*/
addLinkFromPersonsToCourse({ commit, getters, dispatch }, course) {
let currentParticipations = course.participations.filter(p => p.endDate === null)
@ -227,7 +233,6 @@ const store = createStore({
arrows: 'from',
color: 'orange',
font: { color: 'darkorange' },
//label: visMessages.fr.visgraph.concerned,
})
if (!getters.isPersonLoaded(p.person.id)) {
console.log(' person is not loaded', p.person.id)
@ -238,7 +243,8 @@ const store = createStore({
/**
* 8) Fetch Relationship
* @param Person person
* @param object
* @param person
*/
fetchRelationshipByPerson({ dispatch }, person) {
//console.log('fetchRelationshipByPerson', person)
@ -253,7 +259,8 @@ const store = createStore({
/**
* 9) Add each distinct relationship
* @param array relationships
* @param object
* @param relationships
*/
addRelationships({ commit, getters, dispatch }, relationships) {
relationships.forEach(relationship => {
@ -269,7 +276,8 @@ const store = createStore({
/**
* 10) Add an edge for each relationship (person -> person)
* @param Relationship r
* @param object
* @param r (relationship)
*/
addLinkFromRelationship({ commit, getters, dispatch }, r) {
//console.log('-> addLink from person', r.fromPerson.id, 'to person', r.toPerson.id)
@ -294,7 +302,8 @@ const store = createStore({
/**
* Fetch missing person
* @param Person person
* @param object
* @param person
*/
addMissingPerson({ commit, getters, dispatch }, person) {
//console.log('addMissingPerson', person)