funcion/refactor-general #45
1 changed files with 17 additions and 19 deletions
|
@ -5,20 +5,20 @@
|
||||||
<div class="column is-two-thirds">
|
<div class="column is-two-thirds">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" @input="onType" v-model="subpedido"/>
|
<input class="input" @input="onType" v-model="searchString"/>
|
||||||
</div>
|
</div>
|
||||||
<p class="help">Debe ser claro para que tus compas del barrio te identifiquen.</p>
|
<p class="help">Debe ser claro para que tus compas del barrio te identifiquen.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-one-third buttons">
|
<div class="column is-one-third buttons">
|
||||||
<button class="button is-danger" v-show="!botonCrearDesabilitado" @click="submit">Crear nuevo pedido
|
<button class="button is-danger" v-if="!deshabilitado" @click="submit">Crear nuevo pedido
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="subpedidosExistentes.length" class="block">
|
<div v-if="pedidos.length" class="block">
|
||||||
<label class="label">Si ya comenzaste a hacer tu pedido este mes, elegilo en esta lista:</label>
|
<label class="label">Si ya comenzaste a hacer tu pedido este mes, elegilo en esta lista:</label>
|
||||||
<p class="help">Podés seguir escribiendo en el campo de arriba para refinar la búsqueda.</p>
|
<p class="help">Podés seguir escribiendo en el campo de arriba para refinar la búsqueda.</p>
|
||||||
<div class="columns is-mobile" v-for="(subpedidoExistente, index) in subpedidosExistentes"
|
<div class="columns is-mobile" v-for="(subpedidoExistente, index) in pedidos"
|
||||||
:class="{'has-background-grey-lighter': index % 2}" :key="index">
|
:class="{'has-background-grey-lighter': index % 2}" :key="index">
|
||||||
<div class="column is-half-mobile is-two-thirds-desktop is-two-thirds-tablet">
|
<div class="column is-half-mobile is-two-thirds-desktop is-two-thirds-tablet">
|
||||||
<p style="padding-top: calc(.5em - 1px); margin-bottom: .5rem"
|
<p style="padding-top: calc(.5em - 1px); margin-bottom: .5rem"
|
||||||
|
@ -37,43 +37,41 @@
|
||||||
import { mapActions, mapState } from "vuex";
|
import { mapActions, mapState } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
async mounted() {
|
||||||
|
await this.getGrupoDeCompra();
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
subpedido: null,
|
searchString: null,
|
||||||
subpedidosExistentes: []
|
pedidos: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('barrio',["grupo_de_compra_id"]),
|
...mapState('barrio',["grupo_de_compra_id"]),
|
||||||
nombresDeSubpedidos: function () {
|
deshabilitado: function () {
|
||||||
return this.subpedidosExistentes.map(a => a.nombre.toLowerCase())
|
return !this.searchString?.trim()
|
||||||
},
|
|| this.pedidos.some(p => p.nombre.toLowerCase() === this.searchString.toLowerCase())
|
||||||
botonCrearDesabilitado: function () {
|
|
||||||
return !this.subpedido || this.nombresDeSubpedidos.includes(this.subpedido.toLowerCase())
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
|
||||||
await this.getGrupoDeCompra();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('barrio',["getGrupoDeCompra"]),
|
...mapActions('barrio',["getGrupoDeCompra"]),
|
||||||
onType() {
|
onType() {
|
||||||
if (!this.subpedido) {
|
if (!this.searchString) {
|
||||||
this.subpedidosExistentes = [];
|
this.pedidos = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
axios.get("/api/subpedidos", {
|
axios.get("/api/subpedidos", {
|
||||||
params: {
|
params: {
|
||||||
nombre: this.subpedido,
|
nombre: this.searchString,
|
||||||
grupo_de_compra: this.grupo_de_compra_id
|
grupo_de_compra: this.grupo_de_compra_id
|
||||||
}
|
}
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
this.subpedidosExistentes = response.data
|
this.pedidos = response.data
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
submit() {
|
submit() {
|
||||||
axios.post("/api/subpedidos", {
|
axios.post("/api/subpedidos", {
|
||||||
nombre: this.subpedido,
|
nombre: this.searchString,
|
||||||
grupo_de_compra_id: this.grupo_de_compra_id
|
grupo_de_compra_id: this.grupo_de_compra_id
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
//se creo el subpedido
|
//se creo el subpedido
|
||||||
|
|
Loading…
Add table
Reference in a new issue