Class: DashboardPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/dashboard_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(current_user:) ⇒ DashboardPresenter

Returns a new instance of DashboardPresenter.



4
5
6
# File 'app/presenters/dashboard_presenter.rb', line 4

def initialize(current_user:)
  @current_user = current_user
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



3
4
5
# File 'app/presenters/dashboard_presenter.rb', line 3

def current_user
  @current_user
end

Instance Method Details

#all_projectsObject



8
9
10
11
12
13
# File 'app/presenters/dashboard_presenter.rb', line 8

def all_projects
  return [] unless current_user&.eligible_sysadmin?

  @all_projects ||= Project.all_projects.map { |project| ProjectDashboardPresenter.new(project) }.sort_by(&:updated_at).reverse
  @all_projects
end

#dashboard_projectsObject



15
16
17
18
# File 'app/presenters/dashboard_presenter.rb', line 15

def dashboard_projects
  @dashboard_projects ||= Project.users_projects(current_user).map { |project| ProjectDashboardPresenter.new(project) }.sort_by(&:updated_at).reverse
  @dashboard_projects
end

#my_draft_requestsObject



24
25
26
# File 'app/presenters/dashboard_presenter.rb', line 24

def my_draft_requests
  @my_draft_requests ||= Request.where(requested_by: current_user.uid)
end

#my_inventory_requestsObject



20
21
22
# File 'app/presenters/dashboard_presenter.rb', line 20

def my_inventory_requests
  @my_inventory_requests ||= current_user.user_requests.where(type: "FileInventoryRequest")
end