allow to disable confetti

This commit is contained in:
Pete Matsyburka
2024-03-09 23:29:59 +02:00
parent 2d0f323854
commit 633e5ac5e4
6 changed files with 39 additions and 9 deletions
+13 -6
View File
@@ -2,20 +2,27 @@
module Submitters
module FormConfigs
DEFAULT_KEYS = [AccountConfig::FORM_COMPLETED_BUTTON_KEY,
AccountConfig::FORM_WITH_CONFETTI_KEY,
AccountConfig::ALLOW_TYPED_SIGNATURE].freeze
module_function
def call(submitter)
def call(submitter, keys = [])
configs = submitter.submission.template.account.account_configs
.where(key: [AccountConfig::FORM_COMPLETED_BUTTON_KEY,
AccountConfig::FORM_WITH_CONFETTI_KEY,
AccountConfig::ALLOW_TYPED_SIGNATURE])
.where(key: DEFAULT_KEYS + keys)
completed_button = configs.find { |e| e.key == AccountConfig::FORM_COMPLETED_BUTTON_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:, with_typed_signature:, with_confetti: }
attrs = { completed_button:, with_typed_signature:, with_confetti: }
keys.each do |key|
attrs[key.to_sym] = configs.find { |e| e.key == key.to_s }&.value
end
attrs
end
end
end