Module: AutoCompletionHelper

Defined in:
app/helpers/auto_completion_helper.rb

Instance Method Summary collapse

Instance Method Details

#multiple_users_best_in_place(object, attribute, options = {}) ⇒ Object

options:

- activator: places a pen next to the field that activates it (for boxes without edit button)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/auto_completion_helper.rb', line 6

def multiple_users_best_in_place(object, attribute, options = {})
  # autocomplete_field_tag :user_title, '', autocomplete_title_users_path %>
  
  activator_id = options[:activator] ? "#{object.cache_key} #{attribute} multi user selector activator".parameterize : ''
  
  html = best_in_place( object, attribute, 
                 html_attrs: { 
                   'data-autocomplete-url' => autocomplete_title_users_path,
                   :class => 'multiple-users-select-input'
                 },
                 activator: (activator_id.present? ? ('#' + activator_id) : '')
                 )
  if options[:activator]
    html += link_to(icon(:edit), '#', id: activator_id, class: 'multi_user_select_activator', title: I18n.t(:edit)).html_safe
  end
  return html.html_safe
end

#user_best_in_place(object, attribute) ⇒ Object



24
25
26
27
28
29
30
31
# File 'app/helpers/auto_completion_helper.rb', line 24

def user_best_in_place( object, attribute )
  best_in_place( object, attribute,
                 html_attrs: {
                   'data-autocomplete-url' => autocomplete_title_users_path,
                   :class => "user-select-input #{attribute}"
                 },
                 classes: "relationships #{attribute}" )
end