Sha256: 008f34679eb202269456974bbc5b96099027fcaea2c8bedfd08898dcb413a249

Contents?: true

Size: 1.11 KB

Versions: 13

Compression:

Stored size: 1.11 KB

Contents

module Admin::Resources::SidebarHelper

  def build_sidebar
    locals = { :sidebar_title => Typus::I18n.t("Dashboard"), :actions => []}

    if @resource
      locals[:actions] = [sidebar_list(@resource.name), sidebar_add_new(@resource.name)].compact
      locals[:sidebar_title] = @resource.model_name.human.pluralize
    end

    render "helpers/admin/resources/sidebar", locals
  end

  def sidebar_add_new(klass)
    if admin_user.can?("create", klass)
      { :message => Typus::I18n.t("Add"),
        :url => { :controller => "/admin/#{klass.to_resource}", :action => "new" },
        :icon => "plus" }
    end
  end

  def sidebar_list(klass)
    if admin_user.can?("read", klass)
      { :message => Typus::I18n.t("List"),
        :url => { :controller => "/admin/#{klass.to_resource}", :action => "index" },
        :icon => "list" }
    end
  end

  # TODO: Move it to the header.
  def sidebar_view_site
    if Typus.link_to_view_site
      { :message => Typus::I18n.t("View Site"),
        :url => Typus.admin_title_link,
        :link_to_options => { :target => '_blank' },
        :icon => "share" }
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

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