Class: Faalis::Dashboard::Models::Sidebar

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TranslationHelper
Defined in:
lib/faalis/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/faalis/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/faalis/dashboard/models/sidebar.rb', line 74

def children
  @tree
end

#faalis_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
# File 'lib/faalis/dashboard/models/sidebar.rb', line 101

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

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

  end

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

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

  end
end

#item(name, **options) ⇒ Object


96
97
98
99
# File 'lib/faalis/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/faalis/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/faalis/dashboard/models/sidebar.rb', line 78

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