From 85b3012cd940ec82c01a6dce64f8217472a8991b Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Fri, 2 Oct 2015 17:39:53 +0800 Subject: [PATCH] fix a few more mappable/topic/synapse things in JS --- app/assets/javascripts/src/Metamaps.js | 6 ++++-- app/controllers/main_controller.rb | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js index 78b6c868..5f71007d 100644 --- a/app/assets/javascripts/src/Metamaps.js +++ b/app/assets/javascripts/src/Metamaps.js @@ -194,7 +194,8 @@ Metamaps.Backbone.init = function () { return Metamaps.Mappings.findWhere({ map_id: Metamaps.Active.Map.id, - topic_id: this.isNew() ? this.cid : this.id + mappable_type: "Topic", + mappable_id: this.isNew() ? this.cid : this.id }); }, createNode: function () { @@ -370,7 +371,8 @@ Metamaps.Backbone.init = function () { return Metamaps.Mappings.findWhere({ map_id: Metamaps.Active.Map.id, - synapse_id: this.isNew() ? this.cid : this.id + mappable_type: "Synapse", + mappable_id: this.isNew() ? this.cid : this.id }); }, createEdge: function () { diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 88f035e9..c5535276 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -187,14 +187,14 @@ class MainController < ApplicationController term = params[:term] topic1id = params[:topic1id] topic2id = params[:topic2id] - + if term && !term.empty? - @synapses = Synapse.select('DISTINCT "desc"').where('LOWER("desc") like ?', '%' + term.downcase + '%').order('"desc"') + @synapses = Synapse.where('LOWER("desc") like ?', '%' + term.downcase + '%').order('"desc"') # remove any duplicate synapse types that just differ by # leading or trailing whitespaces collectedDesc = [] - @synapses.to_a.delete_if {|s| + @synapses.to_a.uniq(&:desc).delete_if {|s| desc = s.desc == nil || s.desc == "" ? "" : s.desc.strip if collectedDesc.index(desc) == nil collectedDesc.push(desc)