mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-09 14:12:37 +01:00
Add a Sidebar class to represent the side bar
Start using it throughout the rest of the app instead of the various instance variables
This commit is contained in:
parent
2883d1b7f4
commit
8d24f5105a
5 changed files with 66 additions and 17 deletions
29
app/models/sidebar.rb
Normal file
29
app/models/sidebar.rb
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
class Sidebar
|
||||
attr_reader :contexts, :projects
|
||||
|
||||
def initialize(user)
|
||||
user = user
|
||||
@contexts = user.contexts
|
||||
@projects = user.projects
|
||||
end
|
||||
|
||||
def active_contexts
|
||||
@active_contexts ||= contexts.active
|
||||
end
|
||||
|
||||
def hidden_contexts
|
||||
@hidden_contexts ||= contexts.hidden
|
||||
end
|
||||
|
||||
def active_projects
|
||||
@active_projects ||= projects.active
|
||||
end
|
||||
|
||||
def hidden_projects
|
||||
@hidden_projects ||= projects.hidden
|
||||
end
|
||||
|
||||
def completed_projects
|
||||
@completed_projects ||= projects.completed
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue