feat: carry forward font and alignment attributes for new fields

pull/555/head
NEMYSESx 3 months ago
parent fa99b4ebdc
commit 0b3b95ff38

@ -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|

@ -1210,6 +1210,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
@ -1254,6 +1269,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

@ -89,6 +89,14 @@
<%= ff.check_box :require_email_2fa, { checked: ff.object.require_email_2fa == true, class: 'toggle' }, 'true', 'false' %>
</submit-form>
</div>
<div class="flex items-center justify-between py-2.5 px-1 mb-2">
<span>
<%= t('carry_forward_field_attributes_on_the_document') %>
</span>
<submit-form data-on="change" class="flex">
<%= ff.check_box :carry_forward_attributes, { checked: ff.object.carry_forward_attributes == true, class: 'toggle' }, 'true', 'false' %>
</submit-form>
</div>
<% end %>
<div class="form-control pt-2">
<%= f.button button_title(title: t('save'), disabled_with: t('saving')), class: 'base-button' %>

Loading…
Cancel
Save