fix submit form
This commit is contained in:
@@ -41,7 +41,7 @@ class SubmitFormController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def normalized_values
|
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'
|
if params[:cast_boolean] == 'true'
|
||||||
v == 'true'
|
v == 'true'
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -21,12 +21,6 @@
|
|||||||
name="authenticity_token"
|
name="authenticity_token"
|
||||||
:value="authenticityToken"
|
:value="authenticityToken"
|
||||||
>
|
>
|
||||||
<input
|
|
||||||
v-if="currentStep === stepFields.length - 1"
|
|
||||||
type="hidden"
|
|
||||||
name="completed"
|
|
||||||
value="true"
|
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
value="put"
|
value="put"
|
||||||
name="_method"
|
name="_method"
|
||||||
@@ -263,7 +257,7 @@
|
|||||||
href="#"
|
href="#"
|
||||||
class="inline border border-base-300 h-3 w-3 rounded-full mx-1"
|
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 }"
|
: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>
|
||||||
</div>
|
</div>
|
||||||
@@ -401,13 +395,13 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
saveStep () {
|
saveStep (formData) {
|
||||||
if (this.isCompleted) {
|
if (this.isCompleted) {
|
||||||
return Promise.resolve({})
|
return Promise.resolve({})
|
||||||
} else {
|
} else {
|
||||||
return fetch(this.submitPath, {
|
return fetch(this.submitPath, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: new FormData(this.$refs.form)
|
body: formData || new FormData(this.$refs.form)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -420,7 +414,13 @@ export default {
|
|||||||
|
|
||||||
await stepPromise()
|
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]
|
const nextStep = this.stepFields[this.currentStep + 1]
|
||||||
|
|
||||||
if (nextStep) {
|
if (nextStep) {
|
||||||
|
|||||||
@@ -82,7 +82,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<% if submitter && !submitter.completed_at? %>
|
<% if submitter && !submitter.completed_at? %>
|
||||||
<div class="mt-2 mb-1">
|
<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
|
Submit Form
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ module Submissions
|
|||||||
|
|
||||||
value = submitter.values[field['uuid']]
|
value = submitter.values[field['uuid']]
|
||||||
|
|
||||||
|
next if Array.wrap(value).compact_blank.blank?
|
||||||
|
|
||||||
canvas = page.canvas(type: :overlay)
|
canvas = page.canvas(type: :overlay)
|
||||||
|
|
||||||
case field['type']
|
case field['type']
|
||||||
|
|||||||
Reference in New Issue
Block a user