add the moved event
This commit is contained in:
parent
107b42bc88
commit
dda1a065f3
2 changed files with 21 additions and 11 deletions
|
@ -50,7 +50,7 @@ class Mapping < ApplicationRecord
|
||||||
if mappable_type == 'Topic' and (xloc_changed? or yloc_changed?)
|
if mappable_type == 'Topic' and (xloc_changed? or yloc_changed?)
|
||||||
meta = {'x': xloc, 'y': yloc, 'mapping_id': id}
|
meta = {'x': xloc, 'y': yloc, 'mapping_id': id}
|
||||||
Events::TopicMovedOnMap.publish!(mappable, map, updated_by, meta)
|
Events::TopicMovedOnMap.publish!(mappable, map, updated_by, meta)
|
||||||
# we should add another action cable event here
|
ActionCable.server.broadcast 'map_' + map.id.to_s, type: 'topicMoved', id: mappable.id, mapping_id: id, x: xloc, y: yloc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import Mapper from './Mapper'
|
||||||
import Synapse from './Synapse'
|
import Synapse from './Synapse'
|
||||||
import Topic from './Topic'
|
import Topic from './Topic'
|
||||||
import { ChatView } from './Views'
|
import { ChatView } from './Views'
|
||||||
|
import Visualize from './Visualize'
|
||||||
|
|
||||||
const Cable = {
|
const Cable = {
|
||||||
init: () => {
|
init: () => {
|
||||||
|
@ -29,8 +30,6 @@ const Cable = {
|
||||||
delete self.sub
|
delete self.sub
|
||||||
},
|
},
|
||||||
synapseAdded: event => {
|
synapseAdded: event => {
|
||||||
// make sure we don't have the relevant synapse first
|
|
||||||
|
|
||||||
// we receive contentless models from the server
|
// we receive contentless models from the server
|
||||||
// containing only the information we need to determine whether the active mapper
|
// containing only the information we need to determine whether the active mapper
|
||||||
// can view this synapse and the two topics it connects,
|
// can view this synapse and the two topics it connects,
|
||||||
|
@ -40,8 +39,8 @@ const Cable = {
|
||||||
const t1 = new DataModel.Topic(event.topic1)
|
const t1 = new DataModel.Topic(event.topic1)
|
||||||
const t2 = new DataModel.Topic(event.topic2)
|
const t2 = new DataModel.Topic(event.topic2)
|
||||||
|
|
||||||
if (t1.authorizeToShow(m) && t2.authorizeToShow(m) && s.authorizeToShow(m)) {
|
if (t1.authorizeToShow(m) && t2.authorizeToShow(m) && s.authorizeToShow(m) && !DataModel.Synapses.get(event.synapse.id)) {
|
||||||
// refactor the heck outta this
|
// refactor the heck outta this, its adding wicked wait time
|
||||||
var topic1, topic2, node1, node2, synapse, mapping, cancel, mapper
|
var topic1, topic2, node1, node2, synapse, mapping, cancel, mapper
|
||||||
|
|
||||||
function waitThenRenderSynapse() {
|
function waitThenRenderSynapse() {
|
||||||
|
@ -88,6 +87,7 @@ const Cable = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
synapseUpdated: event => {
|
synapseUpdated: event => {
|
||||||
|
// handle case where permission changed
|
||||||
var synapse = DataModel.Synapses.get(event.id)
|
var synapse = DataModel.Synapses.get(event.id)
|
||||||
if (synapse) {
|
if (synapse) {
|
||||||
// edge reset necessary because fetch causes model reset
|
// edge reset necessary because fetch causes model reset
|
||||||
|
@ -101,7 +101,6 @@ const Cable = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
synapseRemoved: event => {
|
synapseRemoved: event => {
|
||||||
// remove by the mapping id instead
|
|
||||||
var synapse = DataModel.Synapses.get(event.id)
|
var synapse = DataModel.Synapses.get(event.id)
|
||||||
if (synapse) {
|
if (synapse) {
|
||||||
var edge = synapse.get('edge')
|
var edge = synapse.get('edge')
|
||||||
|
@ -121,16 +120,14 @@ const Cable = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
topicAdded: event => {
|
topicAdded: event => {
|
||||||
// make sure we don't have the relevant topic first
|
|
||||||
|
|
||||||
const m = Active.Mapper
|
const m = Active.Mapper
|
||||||
// we receive a contentless model from the server
|
// we receive a contentless model from the server
|
||||||
// containing only the information we need to determine whether the active mapper
|
// containing only the information we need to determine whether the active mapper
|
||||||
// can view this topic, then if we determine it can, we make a call for the full model
|
// can view this topic, then if we determine it can, we make a call for the full model
|
||||||
const t = new DataModel.Topic(event.topic)
|
const t = new DataModel.Topic(event.topic)
|
||||||
|
|
||||||
if (t.authorizeToShow(m)) {
|
if (t.authorizeToShow(m) && !DataModel.Topics.get(event.topic.id)) {
|
||||||
// refactor the heck outta this
|
// refactor the heck outta this, its adding wicked wait time
|
||||||
var topic, mapping, mapper, cancel
|
var topic, mapping, mapper, cancel
|
||||||
|
|
||||||
function waitThenRenderTopic() {
|
function waitThenRenderTopic() {
|
||||||
|
@ -172,6 +169,7 @@ const Cable = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
topicUpdated: event => {
|
topicUpdated: event => {
|
||||||
|
// handle case where permission changed
|
||||||
var topic = DataModel.Topics.get(event.id)
|
var topic = DataModel.Topics.get(event.id)
|
||||||
if (topic) {
|
if (topic) {
|
||||||
var node = topic.get('node')
|
var node = topic.get('node')
|
||||||
|
@ -183,8 +181,19 @@ const Cable = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
topicMoved: event => {
|
||||||
|
var topic, node, mapping
|
||||||
|
if (Active.Map) {
|
||||||
|
topic = DataModel.Topics.get(event.id)
|
||||||
|
mapping = DataModel.Mappings.get(event.mapping_id)
|
||||||
|
mapping.set('xloc', event.x)
|
||||||
|
mapping.set('yloc', event.y)
|
||||||
|
if (topic) node = topic.get('node')
|
||||||
|
if (node) node.pos.setc(event.x, event.y)
|
||||||
|
Visualize.mGraph.plot()
|
||||||
|
}
|
||||||
|
},
|
||||||
topicRemoved: event => {
|
topicRemoved: event => {
|
||||||
// remove by the mapping id instead
|
|
||||||
var topic = DataModel.Topics.get(event.id)
|
var topic = DataModel.Topics.get(event.id)
|
||||||
if (topic) {
|
if (topic) {
|
||||||
var node = topic.get('node')
|
var node = topic.get('node')
|
||||||
|
@ -195,6 +204,7 @@ const Cable = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
messageCreated: event => {
|
messageCreated: event => {
|
||||||
|
if (Active.Mapper && Active.Mapper.id === event.message.user_id) return
|
||||||
ChatView.addMessages(new DataModel.MessageCollection(event.message))
|
ChatView.addMessages(new DataModel.MessageCollection(event.message))
|
||||||
},
|
},
|
||||||
mapUpdated: event => {
|
mapUpdated: event => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue