pull/718/merge
Tomasz Gasper 5 days ago committed by GitHub
commit 2bc4d6dc6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -141,11 +141,23 @@
<form
v-if="!isCompleted && !isInvite"
id="complete_form"
ref="completeForm"
class="hidden"
:action="submitPath"
method="post"
@submit.prevent="submitStep"
/>
>
<input
type="hidden"
name="authenticity_token"
:value="authenticityToken"
>
<input
value="put"
name="_method"
type="hidden"
>
</form>
<button
v-if="!isFormVisible && currentField"
id="expand_form_button"
@ -1114,7 +1126,8 @@ export default {
})
},
showCompleteButton () {
return this.completeButtonContainer && !this.isCompleted && !this.isInvite && this.isFormStarted &&
return this.completeButtonContainer && !this.isCompleted && !this.isInvite &&
(this.isFormStarted || this.stepFields.length === 0) &&
!this.stepFields.find((fields) => fields.some((f) => f.required && isEmpty(this.submittedValues[f.uuid])))
},
submitButtonText () {
@ -1614,7 +1627,7 @@ export default {
}
const currentFieldUuids = this.currentStepFields.map((f) => f.uuid)
const currentFieldType = this.currentField.type
const currentFieldType = this.currentField?.type
if (!formData && !this.$refs.form.checkValidity() && currentFieldUuids.every((fieldUuid) => isEmpty(this.submittedValues[fieldUuid]) || !isEmpty(this.values[fieldUuid]))) {
return
@ -1667,7 +1680,7 @@ export default {
const submitStepIndex = this.currentStep
const stepPromise = ['signature', 'phone', 'initials', 'payment', 'verification', 'kba'].includes(this.currentField.type)
const stepPromise = ['signature', 'phone', 'initials', 'payment', 'verification', 'kba'].includes(this.currentField?.type)
? this.$refs.currentStep.submit
: () => Promise.resolve({})
@ -1682,7 +1695,7 @@ export default {
})
})
const formData = new FormData(this.$refs.form)
const formData = new FormData(this.$refs.form || this.$refs.completeForm)
const isLastStep = (this.onlyRequiredFields ? !this.findNextStep(submitStepIndex) : (submitStepIndex === this.stepFields.length - 1)) || forceComplete
if (isLastStep && !emptyRequiredField && !this.inviteSubmitters.length && !this.optionalInviteSubmitters.length) {

@ -33,7 +33,9 @@
</button>
</modal-button>
<% end %>
<% unless @submitter.viewer? %>
<span id="complete_button_container" class="peer contents"></span>
<% end %>
<% if @form_configs[:with_delegate] && !@submitter.viewer? %>
<modal-button data-target="<%= delegate_modal_id = SecureRandom.uuid %>" class="hidden peer-empty:flex">
<button id="delegate_button" type="button" class="btn btn-sm !px-5"><%= t(:delegate) %></button>
@ -84,7 +86,9 @@
</button>
</modal-button>
<% end %>
<% unless @submitter.viewer? %>
<span id="complete_button_container_scroll" class="peer contents"></span>
<% end %>
<% if @form_configs[:with_delegate] && !@submitter.viewer? %>
<modal-button data-target="<%= delegate_modal_id %>" class="hidden peer-empty:flex">
<button id="delegate_button_mobile" type="button" class="btn btn-sm px-0" aria-label="<%= t(:delegate) %>">

@ -1317,6 +1317,29 @@ RSpec.describe 'Signing Form' do
expect(submitter.completed_at).to be_present
expect(field_value(submitter, 'First Name')).to eq 'John Doe'
end
it 'completes a form containing only readonly fields' do
template.fields.each do |field|
field['readonly'] = true
field['default_value'] = "Default #{field['name']}"
end
template.save!
submission.update!(template_fields: template.fields)
visit submit_form_path(slug: submitter.slug)
expect(page).to have_css('#complete_button_container button')
find('#complete_button_container button').click
expect(page).to have_content('Form has been completed!')
submitter.reload
expect(submitter.completed_at).to be_present
expect(field_value(submitter, 'First Name')).to eq 'Default First Name'
expect(field_value(submitter, 'Birthday')).to eq 'Default Birthday'
end
end
context 'when a view-only party opens the form' do
@ -1339,6 +1362,7 @@ RSpec.describe 'Signing Form' do
expect(page).to have_content(template.name)
expect(page).to have_no_css('#form_container')
expect(page).to have_no_css('#complete_button_container')
end
end
end

Loading…
Cancel
Save