several improvements

This commit is contained in:
thilo 2020-03-22 00:33:29 +01:00
parent b96a76ba75
commit e9080ead15
5 changed files with 21 additions and 6 deletions

View file

@ -4,6 +4,15 @@
</div>
</template>
<script>
export default {
mounted() {
this.$store.commit("init")
},
}
</script>
<style>
@font-face {
font-family: 'Zilla Slab';

View file

@ -29,7 +29,7 @@
v-on:click="answerQuestion(answer.value)">{{ answer.text }}</button>
</div>
<router-link to="/questionnaire/help" style="text-decoration: none"><button class="alert">Ich brauche Hilfe zu dieser Frage</button></router-link>
<svg v-on:click="goBack()" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="48" height="48"><path fill="none" d="M0 0h24v24H0z"/><path d="M8 11.333l10.223-6.815a.5.5 0 0 1 .777.416v14.132a.5.5 0 0 1-.777.416L8 12.667V19a1 1 0 0 1-2 0V5a1 1 0 1 1 2 0v6.333z"/></svg>
<svg v-if="$store.state.currentQuestion != 0" v-on:click="goBack()" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="48" height="48"><path fill="none" d="M0 0h24v24H0z"/><path d="M8 11.333l10.223-6.815a.5.5 0 0 1 .777.416v14.132a.5.5 0 0 1-.777.416L8 12.667V19a1 1 0 0 1-2 0V5a1 1 0 1 1 2 0v6.333z"/></svg>
</div>
</template>
@ -53,8 +53,14 @@
},
goBack() {
this.$store.commit('previousQuestion')
}
},
},
mounted () {
document.addEventListener("backbutton", this.goBack, false);
},
beforeDestroy () {
document.removeEventListener("backbutton", this.goBack);
}
}
</script>

View file

@ -26,6 +26,9 @@ export default new Vuex.Store({
this.state.currentQuestion -= 1
}
},
startWithFirstQuestion() {
this.state.currentQuestion = 0
},
answerQuestion(state, value) {
this.state.answers[this.state.currentQuestion] = value
},

View file

@ -15,9 +15,6 @@
export default {
name: "Questionnaire",
components: {Question},
mounted() {
this.$store.commit("init")
},
methods: {
getDotClass(n) {
if (n <= this.$store.state.currentQuestion) {

View file

@ -24,6 +24,6 @@
Bereitschaftsdienst unter 116117 an.
</p>
</div>
<router-link style="text-decoration:none" to="/questionnaire"><button>Ich möchte weiter zum Test</button></router-link>
<router-link v-on:click="this.$store.commit('startWithFirstQuestion')" style="text-decoration:none" to="/questionnaire"><button>Ich möchte weiter zum Test</button></router-link>
</div>
</template>