a11yist/app/controllers/application_controller.rb
david 4dd445be57
Some checks failed
/ Run tests (push) Successful in 7m57s
/ Run system tests (push) Failing after 4m18s
/ Build, push and deploy image (push) Failing after 59s
wip: wcag structure
2025-05-16 19:02:33 +02:00

58 lines
1.3 KiB
Ruby

# frozen_string_literal: true
class ApplicationController < ActionController::Base
include Authentication
include Pagy::Backend
# allow_browser versions: :modern
helper_method :sidebar?
before_action :initialize_navbar
private
def initialize_navbar
return unless request.get?
@navbar_items = if authenticated?
[
{
label: "Dashboard",
icon: :speedometer2,
path: :root
},
{
label: Project.model_name.human(count: 2),
icon: :'folder',
path: :projects },
{
label: I18n.t("backoffice"),
icon: :gear,
path: :backoffice,
active: %w[backoffice checklists checks links link_categories].include?(controller_name) },
{
label: "Konto",
path: profile_path,
icon: "person-circle"
}
]
else
[ { label: "Login", icon: :'door-closed', path: new_session_path, label_class: "text-info" } ]
end
@nav_path = controller_name
@search_url = nil
@sidebar_items = initialize_sidebar_items
end
def sidebar?
@sidebar_items && @sidebar_items.any?
end
def initialize_sidebar_items
[]
end
def render_modal(action: action_name)
render action, layout: "modal" if turbo_frame_request_id == "modal"
end
end