Module: AeUsers::InstanceTagExtensions

Defined in:
lib/ae_users.rb

Constant Summary collapse

DEFAULT_USERPICKER_OPTIONS =
{
  "auto_complete_url_params" => {:controller => "permission", :action => "auto_complete_for_permission_grantee"}
}

Instance Method Summary collapse

Instance Method Details

#to_user_picker_tag(people, roles, options = {}) ⇒ Object



693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
# File 'lib/ae_users.rb', line 693

def to_user_picker_tag(people, roles, options={})
  options = options.stringify_keys
  options = DEFAULT_USERPICKER_OPTIONS.merge(options)
  add_default_name_and_id(options)
  
  default = options["default"]
  shim = tag("input", :type => "text", :id => "#{options["id"]}_shim", :value => default ? default.name : "",
             :style => "width: 15em; display: inline; float: none;")
  hidden = to_input_field_tag("hidden", options.update("value" => default ? default.id : ""))
  
  url_params = options["auto_complete_url_params"].update(:people => people, :roles => roles,
                                         :escape => false)
  RAILS_DEFAULT_LOGGER.debug url_params.collect { |k, v| "#{k}: #{v}" }.join(", ")
  
  options["auto_complete_url"] = @template_object.url_for(url_params)
  shim + hidden + user_picker_extra_content(options) + user_picker_js(options)
end