metamaps--metamaps/app/helpers/maps_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

35 lines
1.2 KiB
Ruby

module MapsHelper
## this one is for building our custom JSON autocomplete format for typeahead
def autocomplete_map_array_json(maps)
temp = []
maps.each do |m|
map = {}
map['id'] = m.id
map['label'] = m.name
map['value'] = m.name
map['description'] = m.desc.try(:truncate, 30)
map['permission'] = m.permission
map['topicCount'] = m.topics.count
map['synapseCount'] = m.synapses.count
map['contributorCount'] = m.contributors.count
map['rtype'] = 'map'
contributorTip = ''
firstContributorImage = 'https://s3.amazonaws.com/metamaps-assets/site/user.png'
if m.contributors.count > 0
firstContributorImage = m.contributors[0].image.url(:thirtytwo)
m.contributors.each_with_index do |c, _index|
userImage = c.image.url(:thirtytwo)
name = c.name
contributorTip += '<li> <img class="tipUserImage" width="25" height="25" src=' + userImage + ' />' + '<span>' + name + '</span> </li>'
end
end
map['contributorTip'] = contributorTip
map['mapContributorImage'] = firstContributorImage
temp.push map
end
temp
end
end