fix a few more mappable/topic/synapse things in JS

This commit is contained in:
Devin Howard 2015-10-02 17:39:53 +08:00
parent 6d1e382d5c
commit 85b3012cd9
2 changed files with 7 additions and 5 deletions

View file

@ -194,7 +194,8 @@ Metamaps.Backbone.init = function () {
return Metamaps.Mappings.findWhere({ return Metamaps.Mappings.findWhere({
map_id: Metamaps.Active.Map.id, 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 () { createNode: function () {
@ -370,7 +371,8 @@ Metamaps.Backbone.init = function () {
return Metamaps.Mappings.findWhere({ return Metamaps.Mappings.findWhere({
map_id: Metamaps.Active.Map.id, 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 () { createEdge: function () {

View file

@ -189,12 +189,12 @@ class MainController < ApplicationController
topic2id = params[:topic2id] topic2id = params[:topic2id]
if term && !term.empty? 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 # remove any duplicate synapse types that just differ by
# leading or trailing whitespaces # leading or trailing whitespaces
collectedDesc = [] collectedDesc = []
@synapses.to_a.delete_if {|s| @synapses.to_a.uniq(&:desc).delete_if {|s|
desc = s.desc == nil || s.desc == "" ? "" : s.desc.strip desc = s.desc == nil || s.desc == "" ? "" : s.desc.strip
if collectedDesc.index(desc) == nil if collectedDesc.index(desc) == nil
collectedDesc.push(desc) collectedDesc.push(desc)