refactors varios para sacar responsabilidades a la nav bar

This commit is contained in:
Alejandro Tasistro 2023-05-27 11:20:38 -03:00
parent 599d55b684
commit 2eac2a9554
4 changed files with 31 additions and 15 deletions

16
resources/js/app.js vendored
View File

@ -21,6 +21,21 @@ window.bulmaToast = require('bulma-toast');
const files = require.context('./', true, /\.vue$/i)
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
/**
* Global data
*/
Vue.prototype.$gdc = null
Vue.prototype.$pedido = {
id: null,
nombre: null,
grupo_de_compra_id: null,
created_at: null,
updated_at: null
}
Vue.prototype.$settearProducto = function(cantidad, id) {
Event.$emit("sync-subpedido", this.cant, this.producto.id);
}
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
@ -30,3 +45,4 @@ files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(
const app = new Vue({
el: '#root'
});

View File

@ -28,7 +28,7 @@
data() {
return {
visible: false,
gdc: null,
gdc: this.$gdc,
passwordVisible: false,
passwordType: "password",
}

View File

@ -21,25 +21,25 @@
</div>
<div id="nav-bar" class="navbar-menu" :class="{'is-active':isActive}">
<div class="navbar-start"></div>
<div class="navbar-end">
<div class="control mt-auto mb-auto has-icons-left margin-in-burger">
<div v-if="subpedido.id != null" class="control mt-auto mb-auto has-icons-left margin-in-burger">
<input class="input is-small" type="text" placeholder="Harina" :v-model="searchString">
<span class="icon is-small is-left">
<i class="fas fa-search"></i>
</span>
</div>
<a class="navbar-item" href="#chismosa" @click.capture="toggleChismosa">
<a v-if="subpedido.id != null" class="navbar-item" href="#chismosa" @click.capture="toggleChismosa">
<span class="icon is-small mr-1" id="chismosa">
<img class="invert-in-burger" src="/assets/chismosa.png">
</span>
<span v-text="'$' + (subpedido == null ? 0 : subpedido.total)"></span>
</a>
<a class="navbar-item"
onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
Cerrar sesión
</a>
<slot name="logout-form"></slot>
<div class="block navbar-item">
<a class="button" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
Cerrar sesión
</a>
<slot name="logout-form"></slot>
</div>
</div>
</div>
</nav>
@ -50,7 +50,7 @@
data() {
return {
isActive: false,
subpedido: null,
subpedido: this.$pedido,
searchString: ""
}
},
@ -60,9 +60,9 @@
},
actualizarSubpedido(){
axios.get("/api/subpedidos/" + this.subpedido.id)
.then(response => {
this.subpedido = response.data.data
});
.then(response => {
this.subpedido = response.data.data
});
},
toggleChismosa(){
if (this.isActive) this.toggleState()
@ -123,7 +123,7 @@ p.navbar-item:empty {
}
.margin-in-burger {
margin-left: .75rem;
margin-right: .75rem;
margin-right: 1.5rem;
}
}
</style>

View File

@ -83,7 +83,7 @@
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.$settearProducto(this.cant, this.producto.id);
this.cerrar();
}
}