Compare commits

..

No commits in common. "39cc35341fe00d8af5e5a8164fc5a48982f70fb0" and "546b901a05a689be0f88d64efc91af0e5db9739c" have entirely different histories.

2 changed files with 24 additions and 44 deletions

View file

@ -5,24 +5,12 @@ Vue.component('subpedido-select', {
subpedidosExistentes: [] subpedidosExistentes: []
} }
}, },
computed: {
nombresDeSubpedidos: function() {
return this.subpedidosExistentes.map(a => a.nombre.toLowerCase())
},
botonCrearDesabilitado : function() {
return !this.subpedido || this.nombresDeSubpedidos.includes(this.subpedido.toLowerCase())
}
},
props: ["gdcid"], props: ["gdcid"],
mounted() { mounted() {
console.log("ready"); console.log("ready");
}, },
methods: { methods: {
onType() { onType() {
if (!this.subpedido){
this.subpedidosExistentes = [];
return;
}
axios.get("/api/subpedidos", { axios.get("/api/subpedidos", {
params: { params: {
nombre: this.subpedido, nombre: this.subpedido,
@ -37,16 +25,14 @@ Vue.component('subpedido-select', {
nombre: this.subpedido, nombre: this.subpedido,
grupo_de_compra_id: this.gdcid grupo_de_compra_id: this.gdcid
}).then(response => { }).then(response => {
//se creo el subpedido, guardamos el subpedido en sesion //se creo el subpedido, guardamos el subpedido en sesion
this.guardarSubpedidoEnSesion(response.data); axios.post("/subpedidos/guardar_sesion", {
subpedido: response.data
}).then(response => {
window.location.href = 'productos';
});
}); });
}, }
guardarSubpedidoEnSesion(subpedido) {
axios.post("/subpedidos/guardar_sesion", {
subpedido: subpedido
}).then(response => {
window.location.href = 'productos';
});
}
} }
}); });

View file

@ -10,31 +10,25 @@
Bienvenidx a la aplicación de compras del <strong>Mercado Popular de Subsistencia</strong> Bienvenidx a la aplicación de compras del <strong>Mercado Popular de Subsistencia</strong>
</p> </p>
<subpedido-select inline-template gdcid="{{Auth::user()->grupoDeCompra->id}}"> <subpedido-select inline-template gdcid="{{Auth::user()->grupoDeCompra->id}}">
<div> <div class="block">
<label class="label">Escribí el nombre de tu familia o grupo de convivencia</label> <div class="field">
<div class="columns"> <label class="label">Escribí el nombre de tu familia o grupo de convivencia</label>
<div class="column is-two-thirds"> <div class="control">
<div class="field"> <input class="input" @input="onType" v-model="subpedido"></input>
<div class="control">
<input class="input" @input="onType" v-model="subpedido"></input>
</div>
<p class="help">Debe ser claro para que tus compas del barrio te identifiquen.</p>
</div>
</div>
<div class="column is-one-third buttons">
<button class="button is-danger" :disabled="botonCrearDesabilitado" @click="submit">Crear nuevo pedido</button>
</div> </div>
<p class="help">Intentá que sea claro como para que tus compas del barrio te identifiquen.</p>
</div> </div>
<div v-if="subpedidosExistentes.length" class="block"> <div class="buttons">
<label class="label">Si ya comenzaste a hacer tu pedido este mes, elegilo en esta lista:</label> <button class="button is-primary" @click="submit">Crear nuevo pedido</button>
<p class="help">Podés seguir escribiendo en el campo de arriba para refinar la búsqueda.</p> </div>
<div class="columns is-mobile" v-for="(subpedidoExistente, index) in subpedidosExistentes" :class="{'has-background-grey-lighter': index % 2}"> <div class="table-container">
<div class="column is-half-mobile is-two-thirds-desktop is-two-thirds-tablet"><p style="padding-top: calc(.5em - 1px); margin-bottom: .5rem" v-text="subpedidoExistente.nombre"></p></div> <table class="table is-hoverable">
<div class="buttons column is-half-mobile is-one-third-desktop is-one-third-tablet"> <tbody>
<button class="button is-danger" @click="guardarSubpedidoEnSesion(subpedidoExistente)">Continuar pedido</button> <tr v-for="subpedidoExistente in subpedidosExistentes" >
</div> <td><a v-text="subpedidoExistente.nombre" :href="subpedidoExistente.nombre"></a></td>
</div> </tr>
</div> </tbody>
</table>
</div> </div>
</div> </div>
</subpedido-select> </subpedido-select>