Class: DashboardPresenter
- Inherits:
 - 
      Object
      
        
- Object
 - DashboardPresenter
 
 
- Defined in:
 - app/presenters/dashboard_presenter.rb
 
Instance Attribute Summary collapse
- 
  
    
      #current_user  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute current_user.
 
Instance Method Summary collapse
- #all_projects ⇒ Object
 - #dashboard_projects ⇒ Object
 - 
  
    
      #initialize(current_user:)  ⇒ DashboardPresenter 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of DashboardPresenter.
 - #my_draft_requests ⇒ Object
 - #my_inventory_requests ⇒ Object
 - #my_submitted_requests ⇒ Object
 
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_user ⇒ Object (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_projects ⇒ Object
      8 9 10 11 12 13 14 15 16 17 18 19  | 
    
      # File 'app/presenters/dashboard_presenter.rb', line 8 def all_projects # Short-cut to prevent an extra call to Mediaflux for non-admins # which are the large majority of our users. return [] unless current_user&.eligible_sysadmin? @all_projects ||= Project.all_projects(current_user) .map { |project| ProjectDashboardPresenter.new(project) } .select(&:project_in_rails?) .sort_by(&:updated_at) .reverse @all_projects end  | 
  
#dashboard_projects ⇒ Object
      21 22 23 24 25 26 27 28  | 
    
      # File 'app/presenters/dashboard_presenter.rb', line 21 def dashboard_projects @dashboard_projects ||= Project.users_projects(current_user) .map { |project| ProjectDashboardPresenter.new(project) } .select(&:project_in_rails?) .sort_by(&:updated_at) .reverse @dashboard_projects end  | 
  
#my_draft_requests ⇒ Object
      34 35 36  | 
    
      # File 'app/presenters/dashboard_presenter.rb', line 34 def my_draft_requests @my_draft_requests ||= Request.where(requested_by: current_user.uid, state: Request::DRAFT) end  | 
  
#my_inventory_requests ⇒ Object
      30 31 32  | 
    
      # File 'app/presenters/dashboard_presenter.rb', line 30 def my_inventory_requests @my_inventory_requests ||= current_user.user_requests.where(type: "FileInventoryRequest") end  |