Module: ChaltronHelper

Defined in:
app/helpers/chaltron_helper.rb

Instance Method Summary collapse

Instance Method Details



26
27
28
29
30
31
32
33
34
# File 'app/helpers/chaltron_helper.rb', line 26

def back_link(opts = {})
  klass = opts[:class] || 'btn btn-primary'
  text  = opts[:text]  || t('chaltron.common.back')
  ic    = opts[:icon]  || 'arrow-left '

  link_to :back, class: klass do
    icon(:fas, ic, text)
  end
end

#bootstrap_class_for(flash_type) ⇒ Object

Flash messages



10
11
12
13
14
15
16
17
# File 'app/helpers/chaltron_helper.rb', line 10

def bootstrap_class_for(flash_type)
  {
    success: 'alert-success',
    error:   'alert-danger',
    alert:   'alert-warning',
    notice:  'alert-info'
  }[flash_type] || flash_type.to_s
end

#flash_message(message, type) ⇒ Object



19
20
21
22
23
24
# File 'app/helpers/chaltron_helper.rb', line 19

def flash_message(message, type)
  (:div, message, class: "alert #{bootstrap_class_for(type)} rounded-0") do
    (:strong, I18n.t("chaltron.flash.#{type}") + ': ') +
    message
  end
end

#ldap_enabled?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'app/helpers/chaltron_helper.rb', line 3

def ldap_enabled?
  Devise.omniauth_providers.include? :ldap
end

#revisionObject

Get current revision



39
40
41
# File 'app/helpers/chaltron_helper.rb', line 39

def revision
  @revision || get_revision_number
end