|
|
|
@ -1,17 +1,10 @@ |
|
|
|
module InterruptionScreenHelper |
|
|
|
module InterruptionScreenHelper |
|
|
|
def display_informative_text(informative_text, lettings_log) |
|
|
|
def display_informative_text(informative_text, log) |
|
|
|
return "" unless informative_text["arguments"] |
|
|
|
return "" unless informative_text["arguments"] |
|
|
|
|
|
|
|
|
|
|
|
translation_params = {} |
|
|
|
translation_params = {} |
|
|
|
informative_text["arguments"].each do |argument| |
|
|
|
informative_text["arguments"].each do |argument| |
|
|
|
value = if argument["label"] |
|
|
|
value = get_value_from_argument(log, argument) |
|
|
|
pre_casing_value = lettings_log.form.get_question(argument["key"], lettings_log).answer_label(lettings_log) |
|
|
|
|
|
|
|
pre_casing_value.downcase |
|
|
|
|
|
|
|
elsif argument["currency"] |
|
|
|
|
|
|
|
number_to_currency(lettings_log.public_send(argument["key"]), delimiter: ",", format: "%n", unit: "£") |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
lettings_log.public_send(argument["key"]) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
translation_params[argument["i18n_template"].to_sym] = value |
|
|
|
translation_params[argument["i18n_template"].to_sym] = value |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@ -24,23 +17,27 @@ module InterruptionScreenHelper |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def display_title_text(title_text, lettings_log) |
|
|
|
def display_title_text(title_text, log) |
|
|
|
return "" if title_text.nil? |
|
|
|
return "" if title_text.nil? |
|
|
|
|
|
|
|
|
|
|
|
translation_params = {} |
|
|
|
translation_params = {} |
|
|
|
arguments = title_text["arguments"] || {} |
|
|
|
arguments = title_text["arguments"] || {} |
|
|
|
arguments.each do |argument| |
|
|
|
arguments.each do |argument| |
|
|
|
value = if argument["label"] |
|
|
|
value = get_value_from_argument(log, argument) |
|
|
|
lettings_log.form.get_question(argument["key"], lettings_log).answer_label(lettings_log).downcase |
|
|
|
|
|
|
|
elsif argument["currency"] |
|
|
|
|
|
|
|
number_to_currency(lettings_log.public_send(argument["key"]), delimiter: ",", format: "%n", unit: "£") |
|
|
|
|
|
|
|
elsif argument["arguments_for_public_send"] |
|
|
|
|
|
|
|
lettings_log.public_send(argument["key"], argument["arguments_for_public_send"]) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
lettings_log.public_send(argument["key"]) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
translation_params[argument["i18n_template"].to_sym] = value |
|
|
|
translation_params[argument["i18n_template"].to_sym] = value |
|
|
|
end |
|
|
|
end |
|
|
|
I18n.t(title_text["translation"], **translation_params).to_s |
|
|
|
I18n.t(title_text["translation"], **translation_params).to_s |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_value_from_argument(log, argument) |
|
|
|
|
|
|
|
if argument["label"] |
|
|
|
|
|
|
|
log.form.get_question(argument["key"], log).answer_label(log).downcase |
|
|
|
|
|
|
|
elsif argument["arguments_for_public_send"] |
|
|
|
|
|
|
|
log.public_send(argument["key"], argument["arguments_for_public_send"]) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
log.public_send(argument["key"]) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|