2012-10-10 00:23:45 +00:00
|
|
|
module SynapsesHelper
|
2014-02-05 01:28:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
## this one is for building our custom JSON autocomplete format for typeahead
|
|
|
|
def autocomplete_synapse_generic_json(unique)
|
|
|
|
temp = []
|
|
|
|
unique.each do |s|
|
|
|
|
synapse = {}
|
|
|
|
synapse['label'] = s.desc
|
|
|
|
synapse['value'] = s.desc
|
|
|
|
|
|
|
|
temp.push synapse
|
|
|
|
end
|
|
|
|
return temp
|
|
|
|
end
|
|
|
|
|
|
|
|
## this one is for building our custom JSON autocomplete format for typeahead
|
|
|
|
def autocomplete_synapse_array_json(synapses)
|
|
|
|
temp = []
|
|
|
|
synapses.each do |s|
|
|
|
|
synapse = {}
|
|
|
|
synapse['id'] = s.id
|
2014-11-16 20:17:32 +00:00
|
|
|
synapse['label'] = s.desc == nil || s.desc == "" ? "(no description)" : s.desc
|
2014-02-05 03:03:24 +00:00
|
|
|
synapse['value'] = s.desc
|
2014-02-05 01:28:06 +00:00
|
|
|
synapse['permission'] = s.permission
|
|
|
|
synapse['mapCount'] = s.maps.count
|
|
|
|
synapse['originator'] = s.user.name
|
2014-11-25 20:06:30 +00:00
|
|
|
synapse['originatorImage'] = s.user.image.url(:thirtytwo)
|
2014-02-05 01:28:06 +00:00
|
|
|
synapse['rtype'] = "synapse"
|
|
|
|
|
|
|
|
temp.push synapse
|
|
|
|
end
|
|
|
|
return temp
|
|
|
|
end
|
|
|
|
|
2012-10-10 00:23:45 +00:00
|
|
|
end
|