Files
docuseal/lib/submitters/form_configs.rb
T

31 lines
1.1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
module Submitters
module FormConfigs
2024-03-09 23:29:59 +02:00
DEFAULT_KEYS = [AccountConfig::FORM_COMPLETED_BUTTON_KEY,
2024-04-05 16:16:30 +03:00
AccountConfig::FORM_COMPLETED_MESSAGE_KEY,
2024-03-09 23:29:59 +02:00
AccountConfig::FORM_WITH_CONFETTI_KEY,
AccountConfig::ALLOW_TYPED_SIGNATURE].freeze
module_function
2024-03-09 23:29:59 +02:00
def call(submitter, keys = [])
2024-03-31 17:40:51 +03:00
configs = submitter.submission.account.account_configs
2024-03-09 23:29:59 +02:00
.where(key: DEFAULT_KEYS + keys)
completed_button = configs.find { |e| e.key == AccountConfig::FORM_COMPLETED_BUTTON_KEY }&.value || {}
2024-04-05 16:16:30 +03:00
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
2024-01-26 17:43:52 +02:00
with_confetti = configs.find { |e| e.key == AccountConfig::FORM_WITH_CONFETTI_KEY }&.value != false
2024-04-05 16:16:30 +03:00
attrs = { completed_button:, with_typed_signature:, with_confetti:, completed_message: }
2024-03-09 23:29:59 +02:00
keys.each do |key|
attrs[key.to_sym] = configs.find { |e| e.key == key.to_s }&.value
end
attrs
end
end
end