Class: RubyUIAdmin::Views::Base
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- RubyUIAdmin::Views::Base
- Includes:
- UI, PathHelpers, RailsHelpers, Translation
- Defined in:
- app/components/ruby_ui_admin/views/base.rb
Overview
Full-page layout/chrome for every admin screen. Subclasses implement content.
Instance Method Summary collapse
-
#authorized_to?(rule, record, policy_class: nil) ⇒ Boolean
Whether the current user is allowed to perform
ruleonrecord. -
#content ⇒ Object
Overridden by subclasses.
- #view_template ⇒ Object
Methods included from Translation
Methods included from PathHelpers
#attachment_url, #resource_edit_path, #resource_index_path, #resource_new_path, #resource_show_path
Instance Method Details
#authorized_to?(rule, record, policy_class: nil) ⇒ Boolean
Whether the current user is allowed to perform rule on record.
47 48 49 50 51 |
# File 'app/components/ruby_ui_admin/views/base.rb', line 47 def (rule, record, policy_class: nil) RubyUIAdmin::Services::AuthorizationService .new(RubyUIAdmin::Current.user, record, policy_class: policy_class) .allowed?(rule) end |
#content ⇒ Object
Overridden by subclasses.
44 |
# File 'app/components/ruby_ui_admin/views/base.rb', line 44 def content; end |
#view_template ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/components/ruby_ui_admin/views/base.rb', line 12 def view_template doctype # `overflow-y: auto` keeps the admin scrollable even when the host's global CSS locks page # scroll (e.g. `html, body { overflow: hidden }` for a fixed-viewport app shell) — the admin # renders its own document, so it can't rely on the host layout's own scroll override. html(lang: "en", style: "overflow-y: auto") do head do (charset: "utf-8") (name: "viewport", content: "width=device-width, initial-scale=1") title { page_title } render_head_assets end # Turbo Drive is on (self-hosted, see render_head_assets) for SPA-style navigation — no # full-page reloads. `rua--confirm` manages the shared delete-confirmation AlertDialog. body(class: "min-h-screen bg-background text-foreground antialiased", data: {controller: "rua--confirm"}) do render RubyUI::SidebarWrapper.new do render RubyUI::SidebarInset.new do main(class: "flex-1 min-w-0 p-6 lg:p-8") do # `rua--dialog` manages the lazy action modals rendered anywhere in the page body. div(data: {controller: "rua--dialog"}, class: "w-full max-w-7xl mx-auto") { content } end end end render_toaster render_confirm_dialog end end end |