a11yist/app/helpers/application_helper.rb
david 84fc1d2d93
Some checks failed
/ Run tests (push) Successful in 1m38s
/ Run system tests (push) Failing after 2m5s
/ Build, push and deploy image (push) Successful in 3m9s
Use blank in save display because file attributes are never nil
2024-11-12 22:57:47 +01:00

31 lines
762 B
Ruby

# frozen_string_literal: true
module ApplicationHelper
include Pagy::Frontend
delegate :filter_params, to: :controller
def multilang_form_field(form, attribute, as: :text_field)
return form.send(as, "#{attribute}_de")
col_width = as == :rich_text_area ? 12 : 12 / I18n.available_locales.count
tag.div(class: "row") do
fields = I18n.available_locales.map { _1.to_s.split("-").first }.map do |lang|
tag.div(class: "col-lg-#{col_width}") do
form.send(as, "#{attribute}_#{lang}")
end
end
safe_join(fields)
end
end
def safe_display(value, &block)
return if value.blank?
yield(value)
end
def current_page_displayed(page)
@current_page&.id == page.id ? "open" : nil
end
end