Compare commits
No commits in common. "5a0cf73218a0718af1f4fe1e8cdb681949f09e58" and "3509b9348f4c873c28e2c2a33bffa29ed997e987" have entirely different histories.
5a0cf73218
...
3509b9348f
10 changed files with 55 additions and 48 deletions
|
@ -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');
|
|
||||||
}
|
|
||||||
}
|
|
31
resources/js/app.js
vendored
31
resources/js/app.js
vendored
|
@ -19,6 +19,16 @@ window.bulmaToast = require('bulma-toast');
|
||||||
*/
|
*/
|
||||||
import './components';
|
import './components';
|
||||||
import store from "./store";
|
import store from "./store";
|
||||||
|
import {mapState} from "vuex";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants
|
||||||
|
*/
|
||||||
|
Vue.prototype.$rootMiga = {
|
||||||
|
nombre: "Categorías",
|
||||||
|
href: "/productos"
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global methods
|
* Global methods
|
||||||
*/
|
*/
|
||||||
|
@ -72,11 +82,16 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
Event.$on('obtener-sesion', () => {
|
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')
|
axios.get('/subpedidos/obtener_sesion')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.gdc = response.data.gdc;
|
this.gdc = response.data.gdc;
|
||||||
// this.settearDevoluciones();
|
this.settearDevoluciones();
|
||||||
this.pedido = response.data.subpedido.id;
|
this.pedido = response.data.subpedido.id;
|
||||||
axios.get('/api/subpedidos/' + this.pedido)
|
axios.get('/api/subpedidos/' + this.pedido)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
@ -117,8 +132,16 @@ const app = new Vue({
|
||||||
Event.$emit("pedido-actualizado");
|
Event.$emit("pedido-actualizado");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (window.location.pathname.startsWith('/productos'))
|
|
||||||
Event.$emit('obtener-sesion')
|
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')
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,15 @@
|
||||||
<a class="navbar-item" href="https://mps.org.uy">
|
<a class="navbar-item" href="https://mps.org.uy">
|
||||||
<img src="/assets/logoMPS.png" height="28">
|
<img src="/assets/logoMPS.png" height="28">
|
||||||
</a>
|
</a>
|
||||||
|
<!-- Styles nombre del barrio-->
|
||||||
<p class="navbar-item hide-below-1024">
|
<p class="navbar-item hide-below-1024">
|
||||||
|
<slot name="gdc"></slot>
|
||||||
</p>
|
</p>
|
||||||
<p class="navbar-item">
|
<p class="navbar-item">
|
||||||
|
<slot name="subpedido"></slot>
|
||||||
</p>
|
</p>
|
||||||
<chismosa-dropdown
|
<chismosa-dropdown
|
||||||
v-if="pedidoDefinido"
|
v-if="this.$root.pedido != null"
|
||||||
class="hide-above-1023"
|
class="hide-above-1023"
|
||||||
id="mobile">
|
id="mobile">
|
||||||
</chismosa-dropdown>
|
</chismosa-dropdown>
|
||||||
|
@ -22,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-menu" :class="{'is-active':burgerActiva}">
|
<div class="navbar-menu" :class="{'is-active':burgerActiva}">
|
||||||
<div class="navbar-end">
|
<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">
|
<a class="button is-small has-text-dark-grey" @click.capture="buscar">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<i class="fas fa-search"></i>
|
<i class="fas fa-search"></i>
|
||||||
|
@ -32,7 +35,7 @@
|
||||||
@keyup.enter="buscar">
|
@keyup.enter="buscar">
|
||||||
</div>
|
</div>
|
||||||
<chismosa-dropdown
|
<chismosa-dropdown
|
||||||
v-if="pedidoDefinido"
|
v-if="this.$root.pedido != null"
|
||||||
class="hide-below-1024"
|
class="hide-below-1024"
|
||||||
id="wide">
|
id="wide">
|
||||||
</chismosa-dropdown>
|
</chismosa-dropdown>
|
||||||
|
@ -50,7 +53,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
|
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
|
||||||
import { mapActions, mapGetters } from "vuex";
|
import { mapActions } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { ChismosaDropdown },
|
components: { ChismosaDropdown },
|
||||||
|
@ -60,9 +63,6 @@ export default {
|
||||||
searchString: "",
|
searchString: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
...mapGetters('pedido',["pedidoDefinido"]),
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('productos', ["filtrarProductos"]),
|
...mapActions('productos', ["filtrarProductos"]),
|
||||||
toggleBurger() {
|
toggleBurger() {
|
||||||
|
@ -73,6 +73,7 @@ export default {
|
||||||
this.toggleBurger();
|
this.toggleBurger();
|
||||||
this.filtrarProductos({ filtro: "nombre", valor: this.searchString });
|
this.filtrarProductos({ filtro: "nombre", valor: this.searchString });
|
||||||
Event.$emit('migas-agregar', { nombre: this.searchString });
|
Event.$emit('migas-agregar', { nombre: this.searchString });
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,7 +20,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('productos',["init"]),
|
...mapActions('productos', ["init"]),
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await this.init();
|
await this.init();
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
<nav v-if="pedidoDefinido" class="breadcrumb is-centered has-background-danger-light is-fixed-top"
|
<nav v-if="pedidoDefinido" class="breadcrumb is-centered has-background-danger-light is-fixed-top"
|
||||||
aria-label="breadcrumbs" v-show="visible">
|
aria-label="breadcrumbs" v-show="visible">
|
||||||
<ul class="mt-4">
|
<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"
|
<a :href="miga.href" v-text="miga.nombre"
|
||||||
:class="{'has-text-danger': i !== migaActiva}"></a>
|
:class="{'has-text-danger': i != migaActiva}"></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -55,7 +55,7 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('barrio',["getGrupoDeCompra","getPedidos"]),
|
...mapActions('barrio',["getGrupoDeCompra","getPedidos"]),
|
||||||
...mapActions('pedido',["crearPedido"]),
|
...mapActions('pedido',["crearPedido","getPedido"]),
|
||||||
...mapMutations('barrio',["setPedidos"]),
|
...mapMutations('barrio',["setPedidos"]),
|
||||||
onType() {
|
onType() {
|
||||||
if (!this.searchString) {
|
if (!this.searchString) {
|
||||||
|
@ -66,11 +66,12 @@ export default {
|
||||||
this.getPedidos(this.searchString);
|
this.getPedidos(this.searchString);
|
||||||
},
|
},
|
||||||
async submit() {
|
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 });
|
this.guardarSubpedidoEnSesion({ id: this.pedido_id, nombre: this.nombre });
|
||||||
},
|
},
|
||||||
elegirSubpedido(subpedido) {
|
elegirSubpedido(subpedido) {
|
||||||
//lo guardamos en sesion
|
//lo guardamos en sesion
|
||||||
|
this.getPedido(subpedido.id);
|
||||||
this.guardarSubpedidoEnSesion(subpedido);
|
this.guardarSubpedidoEnSesion(subpedido);
|
||||||
},
|
},
|
||||||
guardarSubpedidoEnSesion(subpedido) {
|
guardarSubpedidoEnSesion(subpedido) {
|
||||||
|
|
1
resources/js/store/modules/barrio.js
vendored
1
resources/js/store/modules/barrio.js
vendored
|
@ -15,6 +15,7 @@ const mutations = {
|
||||||
},
|
},
|
||||||
setPedidos(state, pedidos) {
|
setPedidos(state, pedidos) {
|
||||||
state.pedidos = pedidos;
|
state.pedidos = pedidos;
|
||||||
|
console.log(state);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
2
resources/js/store/modules/pedido.js
vendored
2
resources/js/store/modules/pedido.js
vendored
|
@ -29,7 +29,7 @@ const mutations = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const actions = {
|
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", {
|
const response = await axios.post("/api/subpedidos", {
|
||||||
nombre: nombre,
|
nombre: nombre,
|
||||||
grupo_de_compra_id: grupo_de_compra_id
|
grupo_de_compra_id: grupo_de_compra_id
|
||||||
|
|
|
@ -14,17 +14,22 @@
|
||||||
<script src="https://kit.fontawesome.com/9235d1c676.js" crossorigin="anonymous"></script>
|
<script src="https://kit.fontawesome.com/9235d1c676.js" crossorigin="anonymous"></script>
|
||||||
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
|
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
|
||||||
@yield('stylesheets')
|
@yield('stylesheets')
|
||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body class="has-navbar-fixed-top">
|
<body class="has-navbar-fixed-top">
|
||||||
<div id="root">
|
<div id="root">
|
||||||
<comunes-nav-bar>
|
<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">
|
<form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
|
||||||
@csrf
|
@csrf
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
</comunes-nav-bar>
|
</comunes-nav-bar>
|
||||||
<pedidos-nav-migas></pedidos-nav-migas>
|
<pedidos-nav-migas></pedidos-nav-migas>
|
||||||
|
|
||||||
<main id="main" class="py-4 has-top-padding">
|
<main id="main" class="py-4 has-top-padding">
|
||||||
<pedidos-cartel-pedido-aprobado></pedidos-cartel-pedido-aprobado>
|
<pedidos-cartel-pedido-aprobado></pedidos-cartel-pedido-aprobado>
|
||||||
@yield('content')
|
@yield('content')
|
||||||
|
|
|
@ -59,15 +59,17 @@ Route::middleware(['auth', 'role:barrio'])->group( function() {
|
||||||
'gdc' => session("gdc")
|
'gdc' => session("gdc")
|
||||||
];
|
];
|
||||||
})->name('obtenerSesion');
|
})->name('obtenerSesion');
|
||||||
|
|
||||||
Route::post('sesion', 'SessionController@store');
|
|
||||||
|
|
||||||
Route::get('sesion', 'SessionController@fetch');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/admin/login', 'AdminController@show')->name('admin.login');
|
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::middleware(['auth', 'role:admin_barrio'])->group( function () {
|
||||||
Route::get('/admin', 'AdminController@index')->name('admin.pedidos');
|
Route::get('/admin', 'AdminController@index')->name('admin.pedidos');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue