Sha256: 996975fc6d1eb652170c233e2dba72aad292fdaaf7ac3e3bd5abfff3f9b5b351

Contents?: true

Size: 990 Bytes

Versions: 19

Compression:

Stored size: 990 Bytes

Contents

module AdminIt
  #
  module Helpers
    #
    class TopMenuItem < WrapIt::Link
      attr_accessor :resource
      option :resource

      before_capture do
        unless resource.icon.nil?
          body << html_safe("<i class=\"fa fa-#{resource.icon}\"></i> ")
        end
        body << resource.display_name
        self.link = @template.url_for(
          controller: resource.name,
          action: resource.default_context
        )
        options = { tag: 'li' }
        options[:class] = 'active' if resource == @template.resource
        wrap(options)
      end
    end

    #
    class TopMenu < WrapIt::Container
      default_tag 'ul'
      html_class 'nav'
      child :item, TopMenuItem

      after_initialize { self.deffered_render = true }

      before_capture do
        AdminIt.resources.each do |name, resource|
          next unless resource.menu == true
          item(resource: resource)
        end
      end
    end

    register :top_menu, TopMenu
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
admin_it-1.3.8 lib/admin_it/helpers/top_menu.rb
admin_it-1.3.7 lib/admin_it/helpers/top_menu.rb
admin_it-1.3.6 lib/admin_it/helpers/top_menu.rb
admin_it-1.3.5 lib/admin_it/helpers/top_menu.rb
admin_it-1.3.4 lib/admin_it/helpers/top_menu.rb
admin_it-1.3.3 lib/admin_it/helpers/top_menu.rb
admin_it-1.3.2 lib/admin_it/helpers/top_menu.rb
admin_it-1.3.1 lib/admin_it/helpers/top_menu.rb
admin_it-1.3.0 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.8 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.7 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.6 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.5 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.4 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.3 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.2 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.1 lib/admin_it/helpers/top_menu.rb
admin_it-1.2.0 lib/admin_it/helpers/top_menu.rb
admin_it-1.1.0 lib/admin_it/helpers/top_menu.rb