metamaps--metamaps/app/helpers/synapses_helper.rb

34 lines
924 B
Ruby
Raw Normal View History

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
2014-02-05 01:28:06 +00:00
temp.push synapse
end
temp
2014-02-05 01:28:06 +00:00
end
2014-02-05 01:28:06 +00:00
## 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
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
synapse['originatorImage'] = s.user.image.url(:thirtytwo)
synapse['rtype'] = 'synapse'
2014-02-05 01:28:06 +00:00
temp.push synapse
end
temp
2014-02-05 01:28:06 +00:00
end
2012-10-10 00:23:45 +00:00
end