fix [P-274]: В голосованиях связать клик по чекбоксу с ответом

This commit is contained in:
Denis Voinovich committed 2025-06-17 14:27:49 +03:00
1 parent 2001c03820
commit e9f36aa490
1 file changed
+16 -1
+16 -1
View File
@@ -64,7 +64,7 @@
{{ answer.employee?.fio || answer.name }}
<template v-slot:prepend="{ isSelected }">
<v-list-item-action start>
<v-list-item-action start @click.stop="toggleAnswer(question.id, answer.id)">
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
</v-list-item-action>
</template>
@@ -197,6 +197,20 @@ export default {
}
};
const toggleAnswer = (questionId, answerId) => {
const currentAnswers = result.value[questionId];
const index = currentAnswers.indexOf(answerId);
if (index === -1) {
const question = props.data.questions.find(q => q.id === questionId);
if (currentAnswers.length < question.settings.multiChoice) {
currentAnswers.push(answerId);
}
} else {
currentAnswers.splice(index, 1);
}
};
const submitVote = () => {
let voteData = []
for (let val of Object.values(result.value)) {
@@ -263,6 +277,7 @@ export default {
isCurrentQuestionAnswered,
nextStep,
prevStep,
toggleAnswer,
submitVote,
isVoteSubmitted,
result