mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
visgraph: only addEdge for person to person
This commit is contained in:
parent
41f815bbb9
commit
5d995115ba
@ -20,7 +20,7 @@ const visMessages = {
|
||||
editNode: 'Éditer un noeuds',
|
||||
editEdge: 'Éditer un lien',
|
||||
addDescription: 'Cliquez dans un espace vide pour créer un nouveau nœud.',
|
||||
edgeDescription: 'Cliquez sur un nœud et faites glisser le lien vers un autre nœud pour les connecter.',
|
||||
edgeDescription: 'Cliquez sur un usager et faites glisser le lien vers un autre usager pour les connecter.',
|
||||
editEdgeDescription: 'Cliquez sur les points de contrôle et faites-les glisser vers un nœud pour les relier.',
|
||||
createEdgeError: 'Il est impossible de relier des arêtes à un cluster.',
|
||||
deleteClusterError: 'Les clusters ne peuvent pas être supprimés.',
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createStore } from 'vuex'
|
||||
import { getHouseholdByPerson, getCoursesByPerson, getRelationshipsByPerson } from './api'
|
||||
import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle } from './vis-network'
|
||||
import { adapt2vis, getHouseholdLabel, getHouseholdWidth, getRelationshipLabel, getRelationshipTitle, splitId } from './vis-network'
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production'
|
||||
|
||||
@ -235,7 +235,7 @@ const store = createStore({
|
||||
commit('addLink', {
|
||||
from: `${p.person.type}_${p.person.id}`,
|
||||
to: `${course.id}`,
|
||||
id: `p${p.person.id}-c`+ course.id.split('_')[2],
|
||||
id: `p${p.person.id}-c`+ splitId(course.id,'id'),
|
||||
arrows: 'from',
|
||||
color: 'orange',
|
||||
font: { color: 'darkorange' },
|
||||
|
@ -100,9 +100,14 @@ window.options = {
|
||||
callback(nodeData)
|
||||
},
|
||||
addEdge: function(edgeData, callback) {
|
||||
console.log('addEdge', edgeData)
|
||||
callback(edgeData)
|
||||
eventHub.emit('add-relationship-link', edgeData)
|
||||
if (
|
||||
splitId(edgeData.from,'type') === 'person'
|
||||
&& splitId(edgeData.to,'type') === 'person'
|
||||
) {
|
||||
console.log('addEdge', edgeData)
|
||||
eventHub.emit('add-relationship-link', edgeData)
|
||||
callback(edgeData)
|
||||
}
|
||||
},
|
||||
editEdge: function(edgeData, callback) {
|
||||
console.log('editNode', edgeData)
|
||||
@ -309,10 +314,28 @@ const getRelationshipTitle = (relationship) => {
|
||||
+ relationship.toPerson.text
|
||||
}
|
||||
|
||||
/**
|
||||
* Split string id and return type|id substring
|
||||
* @param id
|
||||
* @param position
|
||||
* @returns string
|
||||
*/
|
||||
const splitId = (id, position) => {
|
||||
switch (position) {
|
||||
case 'type':
|
||||
return /(.+)_/.exec(id)[1] // return 'accompanying_period'
|
||||
case 'id':
|
||||
return id.split("_").pop() // return '124'
|
||||
default:
|
||||
throw 'position undefined'
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
adapt2vis,
|
||||
getHouseholdLabel,
|
||||
getHouseholdWidth,
|
||||
getRelationshipLabel,
|
||||
getRelationshipTitle
|
||||
getRelationshipTitle,
|
||||
splitId
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user