Module: AnyLogin::ApplicationHelper

Extended by:
ActiveSupport::Concern
Defined in:
app/helpers/any_login/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#any_login_hereObject



5
6
7
# File 'app/helpers/any_login/application_helper.rb', line 5

def 
  render 'any_login/any_login' if AnyLogin.enabled && AnyLogin.verify_access_proc.call(self.controller)
end

#any_login_id_inputObject



11
12
13
# File 'app/helpers/any_login/application_helper.rb', line 11

def 
  text_field_tag :id, '', :placeholder => 'ID', :id => 'any_login_id_input'
end

#any_login_klassesObject



61
62
63
64
65
66
# File 'app/helpers/any_login/application_helper.rb', line 61

def 
  klasses = []
  klasses << "any_login_#{AnyLogin.position || 'bottom_left'}"
  klasses << 'any_login_auto_show' if AnyLogin.auto_show
  klasses.join(' ')
end

#any_login_previous_idsObject



50
51
52
# File 'app/helpers/any_login/application_helper.rb', line 50

def 
  (cookies[AnyLogin.cookie_name].presence || '').split(',').take(AnyLogin.previous_limit)
end

#any_login_previous_selectObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/helpers/any_login/application_helper.rb', line 30

def 
  ids = 
  return if ids.blank?

  users = ids.collect do |id|
    AnyLogin.klass.where(AnyLogin.klass.primary_key => id).first
  end.compact

  collection = AnyLogin::Collection.new(users).to_a
  if collection.any?
    select_options = options_for_select(collection)
    [
      (:span, id: 'anylogin_back_to_user') do
        "History: "
      end,
      select_tag(:back_to_previous_id, select_options, select_html_options("Back to:"))
    ].join.html_safe
  end
end

#any_login_selectObject



19
20
21
22
23
24
25
26
27
28
# File 'app/helpers/any_login/application_helper.rb', line 19

def 
  collection = AnyLogin.collection
  select_options =
                  if collection.grouped?
                    grouped_options_for_select(collection.to_a)
                  else
                    options_for_select(collection.to_a)
                  end
  select_tag :selected_id, select_options, select_html_options
end

#any_login_submitObject



15
16
17
# File 'app/helpers/any_login/application_helper.rb', line 15

def 
  submit_tag AnyLogin.
end

#current_user_informationObject



68
69
70
71
72
73
74
75
76
77
78
79
# File 'app/helpers/any_login/application_helper.rb', line 68

def current_user_information
  if respond_to?(AnyLogin.provider::Controller.) &&
     user = send(AnyLogin.provider::Controller.)
     :span, :class => 'any_login_user_information' do
      if AnyLogin.name_method.is_a?(Symbol)
        raw("Current #{AnyLogin.klass_name}: #{h(user.send(AnyLogin.name_method)[0])} &mdash; ID: #{user.id}")
      else
        raw("Current #{AnyLogin.klass_name}: #{h(AnyLogin.name_method.call(user)[0])} &mdash; ID: #{user.id}")
      end
    end
  end
end

#select_html_options(prompt = AnyLogin.select_prompt) ⇒ Object



54
55
56
57
58
59
# File 'app/helpers/any_login/application_helper.rb', line 54

def select_html_options(prompt = AnyLogin.select_prompt)
  options = {}
  options[:onchange] = 'AnyLogin.on_select_change();' if AnyLogin. == :both
  options[:prompt] = prompt
  options
end