From 552866204f1a3f005bce3a9769033b72b42b54e3 Mon Sep 17 00:00:00 2001 From: Simon C Date: Wed, 6 Apr 2022 14:29:04 +0200 Subject: [PATCH] fix: Lors de la selection d'une image le bouton radio doit changer --- .drone.yml | 4 ++-- src/components/Question.vue | 13 ++++++------- src/components/Score.vue | 9 ++++++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index f82e562..e6c1148 100644 --- a/.drone.yml +++ b/.drone.yml @@ -46,7 +46,7 @@ steps: commands: - npm i - npm run fetchData - # - npm run lint + - npm run lint - npm run build - name: push docker image on registry @@ -87,7 +87,7 @@ steps: commands: - npm i - npm run fetchData - # - npm run lint + - npm run lint - npm run build - name: push docker image on registry diff --git a/src/components/Question.vue b/src/components/Question.vue index e951d0b..ec8c4e5 100644 --- a/src/components/Question.vue +++ b/src/components/Question.vue @@ -9,13 +9,10 @@ const props = defineProps({ required: true, }, }); -defineEmits(["answerSelected"]); +const emits = defineEmits(["answerSelected", "nextQuestion"]); const slides = ref(); -if (props.question.weight == null) { - props.question.weight = props.question.answers[0].weight; -} const answerWeight = ref(props.question.weight); function selectAnswer(answer) { @@ -26,7 +23,8 @@ function selectAnswer(answer) { } function slideMove(splide, newIndex) { - props.question.weight = props.question.answers[newIndex].weight; + answerWeight.value = props.question.answers[newIndex].weight; + emits("answerSelected", props.question, answerWeight); } @@ -43,7 +41,8 @@ function slideMove(splide, newIndex) { :name="`question_${question.id}`" :value="answer.weight" v-model="answerWeight" - @click="selectAnswer(answer)" + @change="selectAnswer(answer)" + @click="nextQuestion" /> {{ answer.title }} @@ -61,7 +60,7 @@ function slideMove(splide, newIndex) { diff --git a/src/components/Score.vue b/src/components/Score.vue index 4d4d190..65c9cb6 100644 --- a/src/components/Score.vue +++ b/src/components/Score.vue @@ -104,6 +104,9 @@ function goQuestionSlide(question) { } function answerSelected(question, answerWeight) { questions.value.find((q) => q.id === question.id).weight = answerWeight; +} + +function nextQuestion() { setTimeout(() => slides.value.go(">"), 100); } @@ -125,7 +128,11 @@ function answerSelected(question, answerWeight) { }" > - +