Class: Plutonium::UI::Page::Index
- Inherits:
-
Base
- Object
- Component::Base
- Base
- Plutonium::UI::Page::Index
- Defined in:
- lib/plutonium/ui/page/index.rb
Direct Known Subclasses
Class Method Summary collapse
-
.collection_dom_id(resource_class) ⇒ Object
DOM id of the wrapper around the rendered collection (table OR grid; never the kanban board, which owns its own column frames).
-
.resolve_view(definition, resource_class, view_param, cookies) ⇒ Object
Resolves the index view to render.
-
.view_cookie_name(resource_class) ⇒ Object
Cookie name carrying a per-resource view preference.
-
.view_cookie_path(request) ⇒ Object
Cookie Path scoped to the engine mount point (request.script_name).
Methods inherited from Base
Methods included from Component::Behaviour
Methods included from Component::Tokens
Methods included from Component::Kit
#BuildActionButton, #BuildActionsDropdown, #BuildAvatar, #BuildBlock, #BuildBreadcrumbs, #BuildBulkActionsToolbar, #BuildColorModeSelector, #BuildDynaFrameContent, #BuildDynaFrameHost, #BuildEmptyCard, #BuildFrameNavigatorPanel, #BuildModalCentered, #BuildModalSlideover, #BuildPageHeader, #BuildPanel, #BuildRowActionsDropdown, #BuildSkeletonTable, #BuildTabList, #BuildTableFilterPills, #BuildTableInfo, #BuildTablePagination, #BuildTableScopesBar, #BuildTableScopesPills, #BuildTableSearchBar, #BuildTableToolbar, #BuildTableViewSwitcher, #method_missing, #respond_to_missing?
Constructor Details
This class inherits a constructor from Plutonium::UI::Page::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plutonium::UI::Component::Kit
Class Method Details
.collection_dom_id(resource_class) ⇒ Object
DOM id of the wrapper around the rendered collection (table OR grid; never the kanban board, which owns its own column frames).
This is the turbo-stream target the reposition endpoint updates when a drop leaves the client's optimistic view stale, and the element the drag controllers (Tasks 7/8) scope themselves to. Resource-scoped so two collections of DIFFERENT resources on one page (a nested association panel inside a show page) don't collide.
33 34 35 |
# File 'lib/plutonium/ui/page/index.rb', line 33 def self.collection_dom_id(resource_class) "pu-collection-#{resource_class.model_name.plural}" end |
.resolve_view(definition, resource_class, view_param, cookies) ⇒ Object
Resolves the index view to render. Extracted to a class method because the reposition endpoint has to re-render the SAME view the user is looking at, and re-deriving that from scratch in the controller would be a second, drifting copy of this precedence.
Resolution order:
?view=URL param (so a shared link can pin a view)- The view-preference cookie (sticky per-resource selection)
- The resource's
default_index_view(which itself defaults toindex_views.first)
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/plutonium/ui/page/index.rb', line 47 def self.resolve_view(definition, resource_class, view_param, ) enabled = definition.defined_index_views requested = view_param&.to_sym return requested if requested && enabled.include?(requested) stored = [(resource_class)]&.to_sym return stored if stored && enabled.include?(stored) definition.default_index_view end |
.view_cookie_name(resource_class) ⇒ Object
Cookie name carrying a per-resource view preference. Single
source of truth — Table::Resource, Grid::Resource, and the
Stimulus view-switcher controller all read from here. Underscored
token-only characters keep this RFC 6265-compliant (the : form
this replaces is technically forbidden, even if browsers
accept it in practice).
13 14 15 |
# File 'lib/plutonium/ui/page/index.rb', line 13 def self.(resource_class) "pu_view_#{resource_class.name.gsub("::", "_").underscore}" end |
.view_cookie_path(request) ⇒ Object
Cookie Path scoped to the engine mount point (request.script_name). Two portals mounting the same resource class get independent view preferences instead of leaking through a site-wide cookie.
20 21 22 23 |
# File 'lib/plutonium/ui/page/index.rb', line 20 def self.(request) path = request.script_name.to_s path.empty? ? "/" : path end |