diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue
index f231e3d4..d84a9ea5 100644
--- a/app/javascript/submission_form/form.vue
+++ b/app/javascript/submission_form/form.vue
@@ -297,6 +297,7 @@
+
+ {{ t('please_fill_all_required_fields') }}
+
@@ -457,9 +464,11 @@ export default {
return {
isCompleted: false,
isFormVisible: true,
+ showFillAllRequiredFields: false,
currentStep: 0,
isSubmitting: false,
submittedValues: {},
+ isSecondWalkthrough: false,
recalculateButtonDisabledKey: ''
}
},
@@ -514,10 +523,20 @@ export default {
this.submittedValues = JSON.parse(JSON.stringify(this.values))
if (this.goToLast) {
- this.currentStep = Math.min(
- this.stepFields.indexOf([...this.stepFields].reverse().find((fields) => fields.some((f) => !!this.values[f.uuid]))) + 1,
- this.stepFields.length - 1
- )
+ const requiredEmptyStepIndex = this.stepFields.indexOf(this.stepFields.find((fields) => fields.some((f) => f.required && !this.values[f.uuid])))
+ const lastFilledStepIndex = this.stepFields.indexOf([...this.stepFields].reverse().find((fields) => fields.some((f) => !!this.values[f.uuid]))) + 1
+
+ const indexesList = [this.stepFields.length - 1]
+
+ if (requiredEmptyStepIndex !== -1) {
+ indexesList.push(requiredEmptyStepIndex)
+ }
+
+ if (lastFilledStepIndex !== -1) {
+ indexesList.push(lastFilledStepIndex)
+ }
+
+ this.currentStep = Math.min(...indexesList)
}
if (/iPhone|iPad|iPod/i.test(navigator.userAgent)) {
@@ -608,6 +627,7 @@ export default {
},
goToStep (step, scrollToArea = false, clickUpload = false) {
this.currentStep = this.stepFields.indexOf(step)
+ this.showFillAllRequiredFields = false
this.$nextTick(() => {
this.recalculateButtonDisabledKey = Math.random()
@@ -642,12 +662,13 @@ export default {
stepPromise().then(async () => {
const emptyRequiredField = this.stepFields.find((fields, index) => {
- return index < this.currentStep && fields[0].required && (fields[0].type === 'phone' || !this.allowToSkip) && !this.submittedValues[fields[0].uuid]
+ return index < this.currentStep && fields[0].required && (fields[0].type === 'phone' || !this.allowToSkip || !this.isSecondWalkthrough) && !this.submittedValues[fields[0].uuid]
})
const formData = new FormData(this.$refs.form)
+ const isLastStep = this.currentStep === this.stepFields.length - 1
- if (this.currentStep === this.stepFields.length - 1 && !emptyRequiredField) {
+ if (isLastStep && !emptyRequiredField) {
formData.append('completed', 'true')
}
@@ -662,10 +683,18 @@ export default {
this.submittedValues[this.currentField.uuid] = this.values[this.currentField.uuid]
- const nextStep = emptyRequiredField || this.stepFields[this.currentStep + 1]
+ if (isLastStep) {
+ this.isSecondWalkthrough = true
+ }
+
+ const nextStep = (isLastStep && emptyRequiredField) || this.stepFields[this.currentStep + 1]
if (nextStep) {
this.goToStep(nextStep, true)
+
+ if (emptyRequiredField === nextStep) {
+ this.showFillAllRequiredFields = true
+ }
} else {
this.isCompleted = true
}
diff --git a/app/javascript/submission_form/i18n.js b/app/javascript/submission_form/i18n.js
index 5b57ed7b..3db20ffd 100644
--- a/app/javascript/submission_form/i18n.js
+++ b/app/javascript/submission_form/i18n.js
@@ -29,6 +29,7 @@ const en = {
sending: 'Sending...',
resend_code: 'Re-send code',
verification_code_has_been_resent: 'Verification code has been re-sent via SMS',
+ please_fill_all_required_fields: 'Please fill all required fields',
email_has_been_sent: 'Email has been sent'
}
@@ -63,6 +64,7 @@ const es = {
sending: 'Enviando...',
resend_code: 'Reenviar código',
verification_code_has_been_resent: 'El código de verificación ha sido reenviado por SMS',
+ please_fill_all_required_fields: 'Por favor, complete todos los campos obligatorios',
email_has_been_sent: 'El correo electrónico ha sido enviado'
}
@@ -97,6 +99,7 @@ const it = {
sending: 'Invio in corso...',
resend_code: 'Rinvia codice',
verification_code_has_been_resent: 'Il codice di verifica è stato rinviato tramite SMS',
+ please_fill_all_required_fields: 'Si prega di compilare tutti i campi obbligatori',
email_has_been_sent: "L'email è stata inviata"
}
@@ -131,6 +134,7 @@ const de = {
sending: 'Senden...',
resend_code: 'Code erneut senden',
verification_code_has_been_resent: 'Die Verifizierungscode wurde erneut per SMS gesendet',
+ please_fill_all_required_fields: 'Bitte füllen Sie alle erforderlichen Felder aus',
email_has_been_sent: 'Die E-Mail wurde gesendet'
}
@@ -165,6 +169,7 @@ const fr = {
sending: 'Envoi en cours...',
resend_code: 'Renvoyer le code',
verification_code_has_been_resent: 'Le code de vérification a été renvoyé par SMS',
+ please_fill_all_required_fields: 'Veuillez remplir tous les champs obligatoires',
email_has_been_sent: "L'email a été envoyé"
}
@@ -199,6 +204,7 @@ const pl = {
sending: 'Wysyłanie...',
resend_code: 'Ponownie wyślij kod',
verification_code_has_been_resent: 'Kod weryfikacyjny został ponownie wysłany',
+ please_fill_all_required_fields: 'Proszę wypełnić wszystkie wymagane pola',
email_has_been_sent: 'E-mail został wysłany'
}
@@ -233,6 +239,7 @@ const uk = {
sending: 'Надсилаю...',
resend_code: 'Повторно відправити код',
verification_code_has_been_resent: 'Код підтвердження був повторно надісланий',
+ please_fill_all_required_fields: "Будь ласка, заповніть всі обов'язкові поля",
email_has_been_sent: 'Електронний лист був відправлений'
}
@@ -267,6 +274,7 @@ const cs = {
sending: 'Odesílání...',
resend_code: 'Znovu odeslat kód',
verification_code_has_been_resent: 'Ověřovací kód byl znovu odeslán',
+ please_fill_all_required_fields: 'Prosím vyplňte všechny povinné položky',
email_has_been_sent: 'E-mail byl odeslán'
}
@@ -301,6 +309,7 @@ const pt = {
sending: 'Enviando...',
resend_code: 'Reenviar código',
verification_code_has_been_resent: 'O código de verificação foi reenviado via SMS',
+ please_fill_all_required_fields: 'Por favor, preencha todos os campos obrigatórios',
email_has_been_sent: 'Email enviado'
}