add template form preferences

This commit is contained in:
Pete Matsyburka
2024-09-12 22:41:39 +03:00
committed by Oleksandr Turchyn
parent ad8bca8bf4
commit e72090c2e0
3 changed files with 39 additions and 3 deletions
@@ -9,7 +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.preferences = @template.preferences.reject { |_, v| (v.is_a?(String) || v.is_a?(Hash)) && v.blank? }
@template.save!
head :ok
@@ -23,12 +23,16 @@ class TemplatesPreferencesController < ApplicationController
documents_copy_email_subject documents_copy_email_body
documents_copy_email_enabled documents_copy_email_attach_audit
completed_notification_email_attach_documents
completed_redirect_url
completed_notification_email_subject completed_notification_email_body
completed_notification_email_enabled completed_notification_email_attach_audit]
completed_notification_email_enabled completed_notification_email_attach_audit] +
[completed_message: %i[title body]]
).tap do |attrs|
attrs[:preferences] = attrs[:preferences].transform_values do |value|
if %w[true false].include?(value)
value == 'true'
elsif value.respond_to?(:compact_blank)
value.compact_blank
else
value
end