fix mapping problem

This commit is contained in:
Devin Howard 2015-10-23 21:03:49 +08:00 committed by Connor Turland
parent ae16f8f08d
commit 840484178b

View file

@ -157,7 +157,7 @@ Metamaps.Backbone.init = function () {
this.on('saved', this.savedEvent); this.on('saved', this.savedEvent);
this.on('nowPrivate', function(){ this.on('nowPrivate', function(){
var removeTopicData = { var removeTopicData = {
topicid: this.id mappableid: this.id
}; };
$(document).trigger(Metamaps.JIT.events.removeTopic, [removeTopicData]); $(document).trigger(Metamaps.JIT.events.removeTopic, [removeTopicData]);
@ -165,7 +165,7 @@ Metamaps.Backbone.init = function () {
this.on('noLongerPrivate', function(){ this.on('noLongerPrivate', function(){
var newTopicData = { var newTopicData = {
mappingid: this.getMapping().id, mappingid: this.getMapping().id,
topicid: this.id mappableid: this.id
}; };
$(document).trigger(Metamaps.JIT.events.newTopic, [newTopicData]); $(document).trigger(Metamaps.JIT.events.newTopic, [newTopicData]);
@ -321,14 +321,14 @@ Metamaps.Backbone.init = function () {
this.on('noLongerPrivate', function(){ this.on('noLongerPrivate', function(){
var newSynapseData = { var newSynapseData = {
mappingid: this.getMapping().id, mappingid: this.getMapping().id,
synapseid: this.id mappableid: this.id
}; };
$(document).trigger(Metamaps.JIT.events.newSynapse, [newSynapseData]); $(document).trigger(Metamaps.JIT.events.newSynapse, [newSynapseData]);
}); });
this.on('nowPrivate', function(){ this.on('nowPrivate', function(){
$(document).trigger(Metamaps.JIT.events.removeSynapse, [{ $(document).trigger(Metamaps.JIT.events.removeSynapse, [{
synapseid: this.id mappableid: this.id
}]); }]);
}); });
@ -2559,7 +2559,7 @@ Metamaps.Realtime = {
Metamaps.Mapper.get(data.mapperid, mapperCallback); Metamaps.Mapper.get(data.mapperid, mapperCallback);
} }
$.ajax({ $.ajax({
url: "/topics/" + data.topicid + ".json", url: "/topics/" + data.mappableid + ".json",
success: function (response) { success: function (response) {
Metamaps.Topics.add(response); Metamaps.Topics.add(response);
topic = Metamaps.Topics.get(response.id); topic = Metamaps.Topics.get(response.id);
@ -2606,7 +2606,7 @@ Metamaps.Realtime = {
if (!self.status) return; if (!self.status) return;
var topic = Metamaps.Topics.get(data.topicid); var topic = Metamaps.Topics.get(data.mappableid);
if (topic) { if (topic) {
var node = topic.get('node'); var node = topic.get('node');
var mapping = topic.getMapping(); var mapping = topic.getMapping();
@ -2657,7 +2657,7 @@ Metamaps.Realtime = {
Metamaps.Mapper.get(data.mapperid, mapperCallback); Metamaps.Mapper.get(data.mapperid, mapperCallback);
} }
$.ajax({ $.ajax({
url: "/synapses/" + data.synapseid + ".json", url: "/synapses/" + data.mappableid + ".json",
success: function (response) { success: function (response) {
Metamaps.Synapses.add(response); Metamaps.Synapses.add(response);
synapse = Metamaps.Synapses.get(response.id); synapse = Metamaps.Synapses.get(response.id);
@ -2704,7 +2704,7 @@ Metamaps.Realtime = {
if (!self.status) return; if (!self.status) return;
var synapse = Metamaps.Synapses.get(data.synapseid); var synapse = Metamaps.Synapses.get(data.mappableid);
if (synapse) { if (synapse) {
var edge = synapse.get('edge'); var edge = synapse.get('edge');
var mapping = synapse.getMapping(); var mapping = synapse.getMapping();
@ -2814,12 +2814,12 @@ Metamaps.Control = {
var permToDelete = Metamaps.Active.Mapper.id === topic.get('user_id') || Metamaps.Active.Mapper.get('admin'); var permToDelete = Metamaps.Active.Mapper.id === topic.get('user_id') || Metamaps.Active.Mapper.get('admin');
if (permToDelete) { if (permToDelete) {
var topicid = topic.id; var mappableid = topic.id;
var mapping = node.getData('mapping'); var mapping = node.getData('mapping');
topic.destroy(); topic.destroy();
Metamaps.Mappings.remove(mapping); Metamaps.Mappings.remove(mapping);
$(document).trigger(Metamaps.JIT.events.deleteTopic, [{ $(document).trigger(Metamaps.JIT.events.deleteTopic, [{
topicid: topicid mappableid: mappableid
}]); }]);
Metamaps.Control.hideNode(nodeid); Metamaps.Control.hideNode(nodeid);
} else { } else {
@ -2858,12 +2858,12 @@ Metamaps.Control = {
} }
var topic = node.getData('topic'); var topic = node.getData('topic');
var topicid = topic.id; var mappableid = topic.id;
var mapping = node.getData('mapping'); var mapping = node.getData('mapping');
mapping.destroy(); mapping.destroy();
Metamaps.Topics.remove(topic); Metamaps.Topics.remove(topic);
$(document).trigger(Metamaps.JIT.events.removeTopic, [{ $(document).trigger(Metamaps.JIT.events.removeTopic, [{
topicid: topicid mappableid: mappableid
}]); }]);
Metamaps.Control.hideNode(nodeid); Metamaps.Control.hideNode(nodeid);
}, },
@ -2987,7 +2987,7 @@ Metamaps.Control = {
Metamaps.Control.hideEdge(edge); Metamaps.Control.hideEdge(edge);
} }
var synapseid = synapse.id; var mappableid = synapse.id;
synapse.destroy(); synapse.destroy();
// the server will destroy the mapping, we just need to remove it here // the server will destroy the mapping, we just need to remove it here
@ -2998,7 +2998,7 @@ Metamaps.Control = {
delete edge.data.$displayIndex; delete edge.data.$displayIndex;
} }
$(document).trigger(Metamaps.JIT.events.deleteSynapse, [{ $(document).trigger(Metamaps.JIT.events.deleteSynapse, [{
synapseid: synapseid mappableid: mappableid
}]); }]);
} else { } else {
Metamaps.GlobalUI.notifyUser('Only synapses you created can be deleted'); Metamaps.GlobalUI.notifyUser('Only synapses you created can be deleted');
@ -3043,7 +3043,7 @@ Metamaps.Control = {
var synapse = edge.getData("synapses")[index]; var synapse = edge.getData("synapses")[index];
var mapping = edge.getData("mappings")[index]; var mapping = edge.getData("mappings")[index];
var synapseid = synapse.id; var mappableid = synapse.id;
mapping.destroy(); mapping.destroy();
Metamaps.Synapses.remove(synapse); Metamaps.Synapses.remove(synapse);
@ -3054,7 +3054,7 @@ Metamaps.Control = {
delete edge.data.$displayIndex; delete edge.data.$displayIndex;
} }
$(document).trigger(Metamaps.JIT.events.removeSynapse, [{ $(document).trigger(Metamaps.JIT.events.removeSynapse, [{
synapseid: synapseid mappableid: mappableid
}]); }]);
}, },
hideSelectedEdges: function () { hideSelectedEdges: function () {
@ -4054,14 +4054,14 @@ Metamaps.Topic = {
var mappingSuccessCallback = function (mappingModel, response) { var mappingSuccessCallback = function (mappingModel, response) {
var newTopicData = { var newTopicData = {
mappingid: mappingModel.id, mappingid: mappingModel.id,
topicid: mappingModel.get('topic_id') mappableid: mappingModel.get('mappable_id')
}; };
$(document).trigger(Metamaps.JIT.events.newTopic, [newTopicData]); $(document).trigger(Metamaps.JIT.events.newTopic, [newTopicData]);
}; };
var topicSuccessCallback = function (topicModel, response) { var topicSuccessCallback = function (topicModel, response) {
if (Metamaps.Active.Map) { if (Metamaps.Active.Map) {
mapping.save({ topic_id: topicModel.id }, { mapping.save({ mappable_id: topicModel.id }, {
success: mappingSuccessCallback, success: mappingSuccessCallback,
error: function (model, response) { error: function (model, response) {
console.log('error saving mapping to database'); console.log('error saving mapping to database');
@ -4225,14 +4225,14 @@ Metamaps.Synapse = {
var mappingSuccessCallback = function (mappingModel, response) { var mappingSuccessCallback = function (mappingModel, response) {
var newSynapseData = { var newSynapseData = {
mappingid: mappingModel.id, mappingid: mappingModel.id,
synapseid: mappingModel.get('synapse_id') mappableid: mappingModel.get('mappable_id')
}; };
$(document).trigger(Metamaps.JIT.events.newSynapse, [newSynapseData]); $(document).trigger(Metamaps.JIT.events.newSynapse, [newSynapseData]);
}; };
var synapseSuccessCallback = function (synapseModel, response) { var synapseSuccessCallback = function (synapseModel, response) {
if (Metamaps.Active.Map) { if (Metamaps.Active.Map) {
mapping.save({ synapse_id: synapseModel.id }, { mapping.save({ mappable_id: synapseModel.id }, {
success: mappingSuccessCallback success: mappingSuccessCallback
}); });
} }