prefill signature

This commit is contained in:
Pete Matsyburka
2024-06-15 15:55:09 +03:00
parent 9e66f8412c
commit f9d52e56a2
14 changed files with 195 additions and 30 deletions
+12 -7
View File
@@ -5,20 +5,21 @@ module Submitters
DEFAULT_KEYS = [AccountConfig::FORM_COMPLETED_BUTTON_KEY,
AccountConfig::FORM_COMPLETED_MESSAGE_KEY,
AccountConfig::FORM_WITH_CONFETTI_KEY,
AccountConfig::FORM_PREFILL_SIGNATURE_KEY,
AccountConfig::ALLOW_TYPED_SIGNATURE].freeze
module_function
def call(submitter, keys = [])
configs = submitter.submission.account.account_configs
.where(key: DEFAULT_KEYS + keys)
configs = submitter.submission.account.account_configs.where(key: DEFAULT_KEYS + keys)
completed_button = configs.find { |e| e.key == AccountConfig::FORM_COMPLETED_BUTTON_KEY }&.value || {}
completed_message = configs.find { |e| e.key == AccountConfig::FORM_COMPLETED_MESSAGE_KEY }&.value || {}
with_typed_signature = configs.find { |e| e.key == AccountConfig::ALLOW_TYPED_SIGNATURE }&.value != false
with_confetti = configs.find { |e| e.key == AccountConfig::FORM_WITH_CONFETTI_KEY }&.value != false
completed_button = find_safe_value(configs, AccountConfig::FORM_COMPLETED_BUTTON_KEY) || {}
completed_message = find_safe_value(configs, AccountConfig::FORM_COMPLETED_MESSAGE_KEY) || {}
with_typed_signature = find_safe_value(configs, AccountConfig::ALLOW_TYPED_SIGNATURE) != false
with_confetti = find_safe_value(configs, AccountConfig::FORM_WITH_CONFETTI_KEY) != false
prefill_signature = find_safe_value(configs, AccountConfig::FORM_PREFILL_SIGNATURE_KEY) != false
attrs = { completed_button:, with_typed_signature:, with_confetti:, completed_message: }
attrs = { completed_button:, with_typed_signature:, with_confetti:, completed_message:, prefill_signature: }
keys.each do |key|
attrs[key.to_sym] = configs.find { |e| e.key == key.to_s }&.value
@@ -26,5 +27,9 @@ module Submitters
attrs
end
def find_safe_value(configs, key)
configs.find { |e| e.key == key }&.value
end
end
end