Merge branch '349-poll-is-getting-created-even-if-we-do-not-enter-the-mandatory-questions-and-answers-fields-on' into 'dev'

Validate before enabling "publish" button on poll creation.

See merge request keanuapp/keanuapp-weblite!108
This commit is contained in:
N Pex 2022-07-01 09:14:06 +00:00
commit c90944d951

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>