Compare commits

..

2 commits

View file

@ -144,7 +144,7 @@ Vue.component('producto-container', {
</button>
</p>
<p class="control">
<input id="cantidad" class="input" type="number" :value=cant style="text-align: center">
<input id="cantidad" class="input" type="number" v-model.number="cant" style="text-align: center">
</p>
<p class="control">
<button class="button" @click="cant++">
@ -159,7 +159,7 @@ Vue.component('producto-container', {
</section>
<footer class="modal-card-foot">
<!-- Habría que ver si cambiar el botón cuando al cantidad es 0 -->
<button class="button is-success" @click="agregarProducto">Agregar a la chismosa</button>
<button class="button is-success" :disabled="cant <= 0" @click="agregarProducto">Agregar a la chismosa</button>
<button class="button" @click.capture="cerrar">Cancelar</button>
</footer>
</div>
@ -186,8 +186,12 @@ Vue.component('producto-container', {
Event.$emit("migas-pop");
},
agregarProducto() {
Event.$emit("sync-subpedido", this.cant, this.producto.id);
this.cerrar();
if (this.cant < 0) alert("No se puede agregar cantidades negativas")
else if (!Number.isInteger(this.cant)) alert("Las cantidades deben ser números enteros")
else {
Event.$emit("sync-subpedido", this.cant, this.producto.id);
this.cerrar();
}
}
},
mounted() {