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.
-
#display_modal ⇒ Object
readonly
Returns the value of attribute display_modal.
Instance Method Summary collapse
- #all_projects ⇒ Object
- #dashboard_projects ⇒ Object
- #display_confirm_delete_draft_modal? ⇒ Boolean
-
#initialize(current_user:, display_modal: "") ⇒ DashboardPresenter
constructor
A new instance of DashboardPresenter.
- #my_draft_requests ⇒ Object
- #my_inventory_requests ⇒ Object
- #my_submitted_requests ⇒ Object
Constructor Details
#initialize(current_user:, display_modal: "") ⇒ DashboardPresenter
Returns a new instance of DashboardPresenter.
5 6 7 8 |
# File 'app/presenters/dashboard_presenter.rb', line 5 def initialize(current_user:, display_modal: "") @current_user = current_user @display_modal = display_modal 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 |
#display_modal ⇒ Object (readonly)
Returns the value of attribute display_modal.
3 4 5 |
# File 'app/presenters/dashboard_presenter.rb', line 3 def display_modal @display_modal end |
Instance Method Details
#all_projects ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/presenters/dashboard_presenter.rb', line 10 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, current_user) } .select(&:project_in_rails?) .sort_by(&:updated_at) .reverse @all_projects end |
#dashboard_projects ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/presenters/dashboard_presenter.rb', line 23 def dashboard_projects @dashboard_projects ||= Project.users_projects(current_user) .map { |project| ProjectDashboardPresenter.new(project, current_user) } .select(&:project_in_rails?) .sort_by(&:updated_at) .reverse @dashboard_projects end |
#display_confirm_delete_draft_modal? ⇒ Boolean
44 45 46 |
# File 'app/presenters/dashboard_presenter.rb', line 44 def display_confirm_delete_draft_modal? display_modal == "confirm_delete_draft" end |
#my_draft_requests ⇒ Object
36 37 38 |
# File 'app/presenters/dashboard_presenter.rb', line 36 def my_draft_requests @my_draft_requests ||= presented_requests(Request.where(requested_by: current_user.uid, state: Request::DRAFT)) end |
#my_inventory_requests ⇒ Object
32 33 34 |
# File 'app/presenters/dashboard_presenter.rb', line 32 def my_inventory_requests @my_inventory_requests ||= current_user.user_requests.where(type: "FileInventoryRequest") end |