2016-09-24 03:00:46 +00:00
|
|
|
# frozen_string_literal: true
|
2017-11-06 16:15:18 +00:00
|
|
|
|
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)
|
2016-09-24 04:27:34 +00:00
|
|
|
unique.map do |s|
|
|
|
|
{ label: s.desc, value: s.desc }
|
2014-02-05 01:28:06 +00:00
|
|
|
end
|
|
|
|
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)
|
2016-09-24 04:27:34 +00:00
|
|
|
synapses.map do |s|
|
|
|
|
{
|
|
|
|
id: s.id,
|
|
|
|
label: s.desc.blank? ? '(no description)' : s.desc,
|
|
|
|
value: s.desc,
|
|
|
|
permission: s.permission,
|
|
|
|
mapCount: s.maps.count,
|
|
|
|
originator: s.user.name,
|
|
|
|
originatorImage: s.user.image.url(:thirtytwo),
|
|
|
|
rtype: 'synapse'
|
|
|
|
}
|
2014-02-05 01:28:06 +00:00
|
|
|
end
|
|
|
|
end
|
2012-10-10 00:23:45 +00:00
|
|
|
end
|