Skip to content

Commit

Permalink
add field preferences param
Browse files Browse the repository at this point in the history
  • Loading branch information
omohokcoj committed Jun 9, 2024
1 parent c2ded81 commit 5ae56bd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def submissions_params
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
fields: [:name, :uuid, :default_value, :value, :title, :description,
:readonly, :redacted, :validation_pattern, :invalid_message,
{ default_value: [], value: [] }] }]]
{ default_value: [], value: [], preferences: {} }] }]]
}
]

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/submitters_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def submitter_params
{ metadata: {}, values: {}, readonly_fields: [], message: %i[subject body],
fields: [[:name, :uuid, :default_value, :value,
:readonly, :redacted, :validation_pattern, :invalid_message,
{ default_value: [], value: [] }]] }
{ default_value: [], value: [], preferences: {} }]] }
)
end

Expand Down
2 changes: 2 additions & 0 deletions lib/submissions/create_from_submitters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def assign_field_attrs(field, attrs)
end
end

field['preferences'] = (field['preferences'] || {}).merge(attrs['preferences']) if attrs['preferences'].present?

return field if attrs['validation_pattern'].blank?

field['validation'] = {
Expand Down

0 comments on commit 5ae56bd

Please sign in to comment.