From e7f555077ebc4ad0bb1f02f91fdb66bd25c735c5 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 25 Oct 2021 16:42:38 +0200 Subject: [PATCH] vis need each edge has an id, and vuex don't like vis create it by itself ! --- .../Resources/public/vuejs/VisGraph/store.js | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js index 81085ff32..b002108d5 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js @@ -52,7 +52,7 @@ const store = createStore({ state.courses.push(course) }, addRelationship(state, relationship) { - console.log('+ addRelationship', relationship.id) + console.log('+ addRelationship', relationship) state.relationships.push(relationship) }, markHouseholdLoading(state, id) { @@ -62,17 +62,6 @@ const store = createStore({ unmarkHouseholdLoading(state, id) { state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== id) }, - addLinkFromPersonsToHousehold(state, household) { - const members = household.members.filter(v => household.current_members_id.includes(v.id)) - members.forEach(m => { - console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id) - state.relationships.push({ - from: `${m.person.type}_${m.person.id}`, - to: `household_${m.person.current_household_id}` - }) - }) - - }, }, actions: { addPerson({ commit, dispatch }, person) { @@ -89,7 +78,7 @@ const store = createStore({ * Fetch person current household if it is not already loading * check first isHouseholdLoading to fetch household once */ - fetchHouseholdForPerson({ commit, getters }, person) { + fetchHouseholdForPerson({ commit, getters, dispatch }, person) { console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id)) if (! getters.isHouseholdLoading(person.current_household_id)) { commit('markHouseholdLoading', person.current_household_id) @@ -97,7 +86,7 @@ const store = createStore({ .then(household => new Promise(resolve => { //console.log('getHouseholdByPerson', household) commit('addHousehold', household) - commit('addLinkFromPersonsToHousehold', household) + dispatch('addLinkFromPersonsToHousehold', household) resolve() }) ).catch( () => { @@ -106,6 +95,19 @@ const store = createStore({ } }, + addLinkFromPersonsToHousehold({ commit }, household) { + const members = household.members.filter(v => household.current_members_id.includes(v.id)) + members.forEach(m => { + //console.log('-> addLink from person', m.person.id, 'to household', m.person.current_household_id) + commit('addRelationship', { + from: `${m.person.type}_${m.person.id}`, + to: `household_${m.person.current_household_id}`, + id: `p${m.person.id}-h${m.person.current_household_id}` + }) + }) + + }, + /** * Fetch person current AccompanyingCourses */