Class: Underworld::Dashboard::Models::Sidebar

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TranslationHelper
Defined in:
lib/underworld/dashboard/models/sidebar.rb

Instance Method Summary collapse

Methods included from ActionView::Helpers::TranslationHelper

#t

Constructor Details

#initialize(title, **options) ⇒ Sidebar

Returns a new instance of Sidebar.



67
68
69
70
71
72
# File 'lib/underworld/dashboard/models/sidebar.rb', line 67

def initialize(title, **options)
  @title = title
  extract_options(options)
  @tree = RootMenu.new
  @current_node = @tree
end

Instance Method Details

#childrenObject



74
75
76
# File 'lib/underworld/dashboard/models/sidebar.rb', line 74

def children
  @tree
end

#item(name, **options) ⇒ Object



96
97
98
99
# File 'lib/underworld/dashboard/models/sidebar.rb', line 96

def item(name, **options)
  item = Item.new(name, options)
  @current_node.add_child item
end


82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/underworld/dashboard/models/sidebar.rb', line 82

def menu(name, **options, &block)
  item = Menu.new(name, options)


  @current_node.add_child item

  prev_node = @current_node
  @current_node = item

  block.call if block_given?

  @current_node = prev_node
end

#titleObject



78
79
80
# File 'lib/underworld/dashboard/models/sidebar.rb', line 78

def title
  @title || I18n.t('underworld.dashboard.sidebar.title')
end

#underworld_entriesObject



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/underworld/dashboard/models/sidebar.rb', line 101

def underworld_entries
  menu(t('underworld.dashboard.user_management'),
    icon: 'fa fa-users',
    model: 'Underworld::User') do
    item(I18n.t('underworld.dashboard.users'),
      model: 'Underworld::User',
      url: Underworld::Engine.routes.url_helpers.dashboard_auth_users_path)

    item(I18n.t('underworld.dashboard.groups'),
      model: 'Underworld::Group',
      url: Underworld::Engine.routes.url_helpers.dashboard_auth_groups_path)

  end

  menu(t('underworld.dashboard.user_message'),
    icon: 'fa fa-envelope-o',
    model: 'Underworld::UserMessage') do

    item(I18n.t('underworld.dashboard.user_messages.inbox'),
      model: 'Underworld::UserMessage',
      url: Underworld::Engine.routes.url_helpers.dashboard_user_messages_path)
    item(I18n.t('underworld.dashboard.user_messages.sent'),
      model: 'Underworld::UserMessage',
      url: Underworld::Engine.routes.url_helpers.dashboard_user_messages_path)
    item(I18n.t('underworld.dashboard.user_messages.draft'),
      model: 'Underworld::UserMessage',
      url: Underworld::Engine.routes.url_helpers.dashboard_user_messages_path)

  end
end