fix submit form
This commit is contained in:
@@ -41,7 +41,7 @@ class SubmitFormController < ApplicationController
|
||||
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
|
||||
|
||||
@@ -21,12 +21,6 @@
|
||||
name="authenticity_token"
|
||||
:value="authenticityToken"
|
||||
>
|
||||
<input
|
||||
v-if="currentStep === stepFields.length - 1"
|
||||
type="hidden"
|
||||
name="completed"
|
||||
value="true"
|
||||
>
|
||||
<input
|
||||
value="put"
|
||||
name="_method"
|
||||
@@ -263,7 +257,7 @@
|
||||
href="#"
|
||||
class="inline border border-base-300 h-3 w-3 rounded-full mx-1"
|
||||
:class="{ 'bg-base-300': index === currentStep, 'bg-base-content': index < currentStep || isCompleted, 'bg-white': index > currentStep }"
|
||||
@click.prevent="isCompleted ? '' : goToStep(step, true)"
|
||||
@click.prevent="isCompleted ? '' : [saveStep(), goToStep(step, true)]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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) {
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
</div>
|
||||
<% if submitter && !submitter.completed_at? %>
|
||||
<div class="mt-2 mb-1">
|
||||
<a class="btn btn-sm btn-primary w-full" target="_blank" href="<%= submit_form_url(slug: submitter.slug) %>">
|
||||
<a class="btn btn-sm btn-primary w-full" target="_blank" href="<%= submit_form_path(slug: submitter.slug) %>">
|
||||
Submit Form
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -40,6 +40,8 @@ module Submissions
|
||||
|
||||
value = submitter.values[field['uuid']]
|
||||
|
||||
next if Array.wrap(value).compact_blank.blank?
|
||||
|
||||
canvas = page.canvas(type: :overlay)
|
||||
|
||||
case field['type']
|
||||
|
||||
Reference in New Issue
Block a user