Sha256: 7cdc35486de9f2dc2cef83a254598d1db7f65b59386999436c1a6efb0d3c2f94

Contents?: true

Size: 1.49 KB

Versions: 13

Compression:

Stored size: 1.49 KB

Contents

module Admin::BaseHelper

  def admin_title(page_title = nil)
    if page_title
      content_for(:title) { page_title }
    else
      setting = defined?(Admin::Setting) && Admin::Setting.admin_title
      setting || Typus.admin_title
    end
  end

  def admin_sign_out_path
    case Typus.authentication
    when :devise
      send("destroy_#{Typus.user_class_name.underscore}_session_path")
    else
      destroy_admin_session_path
    end
  end

  def admin_edit_user_path(user)
    { :controller => "/admin/#{Typus.user_class.to_resource}",
      :action => "edit",
      :id => user.id }
  end

  def admin_display_flash_message
    if flash.any?
      String.new.tap do |html|
        flash.each do |type, message|
          if type == :notice
            type = 'info'
          end
          html << content_tag(:div, message, :id => 'flash', :class => "alert alert-#{type}")
        end
      end.html_safe
    end
  end

  def set_modal_options_for(klass)
    { "data-toggle" => "modal",
      "data-controls-modal" => "modal-from-dom-#{klass.model_name.param_key}",
      "data-backdrop" => "true",
      "data-keyboard" => "true",
      "class" => "ajax-modal",
      "url" => "override-this" }
  end

  def body_class
    if params[:controller] == 'admin/dashboard'
      "base dashboard #{params[:action].parameterize}"
    else
      classes = ['base', params[:action].parameterize]
      classes << ['resource', @resource.model_name.param_key] if @resource 
      classes.flatten.join(" ")
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
brainsome_typus-4.0.0.beta13 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta12 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta11 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta10 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta9 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta8 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta7 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta6 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta5 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta4 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta3 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta2 app/helpers/admin/base_helper.rb
brainsome_typus-4.0.0.beta1 app/helpers/admin/base_helper.rb