fix default values
This commit is contained in:
@@ -621,7 +621,7 @@ export default {
|
||||
|
||||
this.fields.forEach((field) => {
|
||||
if (field.default_value && !field.readonly) {
|
||||
this.values[field.uuid] = field.default_value
|
||||
this.values[field.uuid] ||= field.default_value
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -123,12 +123,14 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.isTextArea = this.modelValue?.includes('\n')
|
||||
if (this.modelValue) {
|
||||
this.isTextArea = this.modelValue.toString().includes('\n')
|
||||
|
||||
if (this.isTextArea) {
|
||||
this.$nextTick(() => {
|
||||
this.resizeTextarea()
|
||||
})
|
||||
if (this.isTextArea) {
|
||||
this.$nextTick(() => {
|
||||
this.resizeTextarea()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -109,8 +109,10 @@ module Submissions
|
||||
field['description'] = attrs['description'] if attrs['description'].present?
|
||||
field['readonly'] = attrs['readonly'] if attrs.key?('readonly')
|
||||
field['required'] = attrs['required'] if attrs.key?('required')
|
||||
field['default_value'] = attrs['default_value'] if attrs['default_value'].present? &&
|
||||
!field['type'].in?(%w[signature image initials file])
|
||||
|
||||
if attrs['default_value'].present? && !field['type'].in?(%w[signature image initials file])
|
||||
field['default_value'] = Submitters::NormalizeValues.normalize_value(field, attrs['default_value'])
|
||||
end
|
||||
|
||||
return field if attrs['validation_pattern'].blank?
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@ module Submitters
|
||||
|
||||
next if key.blank?
|
||||
|
||||
if fields_uuid_index[key]['type'].in?(%w[initials signature image file]) && value.present?
|
||||
field = fields_uuid_index[key]
|
||||
|
||||
if field['type'].in?(%w[initials signature image file]) && value.present?
|
||||
new_value, new_attachments = normalize_attachment_value(value, template.account, for_submitter)
|
||||
|
||||
attachments.push(*new_attachments)
|
||||
@@ -36,12 +38,26 @@ module Submitters
|
||||
value = new_value
|
||||
end
|
||||
|
||||
[key, value]
|
||||
[key, normalize_value(field, value)]
|
||||
end.to_h
|
||||
|
||||
[normalized_values, attachments]
|
||||
end
|
||||
|
||||
def normalize_value(field, value)
|
||||
if field['type'] == 'text' && value.present?
|
||||
value.to_s
|
||||
elsif field['type'] == 'date' && value.present?
|
||||
Date.parse(value).to_s
|
||||
else
|
||||
value
|
||||
end
|
||||
rescue Date::Error => e
|
||||
Rollbar.error(e) if defined?(Rollbar)
|
||||
|
||||
value
|
||||
end
|
||||
|
||||
def fetch_fields(template, submitter_name: nil, for_submitter: nil)
|
||||
if submitter_name
|
||||
submitter =
|
||||
|
||||
Reference in New Issue
Block a user