Optional prop generateOnInit, used in virt reg page

This commit is contained in:
2020-03-16 20:00:13 +01:00
parent 7a12c929aa
commit a702e0761a
2 changed files with 11 additions and 2 deletions

View File

@@ -119,7 +119,7 @@
</div> </div>
</div> </div>
<div v-else> <div v-else>
<RaffleGenerator @colors="setWithRandomColors" /> <RaffleGenerator @colors="setWithRandomColors" :generateOnInit="true" />
</div> </div>
</div> </div>
<br /> <br />

View File

@@ -60,6 +60,13 @@
<script> <script>
export default { export default {
props: {
generateOnInit: {
type: Boolean,
required: false,
default: false
}
},
data() { data() {
return { return {
numberOfBallots: 4, numberOfBallots: 4,
@@ -79,12 +86,14 @@ export default {
}, },
beforeMount() { beforeMount() {
this.$emit("numberOfBallots", this.numberOfBallots); this.$emit("numberOfBallots", this.numberOfBallots);
if (this.generateOnInit) {
this.generateColors();
}
}, },
watch: { watch: {
numberOfBallots: function() { numberOfBallots: function() {
this.$emit("numberOfBallots", this.numberOfBallots); this.$emit("numberOfBallots", this.numberOfBallots);
this.generateColors(); this.generateColors();
this.emitColors();
} }
}, },
methods: { methods: {