Validate before enabling "publish" button on poll creation.

This commit is contained in:
N-Pex 2022-07-01 11:09:30 +02:00 committed by n8fr8
parent 9219f1f465
commit ece3606aa2

View file

@ -44,7 +44,7 @@
:class="{ deletable: pollAnswers.length > 1 }" :class="{ deletable: pollAnswers.length > 1 }"
ref="answerInput" ref="answerInput"
> >
<v-btn v-if="pollAnswers.length > 0" icon @click="removeAnswer(index)"><v-icon>delete</v-icon></v-btn> <v-btn v-if="pollAnswers.length > 1" icon @click="removeAnswer(index)"><v-icon>delete</v-icon></v-btn>
</InputControl> </InputControl>
</v-col> </v-col>
</v-row> </v-row>
@ -72,7 +72,7 @@
block block
class="filled-button publish-button" class="filled-button publish-button"
@click.stop="onCreatePoll()" @click.stop="onCreatePoll()"
:disabled="isCreating" :disabled="isCreating || !publishButtonEnabled"
>{{ $t("poll_create.create") }}</v-btn >{{ $t("poll_create.create") }}</v-btn
> >
</v-col> </v-col>
@ -197,6 +197,11 @@ export default {
} }
}, },
}, },
computed: {
publishButtonEnabled() {
return this.pollQuestion && this.pollAnswers.length > 0 && this.pollAnswers.every(a => a.text);
}
},
components: { InputControl }, components: { InputControl },
}; };
</script> </script>