Files
grecia/app/components/admin/budgets/help_component.rb
Javi Martín d40535aaee Fix help text in wizard with validation errors
There was an edge case where we could access the headings index without
sending the mode parameter in the URL. That meant when sending the
headings form we could send a form with the mode hidden field set to an
empty string. When that happened, the returned text was
`t("admin.budgets.help.#{i18n_namespace}.`, which returned a hash.

Using `multiple` when an empty strin is received solves the issue.
2021-10-25 18:34:19 +02:00

22 lines
513 B
Ruby

class Admin::Budgets::HelpComponent < ApplicationComponent
attr_reader :i18n_namespace
def initialize(i18n_namespace)
@i18n_namespace = i18n_namespace
end
def budget_mode
(helpers.budget_mode if helpers.respond_to?(:budget_mode)).presence || "multiple"
end
private
def text
if t("admin.budgets.help.#{i18n_namespace}").is_a?(Hash)
t("admin.budgets.help.#{i18n_namespace}.#{budget_mode}")
else
t("admin.budgets.help.#{i18n_namespace}")
end
end
end