vue_visgraph: add checkbox legend to enable/disable layers

This commit is contained in:
2021-10-26 21:29:17 +02:00
parent ccf6c7ad91
commit 2a86fd12d7
3 changed files with 97 additions and 34 deletions

View File

@@ -12,7 +12,8 @@ const store = createStore({
courses: [],
relationships: [],
householdLoadingIds: [],
courseLoadedIds: []
courseLoadedIds: [],
excludedNodesIds: []
},
getters: {
nodes(state) {
@@ -26,6 +27,10 @@ const store = createStore({
state.courses.forEach(c => {
nodes.push(c)
})
// except excluded nodes (unchecked layers)
state.excludedNodesIds.forEach(excluded => {
nodes = nodes.filter(n => n.id !== excluded)
})
return nodes
},
edges(state) {
@@ -56,7 +61,7 @@ const store = createStore({
state.courses.push(adapt2vis(course))
},
addRelationship(state, relationship) {
console.log('+ addRelationship', relationship)
console.log('+ addRelationship from', relationship.from, 'to', relationship.to)
state.relationships.push(relationship)
},
markHouseholdLoading(state, id) {
@@ -72,6 +77,12 @@ const store = createStore({
unmarkCourseLoaded(state, id) {
state.courseLoadedIds = state.courseLoadedIds.filter(i => i !== id)
},
addExcludedNode(state, id) {
state.excludedNodesIds.push(id)
},
removeExcludedNode(state, id) {
state.excludedNodesIds = state.excludedNodesIds.filter(e => e !== id)
}
},
actions: {
/**
@@ -185,7 +196,7 @@ const store = createStore({
arrows: 'to',
color: 'orange',
font: { color: 'orange' },
label: 'usager',
label: 'concerné',
//group: 'link_person_course',
})
})