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
|
2016-07-26 00:14:23 +00:00
|
|
|
|
2014-02-05 01:28:06 +00:00
|
|
|
temp.push synapse
|
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
temp
|
2014-02-05 01:28:06 +00:00
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
|
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
|
2016-07-26 00:14:23 +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)
|
2016-07-26 00:14:23 +00:00
|
|
|
synapse['rtype'] = 'synapse'
|
|
|
|
|
2014-02-05 01:28:06 +00:00
|
|
|
temp.push synapse
|
|
|
|
end
|
2016-07-26 00:14:23 +00:00
|
|
|
temp
|
2014-02-05 01:28:06 +00:00
|
|
|
end
|
2012-10-10 00:23:45 +00:00
|
|
|
end
|