From e0e505de1d6464dbd303e631d86e8b8ccc77aae2 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 28 Feb 2013 20:56:57 -0500 Subject: [PATCH] ok you can now create mappings only if logged in and it's wonderful and you can double click things and closing the seek... tab destroys your search results --- app/assets/javascripts/Jit/find.js | 21 ++++---- .../Jit/graphsettings-event-handlers.js | 4 ++ app/controllers/mappings_controller.rb | 48 ++++++++++--------- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/Jit/find.js b/app/assets/javascripts/Jit/find.js index 346ebf8e..476fa1c9 100644 --- a/app/assets/javascripts/Jit/find.js +++ b/app/assets/javascripts/Jit/find.js @@ -528,16 +528,13 @@ function openFind() { } function closeFind() { + clearFoundData(); + findOpen = false; - Mconsole.graph.eachNode( function (n) { - n.setData('inCommons', false); - n.setData('onCanvas', false); - }); - Mconsole.plot(); - $('#closeFind, #findWhere').css('display','none'); - $('#sideOptionFind').css('cursor','pointer'); - $('#sideOptionFind').animate({ - width: '45px', - height: '32px' - }, 100); -} + $('#closeFind, #findWhere').css('display','none'); + $('#sideOptionFind').css('cursor','pointer'); + $('#sideOptionFind').animate({ + width: '45px', + height: '32px' + }, 100); +}//closeFind diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index f12f3d73..a0c155e8 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -33,6 +33,10 @@ function nodeDoubleClickHandler(node, e) { return; } + if (userid == null) { + return; + } + node.setData('inCommons', false); deselectNode(node); if (window.mapid) { diff --git a/app/controllers/mappings_controller.rb b/app/controllers/mappings_controller.rb index e30a226d..7fdda422 100644 --- a/app/controllers/mappings_controller.rb +++ b/app/controllers/mappings_controller.rb @@ -14,33 +14,35 @@ class MappingsController < ApplicationController # POST mappings def create - @mapping = Mapping.new() + @user = current_user + if @user + @mapping = Mapping.new() - //TODO authenticate and put a user + @mapping.user = @user + @mapping.xloc = params[:xloc] if params[:xloc] + @mapping.yloc = params[:yloc] if params[:yloc] - @mapping.xloc = params[:xloc] if params[:xloc] - @mapping.yloc = params[:yloc] if params[:yloc] - - if params[:map] - if params[:map][:id] - @map = Map.find(params[:map][:id]) - @mapping.map = @map + if params[:map] + if params[:map][:id] + @map = Map.find(params[:map][:id]) + @mapping.map = @map + end end + if params[:topic] + if params[:topic][:id] + @topic = Topic.find(params[:topic][:id]) + @mapping.topic = @topic + @mapping.category = "Topic" + end + elsif params[:synapse] + if params[:synapse][:id] + @topic = Synapse.find(params[:synapse][:id]) + @mapping.synapse = @synapse + @mapping.category = "Synapse" + end + end + @mapping.save() end - if params[:topic] - if params[:topic][:id] - @topic = Topic.find(params[:topic][:id]) - @mapping.topic = @topic - @mapping.category = "Topic" - end - elsif params[:synapse] - if params[:synapse][:id] - @topic = Synapse.find(params[:synapse][:id]) - @mapping.synapse = @synapse - @mapping.category = "Synapse" - end - end - @mapping.save() end # GET /mappings/:id