allow to disable confetti
This commit is contained in:
@@ -8,7 +8,8 @@ class AccountConfigsController < ApplicationController
|
||||
AccountConfig::ALLOW_TYPED_SIGNATURE,
|
||||
AccountConfig::FORCE_MFA,
|
||||
AccountConfig::ALLOW_TO_RESUBMIT,
|
||||
AccountConfig::ESIGNING_PREFERENCE_KEY
|
||||
AccountConfig::ESIGNING_PREFERENCE_KEY,
|
||||
AccountConfig::FORM_WITH_CONFETTI_KEY
|
||||
].freeze
|
||||
|
||||
InvalidKey = Class.new(StandardError)
|
||||
|
||||
@@ -17,7 +17,11 @@ class PersonalizationSettingsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
@account_config.save!
|
||||
if @account_config.value != false && @account_config.value.blank?
|
||||
@account_config.destroy!
|
||||
else
|
||||
@account_config.save!
|
||||
end
|
||||
|
||||
redirect_back(fallback_location: settings_personalization_path, notice: 'Settings have been saved.')
|
||||
end
|
||||
@@ -40,6 +44,8 @@ class PersonalizationSettingsController < ApplicationController
|
||||
def account_config_params
|
||||
attrs = params.require(:account_config).permit!
|
||||
|
||||
return attrs if attrs[:value].is_a?(String)
|
||||
|
||||
attrs[:value]&.transform_values! do |value|
|
||||
if value.in?(%w[true false])
|
||||
value == 'true'
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<%= render 'form_toggle_options' %>
|
||||
@@ -0,0 +1,14 @@
|
||||
<% account_config = AccountConfig.where(account: current_account, key: AccountConfig::FORM_WITH_CONFETTI_KEY).first_or_initialize(value: true) %>
|
||||
<% if can?(:manage, account_config) %>
|
||||
<div class="px-1 mt-2">
|
||||
<%= form_for account_config, url: account_configs_path, method: :post do |f| %>
|
||||
<%= f.hidden_field :key %>
|
||||
<div class="flex items-center justify-between py-2.5">
|
||||
<span>
|
||||
Show confetti on successful completion
|
||||
</span>
|
||||
<%= f.check_box :value, { class: 'toggle', checked: account_config.value != false, onchange: 'this.form.requestSubmit()' }, '1', '0' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -9,8 +9,9 @@
|
||||
</div>
|
||||
<p class="text-4xl font-bold mb-4 mt-8">Company Logo</p>
|
||||
<%= render 'logo_form' %>
|
||||
<p class="text-4xl font-bold mb-4 mt-8">Submitter Form</p>
|
||||
<p class="text-4xl font-bold mb-4 mt-8">Submission Form</p>
|
||||
<%= render 'form_completed_button_form' %>
|
||||
<%= render 'form_customization_settings' %>
|
||||
</div>
|
||||
<div class="w-0 md:w-52"></div>
|
||||
</div>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user