Sha256: 772f84a7c9d2e0c40fc3c4ebdb614c98f23a1a101028634633c861f2af8b6941

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module ChaltronHelper

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

  #
  # Flash messages
  #
  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

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

  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(ic) + ' '.html_safe + text
    end
  end

  #
  # Badge and label helpers
  #
  def badge(*args)
    badge_label(:badge, *args)
  end

  def tag_label(*args)
    badge_label(:label, *args)
  end

  private

  def badge_label(what, value, type = nil)
    klass = [what]
    klass << "#{what}-#{type}" if type.present?
    content_tag :span, value, class: "#{klass.join(' ')}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chaltron-0.1.0 app/helpers/chaltron_helper.rb