prevent from jumping to an end without completing the survey once
This commit is contained in:
parent
0877b4e30a
commit
3bd11fce38
5 changed files with 15 additions and 0 deletions
|
@ -11,6 +11,9 @@
|
|||
export default {
|
||||
mounted() {
|
||||
this.$store.commit("init")
|
||||
if (!this.$store.state.surveyCompletedOnce) {
|
||||
this.$router.push("/")
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
this.$router.push("/questionnaire/" + nextQuestion)
|
||||
}
|
||||
else {
|
||||
this.$store.commit("setSurveyCompleted")
|
||||
router.push('/results')
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ Vue.use(Vuex)
|
|||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
surveyCompletedOnce: false,
|
||||
answers: [],
|
||||
questions: []
|
||||
},
|
||||
|
@ -16,6 +17,9 @@ export default new Vuex.Store({
|
|||
answerQuestion(state, pl) {
|
||||
this.state.answers[pl.id] = pl.answer
|
||||
},
|
||||
setSurveyCompleted() {
|
||||
this.state.surveyCompletedOnce = true
|
||||
},
|
||||
init() {
|
||||
axios.get('https://avian-safeguard-214619.firebaseio.com/questions.json')
|
||||
.then(res => {
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
this.$router.push("/questionnaire/" + nextQuestion)
|
||||
}
|
||||
else {
|
||||
this.$store.commit("setSurveyCompleted")
|
||||
router.push('/results')
|
||||
}
|
||||
},
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<p class="risk-chance alert" v-if="risk >= 66">hoch</p>
|
||||
<p class="risk-chance warning" v-if="risk >= 33 && risk < 66">durchschnittlich</p>
|
||||
<p class="risk-chance success" v-if="risk < 33">niedrig</p>
|
||||
<p class="text-center"><router-link style="text-decoration:none" to="/">
|
||||
Zurück zum Anfang
|
||||
</router-link></p>
|
||||
<p v-if="bad.length > 0">Auf Folgendes sollten Sie achten:</p>
|
||||
<div v-for="card in bad" v-bind:key="card.description" class="card-advice alert">
|
||||
<div class="card-advice-title">{{ card.title }}</div>
|
||||
|
@ -114,4 +117,7 @@
|
|||
.risk-chance.alert {
|
||||
color: #E94A47;
|
||||
}
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in a new issue