Skip to content

Commit 99fff4b

Browse files
authored
Add questions prop validator, fix empty questions array error, don't load submit screen if questions array is empty
1 parent 1304d9e commit 99fff4b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/components/FlowForm.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
</a>
114114
</div>
115115
<div v-if="timer" class="f-timer">
116-
<span>{{ formatTime(time) }}</span>
116+
<span>{{ formatTime(time) }}</span>
117117
</div>
118118
</div>
119119
</div>
@@ -128,6 +128,7 @@
128128
*/
129129
130130
import FlowFormQuestion from './Question.vue'
131+
import QuestionModel from '../models/QuestionModel'
131132
import LanguageModel from '../models/LanguageModel'
132133
import { IsMobile } from '../mixins/IsMobile'
133134
@@ -138,7 +139,10 @@
138139
},
139140
140141
props: {
141-
questions: Array,
142+
questions:{
143+
type: Array,
144+
validator: value => value.every(q => q instanceof QuestionModel)
145+
},
142146
language: {
143147
type: LanguageModel,
144148
default: () => new LanguageModel()
@@ -242,7 +246,7 @@
242246
},
243247
244248
isOnLastStep() {
245-
return this.activeQuestionIndex === this.questionListActivePath.length
249+
return this.numActiveQuestions > 0 && this.activeQuestionIndex === this.questionListActivePath.length
246250
},
247251
248252
isOnTimerStartStep() {
@@ -293,6 +297,11 @@
293297
*/
294298
setQuestionListActivePath() {
295299
const questions = []
300+
301+
if (!this.questions.length) {
302+
return
303+
}
304+
296305
let
297306
index = 0,
298307
serialIndex = 0,

0 commit comments

Comments
 (0)