Module: AnyLogin::Helpers
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/any_login/helpers.rb
Instance Method Summary collapse
- #any_login_here ⇒ Object
- #any_login_id_input ⇒ Object
- #any_login_klasses ⇒ Object
- #any_login_previous_ids ⇒ Object
- #any_login_previous_select ⇒ Object
- #any_login_select ⇒ Object
- #any_login_submit ⇒ Object
- #current_user_information ⇒ Object
- #select_html_options(prompt = AnyLogin.select_prompt) ⇒ Object
Instance Method Details
#any_login_here ⇒ Object
5 6 7 |
# File 'lib/any_login/helpers.rb', line 5 def any_login_here render 'any_login/any_login' if AnyLogin.enabled && AnyLogin.verify_access_proc.call(self.controller) end |
#any_login_id_input ⇒ Object
11 12 13 14 15 |
# File 'lib/any_login/helpers.rb', line 11 def any_login_id_input def any_login_id_input text_field_tag :id, '', placeholder: 'ID', id: 'any_login_id_input', required: true end end |
#any_login_klasses ⇒ Object
62 63 64 65 66 |
# File 'lib/any_login/helpers.rb', line 62 def any_login_klasses klasses = [] klasses << "any_login_#{AnyLogin.position || 'bottom_left'}" klasses.join(' ') end |
#any_login_previous_ids ⇒ Object
52 53 54 |
# File 'lib/any_login/helpers.rb', line 52 def any_login_previous_ids ([AnyLogin.].presence || '').split(',').take(AnyLogin.previous_limit) end |
#any_login_previous_select ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/any_login/helpers.rb', line 32 def any_login_previous_select ids = any_login_previous_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? = (collection) [ content_tag(:span, id: 'anylogin_back_to_user') do "History: " end, select_tag(:back_to_previous_id, , ("Back to:")) ].join.html_safe end end |
#any_login_select ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/any_login/helpers.rb', line 21 def any_login_select collection = AnyLogin.collection = if collection.grouped? (collection.to_a) else (collection.to_a) end select_tag :selected_id, , end |
#any_login_submit ⇒ Object
17 18 19 |
# File 'lib/any_login/helpers.rb', line 17 def any_login_submit submit_tag AnyLogin. end |
#current_user_information ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/any_login/helpers.rb', line 68 def current_user_information if respond_to?(AnyLogin.provider.constantize::Controller.any_login_current_user_method) && user = send(AnyLogin.provider.constantize::Controller.any_login_current_user_method) content_tag :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])} — ID: #{user.id}") else raw("Current #{AnyLogin.klass_name}: #{h(AnyLogin.name_method.call(user)[0])} — ID: #{user.id}") end end end end |
#select_html_options(prompt = AnyLogin.select_prompt) ⇒ Object
56 57 58 59 60 |
# File 'lib/any_login/helpers.rb', line 56 def (prompt = AnyLogin.select_prompt) = {} [:prompt] = prompt end |