diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 95359d27..a747edf3 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -99,10 +99,11 @@ class TopicsController < ApplicationController @position['y'] = params[:topic][:y] # set this for the case where the topic is being created on a map. - @mapping = Mapping.new() + @mapping = nil if params[:topic][:map] @map = Map.find(params[:topic][:map]) + @mapping = Mapping.new() @mapping.category = "Topic" @mapping.user = @user @mapping.map = @map diff --git a/app/views/synapses/create.js.erb b/app/views/synapses/create.js.erb index 49490622..3a2f1260 100644 --- a/app/views/synapses/create.js.erb +++ b/app/views/synapses/create.js.erb @@ -2,9 +2,9 @@ * @file * Javascript called when you create a new synapse. */ -$('#synapse_desc').autocomplete('disable'); $('#new_synapse').fadeOut('fast'); $('#synapse_desc').attr('value',''); +$('#synapse_desc').autocomplete('disable'); $('#synapse_topic1id').attr('value','0'); $('#synapse_topic2id').attr('value','0'); diff --git a/app/views/topics/create.js.erb b/app/views/topics/create.js.erb index 3f0714e2..556cb592 100644 --- a/app/views/topics/create.js.erb +++ b/app/views/topics/create.js.erb @@ -37,7 +37,11 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { else if (gType == "arranged" || gType == "chaotic") { temp.setData('xloc',0); temp.setData('yloc',0); - temp.setData('mappingid', '<%= @mapping.id %>'); + <% if not @mapping.nil? %> + temp.setData('mappingid', <%= @mapping.id %>); + <% elsif @mapping.nil? %> + temp.setData('mappingid', null); + <% end %> temp.setPos(new $jit.Complex(x, y), 'current'); temp.setPos(new $jit.Complex(x, y), 'start'); temp.setPos(new $jit.Complex(x, y), 'end'); @@ -81,8 +85,12 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { temp.setData('dim', 25, 'end'); temp.setData('onCanvas', false); temp.setData('inCommons', false); - if ((gType == "arranged" || gType == "chaotic") && mapid != null) { - temp.setData('mappingid', <%= @mapping.id %>); + if (gType == "arranged" || gType == "chaotic") { + <% if not @mapping.nil? %> + temp.setData('mappingid', <%= @mapping.id %>); + <% elsif @mapping.nil? %> + temp.setData('mappingid', null); + <% end %> } temp.setPos(new $jit.Complex(x, y), 'current'); temp.setPos(new $jit.Complex(x, y), 'start'); @@ -95,4 +103,4 @@ if (!$.isEmptyObject(Mconsole.graph.nodes)) { selectNodeOnClickHandler(temp); } }); -} +} \ No newline at end of file