Compare commits

..

No commits in common. "5a0cf73218a0718af1f4fe1e8cdb681949f09e58" and "3509b9348f4c873c28e2c2a33bffa29ed997e987" have entirely different histories.

10 changed files with 55 additions and 48 deletions

View file

@ -1,26 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Subpedido;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Rule;
class SessionController extends Controller
{
public function store(Request $request) {
$grupo_de_compra_id = Auth::user()->grupo_de_compra_id;
$validated = $request->validate([
'id' => 'required',
Rule::in(Subpedido::where('grupo_de_compra_id', $grupo_de_compra_id)->pluck('id')),
]);
session()->put('pedido_id', $validated["id"]);
return response()->noContent();
}
public function fetch() {
return session('pedido_id');
}
}

29
resources/js/app.js vendored
View file

@ -19,6 +19,16 @@ window.bulmaToast = require('bulma-toast');
*/
import './components';
import store from "./store";
import {mapState} from "vuex";
/**
* Constants
*/
Vue.prototype.$rootMiga = {
nombre: "Categorías",
href: "/productos"
}
/**
* Global methods
*/
@ -72,11 +82,16 @@ const app = new Vue({
},
mounted() {
Event.$on('obtener-sesion', () => {
if (!window.location.pathname.startsWith('/admin')) {
if (window.location.pathname.startsWith('/admin')) {
axios.get('/admin/obtener_sesion')
.then(response => {
this.gdc = response.data.gdc
});
} else {
axios.get('/subpedidos/obtener_sesion')
.then(response => {
this.gdc = response.data.gdc;
// this.settearDevoluciones();
this.settearDevoluciones();
this.pedido = response.data.subpedido.id;
axios.get('/api/subpedidos/' + this.pedido)
.then(response => {
@ -117,7 +132,15 @@ const app = new Vue({
Event.$emit("pedido-actualizado");
});
});
if (window.location.pathname.startsWith('/productos'))
Event.$on('aprobacion-subpedido', (subpedidoId, aprobado) => {
axios.post("/api/admin/subpedidos/" + subpedidoId + "/aprobacion", {
aprobacion: aprobado
}).then((response) => {
Event.$emit('sync-aprobacion', response.data.data);
this.$toast('Pedido ' + (aprobado ? 'aprobado' : 'desaprobado') + ' exitosamente')
})
})
Event.$emit('obtener-sesion')
},
});

View file

@ -4,12 +4,15 @@
<a class="navbar-item" href="https://mps.org.uy">
<img src="/assets/logoMPS.png" height="28">
</a>
<!-- Styles nombre del barrio-->
<p class="navbar-item hide-below-1024">
<slot name="gdc"></slot>
</p>
<p class="navbar-item">
<slot name="subpedido"></slot>
</p>
<chismosa-dropdown
v-if="pedidoDefinido"
v-if="this.$root.pedido != null"
class="hide-above-1023"
id="mobile">
</chismosa-dropdown>
@ -22,7 +25,7 @@
</div>
<div class="navbar-menu" :class="{'is-active':burgerActiva}">
<div class="navbar-end">
<div v-if="pedidoDefinido" class="navbar-item field has-addons mt-2 mr-3">
<div v-if="this.$root.pedido != null" class="navbar-item field has-addons mt-2 mr-3">
<a class="button is-small has-text-dark-grey" @click.capture="buscar">
<span class="icon">
<i class="fas fa-search"></i>
@ -32,7 +35,7 @@
@keyup.enter="buscar">
</div>
<chismosa-dropdown
v-if="pedidoDefinido"
v-if="this.$root.pedido != null"
class="hide-below-1024"
id="wide">
</chismosa-dropdown>
@ -50,7 +53,7 @@
<script>
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
import { mapActions, mapGetters } from "vuex";
import { mapActions } from "vuex";
export default {
components: { ChismosaDropdown },
@ -60,9 +63,6 @@ export default {
searchString: "",
}
},
computed: {
...mapGetters('pedido',["pedidoDefinido"]),
},
methods: {
...mapActions('productos', ["filtrarProductos"]),
toggleBurger() {
@ -73,6 +73,7 @@ export default {
this.toggleBurger();
this.filtrarProductos({ filtro: "nombre", valor: this.searchString });
Event.$emit('migas-agregar', { nombre: this.searchString });
}
},
};

View file

@ -20,7 +20,7 @@ export default {
}
},
methods: {
...mapActions('productos',["init"]),
...mapActions('productos', ["init"]),
},
async mounted() {
await this.init();

View file

@ -2,9 +2,9 @@
<nav v-if="pedidoDefinido" class="breadcrumb is-centered has-background-danger-light is-fixed-top"
aria-label="breadcrumbs" v-show="visible">
<ul class="mt-4">
<li v-for="(miga, i) in migas" :key="i" :class="{'is-active': i === migaActiva}">
<li v-for="(miga, i) in migas" :key="i" :class="{'is-active': i == migaActiva}">
<a :href="miga.href" v-text="miga.nombre"
:class="{'has-text-danger': i !== migaActiva}"></a>
:class="{'has-text-danger': i != migaActiva}"></a>
</li>
</ul>
</nav>

View file

@ -55,7 +55,7 @@ export default {
},
methods: {
...mapActions('barrio',["getGrupoDeCompra","getPedidos"]),
...mapActions('pedido',["crearPedido"]),
...mapActions('pedido',["crearPedido","getPedido"]),
...mapMutations('barrio',["setPedidos"]),
onType() {
if (!this.searchString) {
@ -66,11 +66,12 @@ export default {
this.getPedidos(this.searchString);
},
async submit() {
await this.crearPedido({ nombre: this.searchString, grupo_de_compra_id: this.grupo_de_compra_id });
await this.crearPedido(this.searchString, this.grupo_de_compra_id);
this.guardarSubpedidoEnSesion({ id: this.pedido_id, nombre: this.nombre });
},
elegirSubpedido(subpedido) {
//lo guardamos en sesion
this.getPedido(subpedido.id);
this.guardarSubpedidoEnSesion(subpedido);
},
guardarSubpedidoEnSesion(subpedido) {

View file

@ -15,6 +15,7 @@ const mutations = {
},
setPedidos(state, pedidos) {
state.pedidos = pedidos;
console.log(state);
},
};

View file

@ -29,7 +29,7 @@ const mutations = {
};
const actions = {
async crearPedido({ commit }, { nombre, grupo_de_compra_id }) {
async crearPedido({ commit }, nombre, grupo_de_compra_id) {
const response = await axios.post("/api/subpedidos", {
nombre: nombre,
grupo_de_compra_id: grupo_de_compra_id

View file

@ -14,17 +14,22 @@
<script src="https://kit.fontawesome.com/9235d1c676.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
@yield('stylesheets')
</head>
<body class="has-navbar-fixed-top">
<div id="root">
<comunes-nav-bar>
<template #logout-form>
<template slot="subpedido">{{ session('subpedido_nombre') ? 'Pedido de '. session('subpedido_nombre') : Auth::user()->name }}</template>
<template slot="gdc">{{ session('subpedido_nombre') ? Auth::user()->name : "" }}</template>
<template slot="logout-form">
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
@csrf
</form>
</template>
</comunes-nav-bar>
<pedidos-nav-migas></pedidos-nav-migas>
<main id="main" class="py-4 has-top-padding">
<pedidos-cartel-pedido-aprobado></pedidos-cartel-pedido-aprobado>
@yield('content')

View file

@ -59,15 +59,17 @@ Route::middleware(['auth', 'role:barrio'])->group( function() {
'gdc' => session("gdc")
];
})->name('obtenerSesion');
Route::post('sesion', 'SessionController@store');
Route::get('sesion', 'SessionController@fetch');
});
});
Route::get('/admin/login', 'AdminController@show')->name('admin.login');
Route::get('/admin/obtener_sesion', function() {
return [
'gdc' => session("admin_gdc")
];
})->name('admin_obtener_sesion');
Route::middleware(['auth', 'role:admin_barrio'])->group( function () {
Route::get('/admin', 'AdminController@index')->name('admin.pedidos');