fix default values
This commit is contained in:
@@ -621,7 +621,7 @@ export default {
|
|||||||
|
|
||||||
this.fields.forEach((field) => {
|
this.fields.forEach((field) => {
|
||||||
if (field.default_value && !field.readonly) {
|
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 () {
|
mounted () {
|
||||||
this.isTextArea = this.modelValue?.includes('\n')
|
if (this.modelValue) {
|
||||||
|
this.isTextArea = this.modelValue.toString().includes('\n')
|
||||||
|
|
||||||
if (this.isTextArea) {
|
if (this.isTextArea) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.resizeTextarea()
|
this.resizeTextarea()
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -109,8 +109,10 @@ module Submissions
|
|||||||
field['description'] = attrs['description'] if attrs['description'].present?
|
field['description'] = attrs['description'] if attrs['description'].present?
|
||||||
field['readonly'] = attrs['readonly'] if attrs.key?('readonly')
|
field['readonly'] = attrs['readonly'] if attrs.key?('readonly')
|
||||||
field['required'] = attrs['required'] if attrs.key?('required')
|
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?
|
return field if attrs['validation_pattern'].blank?
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ module Submitters
|
|||||||
|
|
||||||
next if key.blank?
|
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)
|
new_value, new_attachments = normalize_attachment_value(value, template.account, for_submitter)
|
||||||
|
|
||||||
attachments.push(*new_attachments)
|
attachments.push(*new_attachments)
|
||||||
@@ -36,12 +38,26 @@ module Submitters
|
|||||||
value = new_value
|
value = new_value
|
||||||
end
|
end
|
||||||
|
|
||||||
[key, value]
|
[key, normalize_value(field, value)]
|
||||||
end.to_h
|
end.to_h
|
||||||
|
|
||||||
[normalized_values, attachments]
|
[normalized_values, attachments]
|
||||||
end
|
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)
|
def fetch_fields(template, submitter_name: nil, for_submitter: nil)
|
||||||
if submitter_name
|
if submitter_name
|
||||||
submitter =
|
submitter =
|
||||||
|
|||||||
Reference in New Issue
Block a user