diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js index d4ec95210..43046cdbb 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/VisGraph/store.js @@ -21,7 +21,6 @@ const store = createStore({ state.households.forEach(h => { nodes.push(h) }) - // push all others kinds of nodes.. return nodes }, edges(state) { @@ -33,17 +32,27 @@ const store = createStore({ }, mutations: { addPerson(state, person) { + console.log('addPerson', person.id) person.label = person.text // vis need label - person.id = `person_${person.id}` + person.id = `person_${person.id}` // vis need unique id state.persons.push(person) }, addHousehold(state, household) { + console.log('addHousehold', household.id) household.label = `Ménage n° ${household.id}` // vis need label - household.id = `household_${household.id}` + household.id = `household_${household.id}` // vis need unique id state.households.push(household) }, + addCourse(state, course) { + console.log('addCourse', course.id) + state.courses.push(course) + }, + addRelationship(state, relationship) { + console.log('addRelationship', relationship.id) + state.relationships.push(relationship) + }, markHouseholdLoading(state, id) { - console.log('mutation: markHouseholdLoading', id) + console.log('..loading', id) state.householdLoadingIds.push(id) }, unmarkHouseholdLoading(state, id) { @@ -52,15 +61,13 @@ const store = createStore({ }, actions: { addPerson({ commit, dispatch }, person) { - console.log('addPerson', person.id) commit('addPerson', person) dispatch('fetchInfoForPerson', person) }, fetchInfoForPerson({ dispatch }, person) { - //console.log('fetchInfoForPerson', person.id) dispatch('fetchHouseholdForPerson', person) - //getCourseByPerson(person) - //getRelationship(person) + //dispatch('fetchCourseByPerson', person) + //dispatch('fetchRelationship', person) }, /** @@ -73,7 +80,7 @@ const store = createStore({ commit('markHouseholdLoading', person.current_household_id) getHouseholdByPerson(person) .then(household => new Promise(resolve => { - console.log('getHouseholdByPerson', household) + //console.log('getHouseholdByPerson', household) commit('addHousehold', household) resolve() }) @@ -82,6 +89,35 @@ const store = createStore({ }); } }, + + /** + * Fetch person current AccompanyingCourses + */ + fetchCourseByPerson({ commit, getters }, person) { + console.log('fetchCourseByPerson', person) + getCourseByPerson(person) + .then(course => new Promise(resolve => { + console.log('getCourseByPerson', course) + commit('addCourse', course) + resolve() + })) + ; + }, + + /** + * Fetch Relationship + */ + fetchRelationship({ commit, getters }, person) { + console.log('fetchRelationship', person) + getRelationship(person) + .then(relationship => new Promise(resolve => { + console.log('getRelationship', relationship) + commit('addRelationship', relationship) + resolve() + })) + ; + }, + } });