metamaps--metamaps/app/helpers/synapses_helper.rb
Devin Howard 7d4da81272 Update code style automatically using rubocop gem (#563)
* install rubocop

* 1961 automatic rubocop fixes

* update rubocop.yml to ignore half of the remaining cops

* rubocop lint warnings

* random other warnings fixed
2016-07-26 08:14:23 +08:00

33 lines
924 B
Ruby

module SynapsesHelper
## 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
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
synapse['label'] = s.desc.nil? || s.desc == '' ? '(no description)' : s.desc
synapse['value'] = s.desc
synapse['permission'] = s.permission
synapse['mapCount'] = s.maps.count
synapse['originator'] = s.user.name
synapse['originatorImage'] = s.user.image.url(:thirtytwo)
synapse['rtype'] = 'synapse'
temp.push synapse
end
temp
end
end