add emails copy toggle

This commit is contained in:
Pete Matsyburka
2024-06-14 12:19:13 +03:00
parent ee357e58ac
commit 15e60fc5e7
3 changed files with 32 additions and 10 deletions
@@ -9,6 +9,7 @@ class TemplatesPreferencesController < ApplicationController
authorize!(:update, @template)
@template.preferences = @template.preferences.merge(template_params[:preferences])
@template.preferences = @template.preferences.reject { |_, v| v.is_a?(String) && v.blank? }
@template.save!
head :ok
@@ -19,7 +20,16 @@ class TemplatesPreferencesController < ApplicationController
def template_params
params.require(:template).permit(
preferences: %i[bcc_completed request_email_subject request_email_body
documents_copy_email_subject documents_copy_email_body]
)
documents_copy_email_subject documents_copy_email_body
documents_copy_email_enabled]
).tap do |attrs|
attrs[:preferences] = attrs[:preferences].transform_values do |value|
if %w[true false].include?(value)
value == 'true'
else
value
end
end
end
end
end