Sha256: adf1a794e80b949b5f187aa3ab9fa4317575a6b0c588f18bf8a2c6a99cf8c351

Contents?: true

Size: 912 Bytes

Versions: 40

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

module Satis
  module Menus
    class Item
      attr_reader :id, :link, :icon, :app, :menu, :link_attributes, :level, :type

      attr_writer :scope

      def initialize(id, link: nil, label: nil, icon: nil, link_attributes: {}, active: nil, scope: [], level: nil, type: :item, &block)
        @id = id
        @label = label
        @icon = icon
        @link = link
        @link_attributes = link_attributes
        @scope = scope
        @level = level
        @type = type
        @link_attributes = @link_attributes.merge(data: { action: 'click->satis-menu#toggle' }) if type == :toggle
        @menu = Menu.new(scope + ["#{id}_menu".to_sym], level: level + 1, &block) if block_given?
      end

      def label
        return @label if @label

        @label ||= I18n.t(id, scope: [:menu] + @scope)
      end

      def active?
        active
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
satis-2.1.47 lib/satis/menus/item.rb
satis-2.1.46 lib/satis/menus/item.rb
satis-2.1.45 lib/satis/menus/item.rb
satis-2.1.44 lib/satis/menus/item.rb
satis-2.1.43 lib/satis/menus/item.rb
satis-2.1.42 lib/satis/menus/item.rb
satis-2.1.41 lib/satis/menus/item.rb
satis-2.1.40 lib/satis/menus/item.rb
satis-2.1.39 lib/satis/menus/item.rb
satis-2.1.38 lib/satis/menus/item.rb
satis-2.1.37 lib/satis/menus/item.rb
satis-2.1.36 lib/satis/menus/item.rb
satis-2.1.35 lib/satis/menus/item.rb
satis-2.1.33 lib/satis/menus/item.rb
satis-2.1.31 lib/satis/menus/item.rb
satis-2.1.30 lib/satis/menus/item.rb
satis-2.1.29 lib/satis/menus/item.rb
satis-2.1.28 lib/satis/menus/item.rb
satis-2.1.27 lib/satis/menus/item.rb
satis-2.1.26 lib/satis/menus/item.rb