fixup synapse creation
This commit is contained in:
parent
96f66a2f8c
commit
6e347dc33a
3 changed files with 28 additions and 20 deletions
|
@ -4,6 +4,7 @@ import React from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
|
|
||||||
import DataModel from './DataModel'
|
import DataModel from './DataModel'
|
||||||
|
import Engine from './Engine'
|
||||||
import MetacodeSelect from '../components/MetacodeSelect'
|
import MetacodeSelect from '../components/MetacodeSelect'
|
||||||
import Mouse from './Mouse'
|
import Mouse from './Mouse'
|
||||||
import Selected from './Selected'
|
import Selected from './Selected'
|
||||||
|
@ -360,7 +361,9 @@ console.log(codesToSwitchToIds)
|
||||||
|
|
||||||
$('#synapse_desc').focusout(function() {
|
$('#synapse_desc').focusout(function() {
|
||||||
if (Create.newSynapse.beingCreated) {
|
if (Create.newSynapse.beingCreated) {
|
||||||
Synapse.createSynapseLocally()
|
Synapse.createSynapseLocally(Create.newSynapse.topic1id, Create.newSynapse.topic2id)
|
||||||
|
Engine.runLayout()
|
||||||
|
Create.newSynapse.hide()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -368,7 +371,9 @@ console.log(codesToSwitchToIds)
|
||||||
const TAB = 9
|
const TAB = 9
|
||||||
if (Create.newSynapse.beingCreated && e.keyCode === TAB) {
|
if (Create.newSynapse.beingCreated && e.keyCode === TAB) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
Synapse.createSynapseLocally()
|
Synapse.createSynapseLocally(Create.newSynapse.topic1id, Create.newSynapse.topic2id)
|
||||||
|
Engine.runLayout()
|
||||||
|
Create.newSynapse.hide()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -377,7 +382,9 @@ console.log(codesToSwitchToIds)
|
||||||
Synapse.getSynapseFromAutocomplete(datum.id)
|
Synapse.getSynapseFromAutocomplete(datum.id)
|
||||||
} else {
|
} else {
|
||||||
Create.newSynapse.description = datum.value
|
Create.newSynapse.description = datum.value
|
||||||
Synapse.createSynapseLocally()
|
Synapse.createSynapseLocally(Create.newSynapse.topic1id, Create.newSynapse.topic2id)
|
||||||
|
Engine.runLayout()
|
||||||
|
Create.newSynapse.hide()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -687,10 +687,6 @@ const JIT = {
|
||||||
onMouseMoveHandler: function(_node, eventInfo, e) {
|
onMouseMoveHandler: function(_node, eventInfo, e) {
|
||||||
const self = JIT
|
const self = JIT
|
||||||
|
|
||||||
if (Mouse.synapseStartCoordinates.length) {
|
|
||||||
Visualize.mGraph.plot()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Visualize.mGraph.busy) return
|
if (Visualize.mGraph.busy) return
|
||||||
|
|
||||||
const node = eventInfo.getNode()
|
const node = eventInfo.getNode()
|
||||||
|
@ -731,7 +727,9 @@ const JIT = {
|
||||||
} else if (e.target.id === 'topic_name' && !Create.newTopic.metacodeSelectorOpen) {
|
} else if (e.target.id === 'topic_name' && !Create.newTopic.metacodeSelectorOpen) {
|
||||||
Topic.createTopicLocally()
|
Topic.createTopicLocally()
|
||||||
} else if (Create.newSynapse.beingCreated) {
|
} else if (Create.newSynapse.beingCreated) {
|
||||||
Synapse.createSynapseLocally()
|
Synapse.createSynapseLocally(Create.newSynapse.topic1id, Create.newSynapse.topic2id)
|
||||||
|
Engine.runLayout()
|
||||||
|
Create.newSynapse.hide()
|
||||||
}
|
}
|
||||||
}, // enterKeyHandler
|
}, // enterKeyHandler
|
||||||
escKeyHandler: function() {
|
escKeyHandler: function() {
|
||||||
|
@ -744,7 +742,6 @@ const JIT = {
|
||||||
var authorized = Active.Map && Active.Map.authorizeToEdit(Active.Mapper)
|
var authorized = Active.Map && Active.Map.authorizeToEdit(Active.Mapper)
|
||||||
|
|
||||||
if (node && !node.nodeFrom) {
|
if (node && !node.nodeFrom) {
|
||||||
self.handleSelectionBeforeDragging(node, e)
|
|
||||||
|
|
||||||
const pos = eventInfo.getPos()
|
const pos = eventInfo.getPos()
|
||||||
if ((e.button === 0 || e.buttons === 0) && authorized) {
|
if ((e.button === 0 || e.buttons === 0) && authorized) {
|
||||||
|
@ -755,13 +752,20 @@ const JIT = {
|
||||||
Create.newSynapse.hide()
|
Create.newSynapse.hide()
|
||||||
// set the draw synapse start positions
|
// set the draw synapse start positions
|
||||||
Mouse.synapseStartCoordinates = []
|
Mouse.synapseStartCoordinates = []
|
||||||
for (let i = Selected.Nodes.length - 1; i >= 0; i -= 1) {
|
if (Selected.Nodes.length) {
|
||||||
const n = Selected.Nodes[i]
|
Selected.Nodes.forEach(n => {
|
||||||
Mouse.synapseStartCoordinates.push({
|
Mouse.synapseStartCoordinates.push({
|
||||||
x: n.pos.getc().x,
|
x: n.pos.getc().x,
|
||||||
y: n.pos.getc().y
|
y: n.pos.getc().y
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Mouse.synapseStartCoordinates = [{
|
||||||
|
x: node.pos.getc().x,
|
||||||
|
y: node.pos.getc().y
|
||||||
|
}]
|
||||||
|
}
|
||||||
Mouse.synapseEndCoordinates = {
|
Mouse.synapseEndCoordinates = {
|
||||||
x: pos.x,
|
x: pos.x,
|
||||||
y: pos.y
|
y: pos.y
|
||||||
|
@ -792,6 +796,7 @@ const JIT = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Visualize.mGraph.plot()
|
||||||
}, // onDragMoveTopicHandler
|
}, // onDragMoveTopicHandler
|
||||||
onDragCancelHandler: function(node, eventInfo, e) {
|
onDragCancelHandler: function(node, eventInfo, e) {
|
||||||
JIT.tempNode = null
|
JIT.tempNode = null
|
||||||
|
@ -818,7 +823,6 @@ const JIT = {
|
||||||
Create.newSynapse.node1 = JIT.tempNode
|
Create.newSynapse.node1 = JIT.tempNode
|
||||||
Create.newSynapse.node2 = JIT.tempNode2
|
Create.newSynapse.node2 = JIT.tempNode2
|
||||||
JIT.tempNode2.setData('dim', 25, 'current')
|
JIT.tempNode2.setData('dim', 25, 'current')
|
||||||
Visualize.mGraph.plot()
|
|
||||||
midpoint.x = JIT.tempNode.pos.getc().x + (JIT.tempNode2.pos.getc().x - JIT.tempNode.pos.getc().x) / 2
|
midpoint.x = JIT.tempNode.pos.getc().x + (JIT.tempNode2.pos.getc().x - JIT.tempNode.pos.getc().x) / 2
|
||||||
midpoint.y = JIT.tempNode.pos.getc().y + (JIT.tempNode2.pos.getc().y - JIT.tempNode.pos.getc().y) / 2
|
midpoint.y = JIT.tempNode.pos.getc().y + (JIT.tempNode2.pos.getc().y - JIT.tempNode.pos.getc().y) / 2
|
||||||
pixelPos = Util.coordsToPixels(Visualize.mGraph, midpoint)
|
pixelPos = Util.coordsToPixels(Visualize.mGraph, midpoint)
|
||||||
|
@ -829,6 +833,7 @@ const JIT = {
|
||||||
JIT.tempNode2 = null
|
JIT.tempNode2 = null
|
||||||
JIT.tempInit = false
|
JIT.tempInit = false
|
||||||
}
|
}
|
||||||
|
Visualize.mGraph.plot()
|
||||||
}, // onDragEndTopicHandler
|
}, // onDragEndTopicHandler
|
||||||
canvasClickHandler: function(canvasLoc, e) {
|
canvasClickHandler: function(canvasLoc, e) {
|
||||||
// grab the location and timestamp of the click
|
// grab the location and timestamp of the click
|
||||||
|
|
|
@ -43,7 +43,7 @@ const Synapse = {
|
||||||
mapping.save()
|
mapping.save()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createSynapseLocally: function(topic1id, topic2id, manual) {
|
createSynapseLocally: function(topic1id, topic2id) {
|
||||||
var self = Synapse
|
var self = Synapse
|
||||||
$(document).trigger(Map.events.editedByActiveMapper)
|
$(document).trigger(Map.events.editedByActiveMapper)
|
||||||
// for each node in this array we will create a synapse going to the position2 node.
|
// for each node in this array we will create a synapse going to the position2 node.
|
||||||
|
@ -71,10 +71,6 @@ const Synapse = {
|
||||||
// this function also includes the creation of the synapse in the database
|
// this function also includes the creation of the synapse in the database
|
||||||
self.renderSynapse(mapping, synapse, node1, node2)
|
self.renderSynapse(mapping, synapse, node1, node2)
|
||||||
}) // for each in synapsesToCreate
|
}) // for each in synapsesToCreate
|
||||||
if (manual) {
|
|
||||||
Engine.runLayout()
|
|
||||||
Create.newSynapse.hide()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
getSynapseFromAutocomplete: function(id) {
|
getSynapseFromAutocomplete: function(id) {
|
||||||
var self = Synapse
|
var self = Synapse
|
||||||
|
|
Loading…
Add table
Reference in a new issue