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) const files = require.context('./', true, /\.vue$/i)
files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default)) 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 * Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application * 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({ const app = new Vue({
el: '#root' el: '#root'
}); });

View File

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

View File

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

View File

@ -83,7 +83,7 @@
if (this.cant < 0) alert("No se puede agregar cantidades negativas") 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 if (!Number.isInteger(this.cant)) alert("Las cantidades deben ser números enteros")
else { else {
Event.$emit("sync-subpedido", this.cant, this.producto.id); this.$settearProducto(this.cant, this.producto.id);
this.cerrar(); this.cerrar();
} }
} }