diff --git a/app/controllers/templates_preferences_controller.rb b/app/controllers/templates_preferences_controller.rb index 49041cfc..59b18a82 100644 --- a/app/controllers/templates_preferences_controller.rb +++ b/app/controllers/templates_preferences_controller.rb @@ -57,7 +57,8 @@ class TemplatesPreferencesController < ApplicationController require_all_submitters submitters_order require_phone_2fa require_email_2fa default_expire_at_duration shared_link_2fa default_expire_at request_email_enabled 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 + carry_forward_attributes] + [completed_message: %i[title body], submitters: [%i[uuid request_email_subject request_email_body]], link_form_fields: []] ).tap do |attrs| diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 5338fc07..02068088 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -1525,6 +1525,21 @@ export default { } } + const lastField = this.selectedField || this.template.fields[this.template.fields.length - 1] + + if (this.template.preferences?.carry_forward_attributes && lastField?.preferences) { + field.preferences ||= {} + field.preferences = { ...field.preferences } + + const attrsToCopy = ['font', 'font_size', 'font_type', 'align', 'valign', 'color'] + + attrsToCopy.forEach((attr) => { + if (lastField.preferences[attr]) { + field.preferences[attr] = lastField.preferences[attr] + } + }) + } + if (field.type === 'strikethrough') { field.readonly = true field.default_value = true @@ -1569,6 +1584,21 @@ export default { } this.drawField = field + + const lastField = this.selectedField || this.template.fields[this.template.fields.length - 1] + + if (this.template.preferences?.carry_forward_attributes && lastField?.preferences) { + field.preferences ||= {} + field.preferences = { ...field.preferences } + + const attrsToCopy = ['font', 'font_size', 'font_type', 'align', 'valign', 'color'] + + attrsToCopy.forEach((attr) => { + if (lastField.preferences[attr]) { + field.preferences[attr] = lastField.preferences[attr] + } + }) + } } this.drawOption = null diff --git a/app/views/templates_preferences/show.html.erb b/app/views/templates_preferences/show.html.erb index ddb52bd8..55cca0b7 100644 --- a/app/views/templates_preferences/show.html.erb +++ b/app/views/templates_preferences/show.html.erb @@ -89,6 +89,14 @@ <%= ff.check_box :require_email_2fa, { checked: ff.object.require_email_2fa == true, class: 'toggle' }, 'true', 'false' %> +