a11yist/app/controllers/application_controller.rb

59 lines
1.3 KiB
Ruby
Raw Permalink Normal View History

2024-07-15 14:31:54 +02:00
# frozen_string_literal: true
class ApplicationController < ActionController::Base
include Authentication
2024-07-21 00:33:38 +02:00
include Pagy::Backend
2024-09-05 22:54:38 +02:00
# allow_browser versions: :modern
2024-09-22 21:57:05 +02:00
helper_method :sidebar?
2024-09-05 22:54:38 +02:00
2024-07-15 14:31:54 +02:00
before_action :initialize_navbar
private
def initialize_navbar
2024-09-05 22:54:38 +02:00
return unless request.get?
@navbar_items = if authenticated?
2024-09-22 21:57:05 +02:00
[
{
label: "Dashboard",
icon: :speedometer2,
path: :root
},
{
2024-11-24 22:08:36 +01:00
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",
2025-05-16 19:02:33 +02:00
path: profile_path,
icon: "person-circle"
}
2024-09-22 21:57:05 +02:00
]
else
[ { label: "Login", icon: :'door-closed', path: new_session_path, label_class: "text-info" } ]
2024-09-22 21:57:05 +02:00
end
2024-09-05 22:54:38 +02:00
@nav_path = controller_name
@search_url = nil
2024-09-22 21:57:05 +02:00
@sidebar_items = initialize_sidebar_items
end
def sidebar?
@sidebar_items && @sidebar_items.any?
end
def initialize_sidebar_items
[]
2024-07-15 14:31:54 +02:00
end
def render_modal(action: action_name)
render action, layout: "modal" if turbo_frame_request_id == "modal"
end
end