mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
vis need each edge has an id, and vuex don't like vis create it by itself !
This commit is contained in:
parent
b7f3700928
commit
e7f555077e
@ -52,7 +52,7 @@ const store = createStore({
|
|||||||
state.courses.push(course)
|
state.courses.push(course)
|
||||||
},
|
},
|
||||||
addRelationship(state, relationship) {
|
addRelationship(state, relationship) {
|
||||||
console.log('+ addRelationship', relationship.id)
|
console.log('+ addRelationship', relationship)
|
||||||
state.relationships.push(relationship)
|
state.relationships.push(relationship)
|
||||||
},
|
},
|
||||||
markHouseholdLoading(state, id) {
|
markHouseholdLoading(state, id) {
|
||||||
@ -62,17 +62,6 @@ const store = createStore({
|
|||||||
unmarkHouseholdLoading(state, id) {
|
unmarkHouseholdLoading(state, id) {
|
||||||
state.householdLoadingIds = state.householdLoadingIds.filter(i => i !== 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: {
|
actions: {
|
||||||
addPerson({ commit, dispatch }, person) {
|
addPerson({ commit, dispatch }, person) {
|
||||||
@ -89,7 +78,7 @@ const store = createStore({
|
|||||||
* Fetch person current household if it is not already loading
|
* Fetch person current household if it is not already loading
|
||||||
* check first isHouseholdLoading to fetch household once
|
* 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))
|
console.log(' isHouseholdLoading ?', getters.isHouseholdLoading(person.current_household_id))
|
||||||
if (! getters.isHouseholdLoading(person.current_household_id)) {
|
if (! getters.isHouseholdLoading(person.current_household_id)) {
|
||||||
commit('markHouseholdLoading', person.current_household_id)
|
commit('markHouseholdLoading', person.current_household_id)
|
||||||
@ -97,7 +86,7 @@ const store = createStore({
|
|||||||
.then(household => new Promise(resolve => {
|
.then(household => new Promise(resolve => {
|
||||||
//console.log('getHouseholdByPerson', household)
|
//console.log('getHouseholdByPerson', household)
|
||||||
commit('addHousehold', household)
|
commit('addHousehold', household)
|
||||||
commit('addLinkFromPersonsToHousehold', household)
|
dispatch('addLinkFromPersonsToHousehold', household)
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
).catch( () => {
|
).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
|
* Fetch person current AccompanyingCourses
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user