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({
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 () {

View file

@ -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)