Compare commits

..

3 commits

Author SHA1 Message Date
nat
2d302d0116 Arreglado bug de chismosa 2022-05-18 18:17:38 -03:00
nat
e4a08f5aed Chismosa scrollablre 2022-05-18 17:46:47 -03:00
nat
70235970ab comenzamos 2022-05-04 16:50:22 -03:00
8 changed files with 47 additions and 32 deletions

View file

@ -80,7 +80,7 @@ class SubpedidoController extends Controller
$producto = Producto::find($valid['producto_id']); $producto = Producto::find($valid['producto_id']);
$subpedido->syncProducto($producto, $valid['cantidad']); $subpedido->syncProducto($producto, $valid['cantidad']);
return $subpedido; return new SubpedidoResource($subpedido);
} }
} }

22
public/css/app.css vendored
View file

@ -21,13 +21,33 @@ nav.breadcrumb.is-fixed-top {
right: 0; right: 0;
z-index: 30; z-index: 30;
top: 3.25rem; top: 3.25rem;
height: 3.25rem;
} }
main.has-top-padding { main.has-top-padding {
padding-top: 3rem !important; padding-top: 4.5rem !important;
} }
.has-text-centered { .has-text-centered {
text-align: center; text-align: center;
margin: 0 1em; margin: 0 1em;
} }
.is-fixed-top {
position: fixed;
z-index: 30;
}
.chismosa-container {
top: 6.5rem;
max-height: 21rem;
overflow-y: scroll;
overflow-x: hidden;
width: 100%;
position: fixed;
z-index: 15;
}
main.chisma-abierta {
padding-top: 25.5rem !important;
}

10
public/js/app.js vendored
View file

@ -8,7 +8,7 @@ Vue.component('nav-bar', {
<img src="/assets/logoMPS.png" height="28"> <img src="/assets/logoMPS.png" height="28">
</a> </a>
<p style="margin:0 auto" class="navbar-item"><slot name="subpedido"></slot></p> <p style="margin:0 auto" class="navbar-item"><slot name="subpedido"></slot></p>
<a class="navbar-item" href="/chismosa"> <a class="navbar-item" href="#chismosa" @click.capture="toggleChismosa">
<img style="padding:0 0.3em;" src="/assets/chismosa.png" height="28"> <img style="padding:0 0.3em;" src="/assets/chismosa.png" height="28">
<p style="margin:0 auto; color:white">$ <span v-text="subpedido == null ? 0 : subpedido.total"></span></p> <p style="margin:0 auto; color:white">$ <span v-text="subpedido == null ? 0 : subpedido.total"></span></p>
</a> </a>
@ -47,6 +47,9 @@ Vue.component('nav-bar', {
.then(response => { .then(response => {
this.subpedido = response.data.data; this.subpedido = response.data.data;
}); });
},
toggleChismosa(){
Event.$emit("toggle-chismosa");
} }
}, mounted() { }, mounted() {
axios.get("/subpedidos/obtener_sesion").then(response => { axios.get("/subpedidos/obtener_sesion").then(response => {
@ -58,7 +61,9 @@ Vue.component('nav-bar', {
axios.post("/api/subpedidos/"+this.subpedido.id+"/sync", { axios.post("/api/subpedidos/"+this.subpedido.id+"/sync", {
cantidad: cantidad, cantidad: cantidad,
producto_id: id producto_id: id
}).then(() => { }).then((response) => {
this.subpedido = response.data.data;
Event.$emit('sync-chismosa',this.subpedido);
bulmaToast.toast({ bulmaToast.toast({
message: 'Pedido actualizado exitosamente', message: 'Pedido actualizado exitosamente',
duration: 1000, duration: 1000,
@ -66,7 +71,6 @@ Vue.component('nav-bar', {
position: 'bottom-center', position: 'bottom-center',
animate: { in: 'fadeIn', out: 'fadeOut' } animate: { in: 'fadeIn', out: 'fadeOut' }
}); });
this.actualizarSubpedido();
}); });
}); });
} }

24
public/js/chismosa.js vendored
View file

@ -1,6 +1,6 @@
Vue.component('chismosa', { Vue.component('chismosa', {
template: ` template: `
<div class="container"> <div class="container table-container chismosa-container is-max-widescreen is-max-desktop animate__animated" :class="animation" v-show="!init">
<table v-show="this.subpedido.productos.length != 0" class="table is-fullwidth is-striped is-bordered"> <table v-show="this.subpedido.productos.length != 0" class="table is-fullwidth is-striped is-bordered">
<thead> <thead>
<tr> <tr>
@ -39,22 +39,19 @@ Vue.component('chismosa', {
subpedido: { subpedido: {
productos:[] productos:[]
}, },
init: true,
visible: false
} }
}, },
computed: { computed: {
/* TODO: tener el camino que se había hecho antes de abrir la chismosa para volver atrás */ animation: function() {
miga: function() { return this.visible ? "animate__slideInDown" : "animate__slideOutUp";
return {
nombre: "Chismosa de " + this.subpedido.nombre,
href: "/chismosa"
}
} }
}, },
beforeCreate() { beforeCreate() {
axios.get("/subpedidos/obtener_sesion").then(response => { axios.get("/subpedidos/obtener_sesion").then(response => {
this.subpedido = response.data.subpedido; this.subpedido = response.data.subpedido;
this.fetchSubpedido(); this.fetchSubpedido();
Event.$emit("migas-agregar",this.miga);
}); });
}, },
methods: { methods: {
@ -66,8 +63,15 @@ Vue.component('chismosa', {
} }
}, },
mounted() { mounted() {
Event.$on('sync-subpedido', () => { Event.$on('sync-chismosa', (subpedido) => {
this.fetchSubpedido(); this.subpedido = subpedido;
});
Event.$on('toggle-chismosa', () => {
this.init = false;
this.visible = !this.visible;
var main = document.getElementById("main");
if (this.visible) main.classList.add("chisma-abierta");
else main.classList.remove("chisma-abierta");
}); });
} }
}); });

View file

@ -160,7 +160,7 @@ Vue.component('producto-container', {
</section> </section>
<footer class="modal-card-foot"> <footer class="modal-card-foot">
<!-- Habría que ver si cambiar el botón cuando al cantidad es 0 --> <!-- Habría que ver si cambiar el botón cuando al cantidad es 0 -->
<button class="button is-success" :disabled="cant <= 0" @click="agregarProducto">Agregar a la chismosa</button> <button class="button is-success" :disabled="cant <= 0" @click="agregarProducto">Aceptar</button>
<button class="button" @click.capture="cerrar">Cancelar</button> <button class="button" @click.capture="cerrar">Cancelar</button>
</footer> </footer>
</div> </div>

View file

@ -1,15 +0,0 @@
@extends('layouts.app')
@section('stylesheets')
@endsection
@section('content')
<chismosa></chismosa>
<producto-container></producto-container>
@endsection
@section('scripts')
<script src="{{ asset('js/chismosa.js') }}"></script>
<script src="{{ asset('js/productos.js') }}"></script>
@endsection

View file

@ -40,7 +40,7 @@
</nav> </nav>
</nav-migas> </nav-migas>
<main class="py-4 has-top-padding"> <main id="main" class="py-4 has-top-padding">
@yield('content') @yield('content')
</main> </main>
</div> </div>

View file

@ -5,6 +5,7 @@
@endsection @endsection
@section('content') @section('content')
<chismosa></chismosa>
<categorias-container></categorias-container> <categorias-container></categorias-container>
<productos-container></productos-container> <productos-container></productos-container>
<producto-container></producto-container> <producto-container></producto-container>
@ -12,4 +13,5 @@
@section('scripts') @section('scripts')
<script src="{{ asset('js/productos.js') }}"></script> <script src="{{ asset('js/productos.js') }}"></script>
<script src="{{ asset('js/chismosa.js') }}"></script>
@endsection @endsection