listen on relationship nodes event (wip)

This commit is contained in:
Mathieu Jaumotte 2021-11-05 20:34:59 +01:00
parent e55e8e072d
commit 2c0198ef78
2 changed files with 22 additions and 4 deletions

View File

@ -234,14 +234,13 @@ export default {
},
listenOnGraph() {
window.network.on('selectNode', (data) => {
if (data.nodes.length > 1) {
throw 'Multi selection is not allowed. Disable it in options.interaction !'
}
let node = data.nodes[0]
let nodeType = splitId(node, 'type')
switch (nodeType) {
case 'person':
let person = this.nodes.filter(n => n.id === node)[0]
console.log('@@@@@@ event on selected Node', person.id)
@ -269,6 +268,25 @@ export default {
throw 'event is undefined for this type of node'
}
})
window.network.on('selectEdge', (data) => {
if (data.nodes.length !== 0 && data.edges.length !== 1) {
return false
}
let linkType = splitId(data.edges[0], 'link') //<------ Uncaught TypeError: id is undefined
if (linkType.startsWith('relationship')) {
console.log('@@@@@ event on selected Edge', data)
console.log('linkType relationship')
this.editRelationshipModal(data) //<------ you are here, and data is wrong !
}
/* Disabled
if (linkType.startsWith('household')) {
console.log('linkType household')
} else
if (linkType.startsWith('accompanying_period')) {
console.log('linkType accompanying_period')
} else
*/
})
},
forceUpdateComponent() {
//console.log('!! forceUpdateComponent !!')

View File

@ -8,7 +8,7 @@ import { TinyEmitter } from "tiny-emitter";
* cfr. https://github.com/almende/vis/issues/2524#issuecomment-307108271
*/
//console.log('@@@ init eventHub App @@@')
console.log('@@@ init eventHub App @@@')
window.eventHub = new TinyEmitter()
window.network = {}
@ -75,7 +75,7 @@ window.options = {
},
interaction: {
hover: true,
multiselect: false,
multiselect: true,
navigationButtons: false,
},
manipulation: {