Skip to content
Snippets Groups Projects
Commit 54a952ba authored by Milan Jaros's avatar Milan Jaros
Browse files

fix

parent ab841ffa
Branches ncc_v2.2.4
No related tags found
1 merge request!1Ncc v2.2.4
......@@ -135,10 +135,12 @@ export default {
* @returns {Boolean}
*/
computedText() {
const text = this.text.replace('[n]', '').replace(']', '').split('[')[0]
if (this.mandatory) {
return this.text + ' *'
return text + ' *'
}
return this.text
return text
},
/**
......
......@@ -174,7 +174,7 @@ export default {
message += ' ' + t('forms', 'An asterisk (*) indicates mandatory questions.')
}
message += ' ' + this.logError
// message += ' ' + this.logError
return message
},
......@@ -227,7 +227,17 @@ export default {
this.$refs.submitButton.click()
},
checkQuestion(indexQ, saveIndex) {
checkAnswers(indexQ, saveIndex) {
const question = this.form.questions[indexQ]
if (saveIndex && (!this.answers[question.id])) {
showError(t('forms', 'Answer is required'))
const errorMessage = { code: 499, message: 'Answer is required' }
throw errorMessage
}
},
checkQuestion(indexQ) {
const question = this.form.questions[indexQ]
const qTextSplit1 = question.text.replace('[n]', '').replace(']', '').split('[') // [1/1][1/2][1/3]
......@@ -241,16 +251,11 @@ export default {
if (this.answers[qi]) { // "q1": None
const answers = this.answers[qi].filter(answer => answer === ai) // "q1" : [a1,a2,a3,a4]
if (!answers.length) {
if (answers.length === 0) {
continue // no answers, go to next question
} else {
return true
}
} else {
if (saveIndex) {
showError(t('forms', 'Answer is required'))
throw 'Answer is required';
}
}
}
}
......@@ -264,8 +269,9 @@ export default {
let index = this.questionIndex
if (this.checkQuestion(index)) {
if (this.checkQuestion(index, saveIndex)) {
questionsArray.push(this.form.questions[index])
this.checkAnswers(index, saveIndex)
}
while (index < this.form.questions.length - 1) {
......@@ -278,6 +284,7 @@ export default {
if (this.checkQuestion(index, saveIndex)) {
questionsArray.push(this.form.questions[index])
this.checkAnswers(index, saveIndex)
}
}
......@@ -298,8 +305,8 @@ export default {
try {
if (this.questionIndex < this.form.questions.length - 1) {
const questions = this.getQuestions(true)
logError += ' ' + questions.length
this.getQuestions(true)
const questions = this.getQuestions(false)
if (questions.length > 0) {
return
......@@ -314,10 +321,10 @@ export default {
this.questionIndex = 0
this.success = true
} catch (error) {
this.questionIndex = 0
this.logError = ' ' + error
// this.questionIndex = 0
// this.logError += ' ' + error
console.error(error)
showError(t('forms', 'There was an error submitting the form'))
showError(t('forms', 'There was an error in the form'))
} finally {
this.loading = false
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment