add complete button
This commit is contained in:
@@ -39,7 +39,6 @@
|
|||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="isActive"
|
|
||||||
ref="scrollToElem"
|
ref="scrollToElem"
|
||||||
class="absolute"
|
class="absolute"
|
||||||
:style="{ top: scrollPadding }"
|
:style="{ top: scrollPadding }"
|
||||||
|
|||||||
@@ -24,6 +24,44 @@
|
|||||||
:fields="formulaFields"
|
:fields="formulaFields"
|
||||||
:values="values"
|
:values="values"
|
||||||
/>
|
/>
|
||||||
|
<Teleport
|
||||||
|
v-if="completeButtonToRef"
|
||||||
|
:to="completeButtonToRef"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
v-if="(emptyValueRequiredStep && ((stepFields.length - 1) !== currentStep || currentStepFields !== emptyValueRequiredStep)) || isCompleted"
|
||||||
|
class="tooltip-left"
|
||||||
|
:class="{ tooltip: !isCompleted }"
|
||||||
|
:data-tip="t('fill_all_required_fields_to_complete')"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
class="btn btn-sm btn-neutral text-white px-4 w-full flex justify-center btn-disabled pointer-events-auto"
|
||||||
|
@click="[isFormVisible = true, !isCompleted && goToStep(stepFields.indexOf(emptyValueRequiredStep), true, false)]"
|
||||||
|
>
|
||||||
|
{{ t('complete') }}
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
v-else
|
||||||
|
id="complete_form_button"
|
||||||
|
class="btn btn-sm btn-neutral text-white px-4 w-full flex justify-center"
|
||||||
|
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"
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
{{ t('complete') }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</Teleport>
|
||||||
<button
|
<button
|
||||||
v-if="!isFormVisible"
|
v-if="!isFormVisible"
|
||||||
id="expand_form_button"
|
id="expand_form_button"
|
||||||
@@ -74,6 +112,7 @@
|
|||||||
>
|
>
|
||||||
<form
|
<form
|
||||||
v-if="!isCompleted && !isInvite"
|
v-if="!isCompleted && !isInvite"
|
||||||
|
id="steps_form"
|
||||||
ref="form"
|
ref="form"
|
||||||
:action="submitPath"
|
:action="submitPath"
|
||||||
method="post"
|
method="post"
|
||||||
@@ -592,6 +631,11 @@ export default {
|
|||||||
required: false,
|
required: false,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
completeButtonToRef: {
|
||||||
|
type: Object,
|
||||||
|
required: false,
|
||||||
|
default: null
|
||||||
|
},
|
||||||
attachments: {
|
attachments: {
|
||||||
type: Array,
|
type: Array,
|
||||||
required: false,
|
required: false,
|
||||||
@@ -772,6 +816,7 @@ export default {
|
|||||||
phoneVerifiedValues: {},
|
phoneVerifiedValues: {},
|
||||||
orientation: screen?.orientation?.type,
|
orientation: screen?.orientation?.type,
|
||||||
isSubmitting: false,
|
isSubmitting: false,
|
||||||
|
isSubmittingComplete: false,
|
||||||
submittedValues: {},
|
submittedValues: {},
|
||||||
recalculateButtonDisabledKey: ''
|
recalculateButtonDisabledKey: ''
|
||||||
}
|
}
|
||||||
@@ -780,6 +825,13 @@ export default {
|
|||||||
isMobile () {
|
isMobile () {
|
||||||
return /android|iphone|ipad/i.test(navigator.userAgent)
|
return /android|iphone|ipad/i.test(navigator.userAgent)
|
||||||
},
|
},
|
||||||
|
emptyValueRequiredStep () {
|
||||||
|
return this.stepFields.find((fields, index) => {
|
||||||
|
return fields.some((f) => {
|
||||||
|
return f.required && isEmpty(this.values[f.uuid])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
submitButtonText () {
|
submitButtonText () {
|
||||||
if (this.alwaysMinimize) {
|
if (this.alwaysMinimize) {
|
||||||
return this.t('submit')
|
return this.t('submit')
|
||||||
@@ -1146,9 +1198,15 @@ export default {
|
|||||||
scrollIntoArea (area) {
|
scrollIntoArea (area) {
|
||||||
return this.$refs.areas.scrollIntoArea(area)
|
return this.$refs.areas.scrollIntoArea(area)
|
||||||
},
|
},
|
||||||
async submitStep () {
|
async submitStep (e) {
|
||||||
this.isSubmitting = true
|
this.isSubmitting = true
|
||||||
|
|
||||||
|
const forceComplete = e.submitter?.getAttribute('name') === 'completed'
|
||||||
|
|
||||||
|
if (forceComplete) {
|
||||||
|
this.isSubmittingComplete = true
|
||||||
|
}
|
||||||
|
|
||||||
const submitStep = this.currentStep
|
const submitStep = this.currentStep
|
||||||
|
|
||||||
const stepPromise = ['signature', 'phone', 'initials', 'payment'].includes(this.currentField.type)
|
const stepPromise = ['signature', 'phone', 'initials', 'payment'].includes(this.currentField.type)
|
||||||
@@ -1157,7 +1215,7 @@ export default {
|
|||||||
|
|
||||||
stepPromise().then(async () => {
|
stepPromise().then(async () => {
|
||||||
const emptyRequiredField = this.stepFields.find((fields, index) => {
|
const emptyRequiredField = this.stepFields.find((fields, index) => {
|
||||||
if (index >= submitStep) {
|
if (forceComplete ? index === submitStep : index >= submitStep) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1167,7 +1225,7 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const formData = new FormData(this.$refs.form)
|
const formData = new FormData(this.$refs.form)
|
||||||
const isLastStep = submitStep === this.stepFields.length - 1
|
const isLastStep = (submitStep === this.stepFields.length - 1) || forceComplete
|
||||||
|
|
||||||
if (isLastStep && !emptyRequiredField && !this.inviteSubmitters.length) {
|
if (isLastStep && !emptyRequiredField && !this.inviteSubmitters.length) {
|
||||||
formData.append('completed', 'true')
|
formData.append('completed', 'true')
|
||||||
@@ -1192,7 +1250,7 @@ export default {
|
|||||||
return Promise.reject(new Error(data.error))
|
return Promise.reject(new Error(data.error))
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextStep = (isLastStep && emptyRequiredField) || this.stepFields[submitStep + 1]
|
const nextStep = (isLastStep && emptyRequiredField) || (forceComplete ? null : this.stepFields[submitStep + 1])
|
||||||
|
|
||||||
if (nextStep) {
|
if (nextStep) {
|
||||||
if (this.alwaysMinimize) {
|
if (this.alwaysMinimize) {
|
||||||
@@ -1213,6 +1271,7 @@ export default {
|
|||||||
console.error(error)
|
console.error(error)
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.isSubmitting = false
|
this.isSubmitting = false
|
||||||
|
this.isSubmittingComplete = false
|
||||||
})
|
})
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
if (error?.message === 'Image too small') {
|
if (error?.message === 'Image too small') {
|
||||||
@@ -1222,6 +1281,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.isSubmitting = false
|
this.isSubmitting = false
|
||||||
|
this.isSubmittingComplete = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
minimizeForm () {
|
minimizeForm () {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const en = {
|
const en = {
|
||||||
complete: 'Complete',
|
complete: 'Complete',
|
||||||
|
fill_all_required_fields_to_complete: 'Fill all required fields to complete',
|
||||||
sign_and_complete: 'Sign and Complete',
|
sign_and_complete: 'Sign and Complete',
|
||||||
text: 'Text',
|
text: 'Text',
|
||||||
by_clicking_you_agree_to_the: 'By clicking "{button}", you agree to the',
|
by_clicking_you_agree_to_the: 'By clicking "{button}", you agree to the',
|
||||||
@@ -93,6 +94,7 @@ const en = {
|
|||||||
|
|
||||||
const es = {
|
const es = {
|
||||||
complete: 'Completar',
|
complete: 'Completar',
|
||||||
|
fill_all_required_fields_to_complete: 'Complete todos los campos requeridos para finalizar',
|
||||||
sign_and_complete: 'Firmar y Completar',
|
sign_and_complete: 'Firmar y Completar',
|
||||||
invite: 'Invitar',
|
invite: 'Invitar',
|
||||||
email: 'Correo electrónico',
|
email: 'Correo electrónico',
|
||||||
@@ -185,6 +187,7 @@ const es = {
|
|||||||
|
|
||||||
const it = {
|
const it = {
|
||||||
complete: 'Completa',
|
complete: 'Completa',
|
||||||
|
fill_all_required_fields_to_complete: 'Compila tutti i campi obbligatori per completare',
|
||||||
sign_and_complete: 'Firma e Completa',
|
sign_and_complete: 'Firma e Completa',
|
||||||
invite: 'Invita',
|
invite: 'Invita',
|
||||||
email: 'Email',
|
email: 'Email',
|
||||||
@@ -277,6 +280,7 @@ const it = {
|
|||||||
|
|
||||||
const de = {
|
const de = {
|
||||||
complete: 'Abschließen',
|
complete: 'Abschließen',
|
||||||
|
fill_all_required_fields_to_complete: 'Alle erforderlichen Felder ausfüllen, um abzuschließen',
|
||||||
sign_and_complete: 'Signieren und Abschließen',
|
sign_and_complete: 'Signieren und Abschließen',
|
||||||
invite: 'Einladen',
|
invite: 'Einladen',
|
||||||
email: 'E-Mail',
|
email: 'E-Mail',
|
||||||
@@ -369,6 +373,7 @@ const de = {
|
|||||||
|
|
||||||
const fr = {
|
const fr = {
|
||||||
complete: 'Terminer',
|
complete: 'Terminer',
|
||||||
|
fill_all_required_fields_to_complete: 'Veuillez remplir tous les champs obligatoires pour compléter',
|
||||||
sign_and_complete: 'Signer et Terminer',
|
sign_and_complete: 'Signer et Terminer',
|
||||||
invite: 'Inviter',
|
invite: 'Inviter',
|
||||||
email: 'Courriel',
|
email: 'Courriel',
|
||||||
@@ -461,6 +466,7 @@ const fr = {
|
|||||||
|
|
||||||
const pl = {
|
const pl = {
|
||||||
complete: 'Zakończ',
|
complete: 'Zakończ',
|
||||||
|
fill_all_required_fields_to_complete: 'Uzupełnij wszystkie wymagane pola, aby zakończyć',
|
||||||
sign_and_complete: 'Podpisz i zakończ',
|
sign_and_complete: 'Podpisz i zakończ',
|
||||||
invite: 'Zaproś',
|
invite: 'Zaproś',
|
||||||
email: 'E-mail',
|
email: 'E-mail',
|
||||||
@@ -553,6 +559,7 @@ const pl = {
|
|||||||
|
|
||||||
const uk = {
|
const uk = {
|
||||||
complete: 'Завершити',
|
complete: 'Завершити',
|
||||||
|
fill_all_required_fields_to_complete: "Заповніть всі обов'язкові поля для завершення",
|
||||||
sign_and_complete: 'Підписати і завершити',
|
sign_and_complete: 'Підписати і завершити',
|
||||||
invite: 'Запросити',
|
invite: 'Запросити',
|
||||||
email: 'Електронна пошта',
|
email: 'Електронна пошта',
|
||||||
@@ -645,6 +652,7 @@ const uk = {
|
|||||||
|
|
||||||
const cs = {
|
const cs = {
|
||||||
complete: 'Dokončit',
|
complete: 'Dokončit',
|
||||||
|
fill_all_required_fields_to_complete: 'Please complete all mandatory fields',
|
||||||
sign_and_complete: 'Podepsat a dokončit',
|
sign_and_complete: 'Podepsat a dokončit',
|
||||||
invite: 'Pozvat',
|
invite: 'Pozvat',
|
||||||
email: 'E-mail',
|
email: 'E-mail',
|
||||||
@@ -737,6 +745,7 @@ const cs = {
|
|||||||
|
|
||||||
const pt = {
|
const pt = {
|
||||||
complete: 'Completar',
|
complete: 'Completar',
|
||||||
|
preencher_todos_os_campos_obrigatórios_para_concluir: 'Preencher todos os campos obrigatórios para concluir',
|
||||||
sign_and_complete: 'Assinar e Completar',
|
sign_and_complete: 'Assinar e Completar',
|
||||||
invite: 'Convidar',
|
invite: 'Convidar',
|
||||||
email: 'E-mail',
|
email: 'E-mail',
|
||||||
@@ -829,6 +838,7 @@ const pt = {
|
|||||||
|
|
||||||
const he = {
|
const he = {
|
||||||
complete: 'השלם',
|
complete: 'השלם',
|
||||||
|
fill_all_required_fields_to_complete: 'נא למלא את כל השדות הנדרשים להשלמה',
|
||||||
sign_and_complete: 'חתום והשלם',
|
sign_and_complete: 'חתום והשלם',
|
||||||
invite: 'הזמן',
|
invite: 'הזמן',
|
||||||
email: 'דוא"ל',
|
email: 'דוא"ל',
|
||||||
@@ -922,6 +932,7 @@ const he = {
|
|||||||
|
|
||||||
const nl = {
|
const nl = {
|
||||||
complete: 'Voltooien',
|
complete: 'Voltooien',
|
||||||
|
vul_alle_verplichte_velden_in_om_te_voltooien: 'Vul alle verplichte velden in om te voltooien',
|
||||||
sign_and_complete: 'Ondertekenen en voltooien',
|
sign_and_complete: 'Ondertekenen en voltooien',
|
||||||
invite: 'Uitnodigen',
|
invite: 'Uitnodigen',
|
||||||
email: 'E-mail',
|
email: 'E-mail',
|
||||||
@@ -1015,6 +1026,7 @@ const nl = {
|
|||||||
|
|
||||||
const ar = {
|
const ar = {
|
||||||
complete: 'اكتمال',
|
complete: 'اكتمال',
|
||||||
|
fill_all_required_fields_to_complete: 'يرجى ملء جميع الحقول المطلوبة لإكمال',
|
||||||
sign_and_complete: 'التوقيع والاكتمال',
|
sign_and_complete: 'التوقيع والاكتمال',
|
||||||
invite: 'دعوة',
|
invite: 'دعوة',
|
||||||
email: 'البريد الإلكتروني',
|
email: 'البريد الإلكتروني',
|
||||||
@@ -1107,6 +1119,7 @@ const ar = {
|
|||||||
|
|
||||||
const ko = {
|
const ko = {
|
||||||
complete: '완료',
|
complete: '완료',
|
||||||
|
fill_all_required_fields_to_complete: '모든 필수 필드를 작성하여 완료하세요',
|
||||||
sign_and_complete: '서명하고 완료하기',
|
sign_and_complete: '서명하고 완료하기',
|
||||||
invite: '초대하기',
|
invite: '초대하기',
|
||||||
email: '이메일',
|
email: '이메일',
|
||||||
|
|||||||
Reference in New Issue
Block a user