Module: Chaltron::LdapHelper

Defined in:
app/helpers/chaltron/ldap_helper.rb

Instance Method Summary collapse

Instance Method Details

#custom_checkbox(options) ⇒ Object



21
22
23
24
25
26
27
28
# File 'app/helpers/chaltron/ldap_helper.rb', line 21

def custom_checkbox(options)
  id = options.delete(:id)
  klass = options.delete(:class)
   :div, class: 'custom-control custom-checkbox' do
    check_box_tag('checkbox', nil, nil, options.merge(id: id, class: "custom-control-input d-none #{klass}")) +
    label_tag(id, '', class: 'custom-control-label d-block', for: id)
  end
end

#display_entry_email(entry) ⇒ Object



12
13
14
15
16
17
18
19
# File 'app/helpers/chaltron/ldap_helper.rb', line 12

def display_entry_email(entry)
  mail = entry.email
  if mail.blank?
    (:span, I18n.t('chaltron.users.missing_field'), class: 'badge badge-danger')
  else
    mail
  end
end

#display_entry_name(entry) ⇒ Object



3
4
5
6
7
8
9
10
# File 'app/helpers/chaltron/ldap_helper.rb', line 3

def display_entry_name(entry)
  if User.exists?(username: entry.username)
    (entry.name + ' ').html_safe +
      (:span, I18n.t('chaltron.users.already_present'), class: 'badge badge-danger')
  else
    entry.name
  end
end