add complete button to signing form header

This commit is contained in:
Alex Turchyn
2026-05-07 16:49:03 +03:00
committed by Pete Matsyburka
parent a7891f89f8
commit 04129ded90
4 changed files with 132 additions and 27 deletions
+5 -1
View File
@@ -52,7 +52,11 @@ safeRegisterElement('submission-form', class extends HTMLElement {
completedMessage: JSON.parse(this.dataset.completedMessage || '{}'),
completedRedirectUrl: this.dataset.completedRedirectUrl,
attachments: reactive(JSON.parse(this.dataset.attachments)),
fields: JSON.parse(this.dataset.fields)
fields: JSON.parse(this.dataset.fields),
completeButtonRef: document.getElementById('complete_button_container'),
completeButtonMobileRef: document.getElementById('complete_button_container_mobile'),
declineButtonRef: document.getElementById('decline_button')?.closest('modal-button'),
declineButtonMobileRef: document.getElementById('decline_button_mobile')?.closest('modal-button')
})
this.app.mount(this.appElem)
+58
View File
@@ -113,6 +113,31 @@
</span>
</button>
</Teleport>
<Teleport
v-for="ref in (canShowCompleteButton ? [completeButtonRef, completeButtonMobileRef].filter(Boolean) : [])"
:key="ref"
:to="ref"
>
<button
class="btn btn-sm btn-neutral text-white px-4"
form="steps_form"
type="submit"
name="completed"
value="true"
:disabled="isSubmittingComplete"
>
<span class="flex items-center">
<IconInnerShadowTop
v-if="isSubmittingComplete"
class="mr-1 animate-spin w-5 h-5"
aria-hidden="true"
/>
<span>
{{ t('complete') }}
</span>
</span>
</button>
</Teleport>
<button
v-if="!isFormVisible"
id="expand_form_button"
@@ -791,6 +816,26 @@ export default {
required: false,
default: null
},
completeButtonRef: {
type: Object,
required: false,
default: null
},
completeButtonMobileRef: {
type: Object,
required: false,
default: null
},
declineButtonRef: {
type: Object,
required: false,
default: null
},
declineButtonMobileRef: {
type: Object,
required: false,
default: null
},
schema: {
type: Array,
required: false,
@@ -1056,6 +1101,10 @@ export default {
})
})
},
canShowCompleteButton () {
return this.completeButtonRef && !this.emptyValueRequiredStep && !this.isCompleted && !this.isInvite &&
this.stepFields.some((fields) => fields.some((f) => !isEmpty(this.values[f.uuid])))
},
submitButtonText () {
if (this.alwaysMinimize) {
return this.t('submit')
@@ -1238,6 +1287,15 @@ export default {
this.currentStep -= 1
}
},
canShowCompleteButton: {
immediate: true,
handler (show) {
this.$nextTick(() => {
if (this.declineButtonRef) this.declineButtonRef.classList.toggle('hidden', show)
if (this.declineButtonMobileRef) this.declineButtonMobileRef.classList.toggle('hidden', show)
})
}
},
attachmentConditionsIndex: {
deep: true,
immediate: true,