Class: AdminSuite::PortalsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin_suite/portals_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject

Raises:

  • (ActionController::RoutingError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/admin_suite/portals_controller.rb', line 5

def show
  ensure_portals_loaded!
  @portal_key = params[:portal].to_s.presence&.to_sym
  @portal = navigation_items[@portal_key]
  @portal_definition = AdminSuite::PortalRegistry.fetch(@portal_key)

  raise ActionController::RoutingError, "Portal not found" if @portal.blank?

  @sections =
    (@portal[:sections] || {}).sort_by { |(_k, s)| s[:label].to_s }.map do |section_key, section|
      items = Array(section[:items]).sort_by { |it| it[:label].to_s }
      [ section_key, section.merge(items: items) ]
    end

  @dashboard_rows = @portal_definition&.dashboard_definition&.rows
end