mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
visgraph: refactor store excludedNode action
This commit is contained in:
parent
9a00e13532
commit
0f8ca77105
@ -289,12 +289,12 @@ export default {
|
|||||||
addLayer(id) {
|
addLayer(id) {
|
||||||
//console.log('+ addLayer', id)
|
//console.log('+ addLayer', id)
|
||||||
this.checkedLayers.push(id)
|
this.checkedLayers.push(id)
|
||||||
this.$store.dispatch('removeExcludedNode', id)
|
this.$store.dispatch('excludedNode', ['remove', id])
|
||||||
},
|
},
|
||||||
removeLayer(id) {
|
removeLayer(id) {
|
||||||
//console.log('- removeLayer', id)
|
//console.log('- removeLayer', id)
|
||||||
this.checkedLayers = this.checkedLayers.filter(i => i !== id)
|
this.checkedLayers = this.checkedLayers.filter(i => i !== id)
|
||||||
this.$store.dispatch('addExcludedNode', id)
|
this.$store.dispatch('excludedNode', ['add', id])
|
||||||
},
|
},
|
||||||
|
|
||||||
addRelationshipModal(edgeData) {
|
addRelationshipModal(edgeData) {
|
||||||
|
@ -415,9 +415,7 @@ const store = createStore({
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*/
|
*
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggered by a vis-network event when clicking on a Course Node.
|
* Triggered by a vis-network event when clicking on a Course Node.
|
||||||
* Each folded node is unfold, then expanded with fetch infos
|
* Each folded node is unfold, then expanded with fetch infos
|
||||||
* @param object
|
* @param object
|
||||||
@ -450,58 +448,39 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For an excluded node, detect folded person and exclude too
|
* =============================================================================
|
||||||
|
*
|
||||||
|
* For an excluded node, add|remove relative persons excluded too
|
||||||
* @param object
|
* @param object
|
||||||
* @param id
|
* @param array (add|remove action, id)
|
||||||
*/
|
*/
|
||||||
addExcludedNode({ getters, commit }, id) {
|
excludedNode({ getters, commit }, [action, id]) {
|
||||||
console.log('==> ExcludedNode')
|
|
||||||
commit('addExcludedNode', id)
|
|
||||||
switch (splitId(id, 'type')) {
|
|
||||||
case 'accompanying_period':
|
|
||||||
const participations = getters.getParticipationsByCourse(id)
|
|
||||||
getters.getFoldedPersons(participations)
|
|
||||||
.forEach(person => {
|
|
||||||
commit('addExcludedNode', person.id)
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case 'household':
|
|
||||||
let members = getters.getMembersByHousehold(id)
|
|
||||||
getters.getFoldedPersons(members)
|
|
||||||
.forEach(person => {
|
|
||||||
commit('addExcludedNode', person.id)
|
|
||||||
})
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
throw 'case undefined'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
const personGroup = () => {
|
||||||
* For an excluded node, remove relative persons excluded too
|
|
||||||
* @param object
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
removeExcludedNode({ getters, commit }, id) {
|
|
||||||
console.log('<== ExcludedNode')
|
|
||||||
commit('removeExcludedNode', id)
|
|
||||||
switch (splitId(id, 'type')) {
|
switch (splitId(id, 'type')) {
|
||||||
case 'accompanying_period':
|
case 'accompanying_period':
|
||||||
const participations = getters.getParticipationsByCourse(id)
|
return getters.getParticipationsByCourse(id)
|
||||||
getters.getFoldedPersons(participations)
|
|
||||||
.forEach(person => {
|
|
||||||
commit('removeExcludedNode', person.id)
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case 'household':
|
case 'household':
|
||||||
let members = getters.getMembersByHousehold(id)
|
return getters.getMembersByHousehold(id)
|
||||||
getters.getFoldedPersons(members)
|
default:
|
||||||
|
throw 'undefined case with this id'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (action === 'add') {
|
||||||
|
commit('addExcludedNode', id)
|
||||||
|
getters.getFoldedPersons(personGroup())
|
||||||
|
.forEach(person => {
|
||||||
|
if (!getters.isInWhitelist(person.id)) {
|
||||||
|
commit('addExcludedNode', person.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (action === 'remove') {
|
||||||
|
commit('removeExcludedNode', id)
|
||||||
|
getters.getFoldedPersons(personGroup())
|
||||||
.forEach(person => {
|
.forEach(person => {
|
||||||
commit('removeExcludedNode', person.id)
|
commit('removeExcludedNode', person.id)
|
||||||
})
|
})
|
||||||
break
|
|
||||||
default:
|
|
||||||
throw 'case undefined'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user