diff --git a/app/controllers/submit_form_controller.rb b/app/controllers/submit_form_controller.rb index b7c3b26c8..8e50a483e 100644 --- a/app/controllers/submit_form_controller.rb +++ b/app/controllers/submit_form_controller.rb @@ -41,7 +41,7 @@ def completed private def normalized_values - params[:values].to_unsafe_h.transform_values do |v| + params.fetch(:values, {}).to_unsafe_h.transform_values do |v| if params[:cast_boolean] == 'true' v == 'true' else diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index 02fec9442..cf500b2ea 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -21,12 +21,6 @@ name="authenticity_token" :value="authenticityToken" > - @@ -401,13 +395,13 @@ export default { } }) }, - saveStep () { + saveStep (formData) { if (this.isCompleted) { return Promise.resolve({}) } else { return fetch(this.submitPath, { method: 'POST', - body: new FormData(this.$refs.form) + body: formData || new FormData(this.$refs.form) }) } }, @@ -420,7 +414,13 @@ export default { await stepPromise() - this.saveStep().then(response => { + const formData = new FormData(this.$refs.form) + + if (this.currentStep === this.stepFields.length - 1) { + formData.append('completed', 'true') + } + + this.saveStep(formData).then(response => { const nextStep = this.stepFields[this.currentStep + 1] if (nextStep) { diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index c392fd5dd..90c0872e8 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -82,7 +82,7 @@ <% if submitter && !submitter.completed_at? %>
- + Submit Form
diff --git a/lib/submissions/generate_result_attachments.rb b/lib/submissions/generate_result_attachments.rb index 25d77ab67..f02d516a4 100644 --- a/lib/submissions/generate_result_attachments.rb +++ b/lib/submissions/generate_result_attachments.rb @@ -40,6 +40,8 @@ def call(submitter) value = submitter.values[field['uuid']] + next if Array.wrap(value).compact_blank.blank? + canvas = page.canvas(type: :overlay) case field['type']