Compare commits
10 commits
3509b9348f
...
5a0cf73218
Author | SHA1 | Date | |
---|---|---|---|
5a0cf73218 | |||
44bd8045b8 | |||
8a32841f9d | |||
e0bb8127f4 | |||
1610acfbe7 | |||
fff9b5b65f | |||
d64659d653 | |||
f92084d399 | |||
f4560c0be5 | |||
fe529c2242 |
10 changed files with 48 additions and 55 deletions
26
app/Http/Controllers/SessionController.php
Normal file
26
app/Http/Controllers/SessionController.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?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,16 +19,6 @@ 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
|
||||||
*/
|
*/
|
||||||
|
@ -82,16 +72,11 @@ 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 => {
|
||||||
|
@ -132,16 +117,8 @@ const app = new Vue({
|
||||||
Event.$emit("pedido-actualizado");
|
Event.$emit("pedido-actualizado");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
if (window.location.pathname.startsWith('/productos'))
|
||||||
Event.$on('aprobacion-subpedido', (subpedidoId, aprobado) => {
|
Event.$emit('obtener-sesion')
|
||||||
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,15 +4,12 @@
|
||||||
<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="this.$root.pedido != null"
|
v-if="pedidoDefinido"
|
||||||
class="hide-above-1023"
|
class="hide-above-1023"
|
||||||
id="mobile">
|
id="mobile">
|
||||||
</chismosa-dropdown>
|
</chismosa-dropdown>
|
||||||
|
@ -25,7 +22,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="this.$root.pedido != null" class="navbar-item field has-addons mt-2 mr-3">
|
<div v-if="pedidoDefinido" 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>
|
||||||
|
@ -35,7 +32,7 @@
|
||||||
@keyup.enter="buscar">
|
@keyup.enter="buscar">
|
||||||
</div>
|
</div>
|
||||||
<chismosa-dropdown
|
<chismosa-dropdown
|
||||||
v-if="this.$root.pedido != null"
|
v-if="pedidoDefinido"
|
||||||
class="hide-below-1024"
|
class="hide-below-1024"
|
||||||
id="wide">
|
id="wide">
|
||||||
</chismosa-dropdown>
|
</chismosa-dropdown>
|
||||||
|
@ -53,7 +50,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
|
import ChismosaDropdown from '../pedidos/ChismosaDropdown.vue';
|
||||||
import { mapActions } from "vuex";
|
import { mapActions, mapGetters } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { ChismosaDropdown },
|
components: { ChismosaDropdown },
|
||||||
|
@ -63,6 +60,9 @@ export default {
|
||||||
searchString: "",
|
searchString: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
...mapGetters('pedido',["pedidoDefinido"]),
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('productos', ["filtrarProductos"]),
|
...mapActions('productos', ["filtrarProductos"]),
|
||||||
toggleBurger() {
|
toggleBurger() {
|
||||||
|
@ -73,7 +73,6 @@ 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","getPedido"]),
|
...mapActions('pedido',["crearPedido"]),
|
||||||
...mapMutations('barrio',["setPedidos"]),
|
...mapMutations('barrio',["setPedidos"]),
|
||||||
onType() {
|
onType() {
|
||||||
if (!this.searchString) {
|
if (!this.searchString) {
|
||||||
|
@ -66,12 +66,11 @@ export default {
|
||||||
this.getPedidos(this.searchString);
|
this.getPedidos(this.searchString);
|
||||||
},
|
},
|
||||||
async submit() {
|
async submit() {
|
||||||
await this.crearPedido(this.searchString, this.grupo_de_compra_id);
|
await this.crearPedido({ nombre: this.searchString, grupo_de_compra_id: 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,7 +15,6 @@ 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,22 +14,17 @@
|
||||||
<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 slot="subpedido">{{ session('subpedido_nombre') ? 'Pedido de '. session('subpedido_nombre') : Auth::user()->name }}</template>
|
<template #logout-form>
|
||||||
<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,17 +59,15 @@ 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