@@ -39,9 +39,9 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/swiper@12/swiper-bundle.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('alpine:init', () => {
|
||||
Alpine.store('dd', { open: false, userId: null, menuX: 0, menuY: 0, esSubvendedor: false, rolId: null, userName: '' });
|
||||
Alpine.store('openDropdown', null);
|
||||
Livewire.hook('message.received', () => {
|
||||
Alpine.store('dd').open = false;
|
||||
Alpine.store('openDropdown', null);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
editarTarifaRol: @entangle('editarTarifaRol'),
|
||||
init() {
|
||||
['editar','gestion','gestionPromo','modalSaldo','modalPassword','modTarifas','modalSaldoDesc','editarTarifaRol'].forEach(prop => {
|
||||
this.$watch(prop, () => { Alpine.store('dd').open = false; });
|
||||
this.$watch(prop, () => { Alpine.store('openDropdown', null); });
|
||||
});
|
||||
}
|
||||
}" class="h-full w-full md:my-2">
|
||||
@@ -81,7 +81,7 @@
|
||||
</x-slot>
|
||||
<x-slot name="tbody">
|
||||
@foreach ($usuarios as $usuario)
|
||||
<tr wire:key="usuario-{{ $usuario->id }}" class="border-gray-200 text-left hover:bg-purple-50 transition-colors" x-data="{ openDetails: false }">
|
||||
<tr wire:key="usuario-{{ $usuario->id }}" class="border-gray-200 text-left hover:bg-purple-50 transition-colors" x-data="{ openDetails: false, menuX: 0, menuY: 0, toggleMenu(btn){ const r = btn.getBoundingClientRect(); menuX = r.right - 160; menuY = r.bottom + 4; $store.openDropdown = ($store.openDropdown === {{ $usuario->id }}) ? null : {{ $usuario->id }}; } }">
|
||||
@if (auth()->user()->rol_id == 5)
|
||||
|
||||
<td>{{ $usuario->subvendedor_relacion->name ?? 'N/A' }}</td>
|
||||
@@ -148,19 +148,42 @@
|
||||
|
||||
@if (auth()->user()->rol->nombre == 'super')
|
||||
<td>
|
||||
<button @click="const _r=$el.getBoundingClientRect(),_was=$store.dd.open&&$store.dd.userId==={{ $usuario->id }};$store.dd.menuX=_r.right-160;$store.dd.menuY=_r.bottom+4;$store.dd.userId={{ $usuario->id }};$store.dd.esSubvendedor={{ $usuario->subvendedor ? 'true' : 'false' }};$store.dd.rolId={{ $usuario->rol_id }};$store.dd.userName=@js($usuario->name);$store.dd.open=!_was;" class="p-1 rounded-lg hover:bg-gray-100">
|
||||
<button @click="toggleMenu($el)" class="p-1 rounded-lg hover:bg-gray-100">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div x-cloak x-show="$store.openDropdown === {{ $usuario->id }} && menuX > 0" @click.away="$store.openDropdown = null" :style="`position:fixed;top:${menuY}px;left:${menuX}px;`" class="z-50 bg-white text-center w-[10rem] rounded-xl border border-gray-200 shadow-xl">
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="editar({{ $usuario->id }})" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100 hover:rounded-t-xl">Editar</button>
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="editarPassword({{ $usuario->id }})" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Editar contraseña</button>
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="saldo({{ $usuario->id }})" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Agregar saldo</button>
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="saldodesc({{ $usuario->id }})" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Descontar saldo</button>
|
||||
<button x-on:click="$store.openDropdown = null; gestion=true" wire:click="gestionar({{ $usuario->id }},'{{ $usuario->rol_id }}','{{ $usuario->name }}')" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Precio servicio</button>
|
||||
<button x-on:click="$store.openDropdown = null; gestionPromo=true" wire:click="gestionarPromociones({{ $usuario->id }},'{{ $usuario->name }}')" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Precio promoción</button>
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="eliminar({{ $usuario->id }})" class="text-white w-full py-1.5 text-sm bg-red-400 rounded-b-xl hover:bg-red-600">Eliminar</button>
|
||||
</div>
|
||||
</td>
|
||||
@elseif (Auth::user()->subvendedor && $config->subvendedor)
|
||||
<td>
|
||||
<button @click="const _r=$el.getBoundingClientRect(),_was=$store.dd.open&&$store.dd.userId==={{ $usuario->id }};$store.dd.menuX=_r.right-160;$store.dd.menuY=_r.bottom+4;$store.dd.userId={{ $usuario->id }};$store.dd.esSubvendedor={{ $usuario->subvendedor ? 'true' : 'false' }};$store.dd.rolId={{ $usuario->rol_id }};$store.dd.userName=@js($usuario->name);$store.dd.open=!_was;" class="p-1 rounded-lg hover:bg-gray-100">
|
||||
<button @click="toggleMenu($el)" class="p-1 rounded-lg hover:bg-gray-100">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6 cursor-pointer">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM12.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0zM18.75 12a.75.75 0 11-1.5 0 .75.75 0 011.5 0z" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div x-cloak x-show="$store.openDropdown === {{ $usuario->id }} && menuX > 0" @click.away="$store.openDropdown = null" :style="`position:fixed;top:${menuY}px;left:${menuX}px;`" class="z-50 bg-white text-center w-[10rem] rounded-xl border border-gray-200 shadow-xl">
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="editar({{ $usuario->id }})" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100 hover:rounded-t-xl">Editar</button>
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="editarPassword({{ $usuario->id }})" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Editar contraseña</button>
|
||||
@if ($usuario->subvendedor)
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="quitarSubvendedor({{ $usuario->id }})" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Quitar subvendedor</button>
|
||||
@else
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="ponerSubvendedor({{ $usuario->id }})" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Habilitar subvendedor</button>
|
||||
@endif
|
||||
<button x-on:click="$store.openDropdown = null; gestion=true" wire:click="gestionar({{ $usuario->id }},'{{ $usuario->rol_id }}','{{ $usuario->name }}')" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Precio servicio</button>
|
||||
<button x-on:click="$store.openDropdown = null; gestionPromo=true" wire:click="gestionarPromociones({{ $usuario->id }},'{{ $usuario->name }}')" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Precio promoción</button>
|
||||
<button x-on:click="$store.openDropdown = null" wire:click="eliminar({{ $usuario->id }})" class="text-white w-full py-1.5 text-sm bg-red-400 rounded-b-xl hover:bg-red-600">Eliminar</button>
|
||||
</div>
|
||||
</td>
|
||||
@else
|
||||
@endif
|
||||
@@ -172,35 +195,6 @@
|
||||
</x-slot>
|
||||
</x-primary-table>
|
||||
|
||||
{{-- Dropdown global: único elemento fuera del @foreach, Livewire no lo morfea --}}
|
||||
<div x-cloak
|
||||
x-show="$store.dd.open"
|
||||
@click.away="$store.dd.open = false"
|
||||
:style="`position:fixed;top:${$store.dd.menuY}px;left:${$store.dd.menuX}px;z-index:9999`"
|
||||
class="bg-white text-center w-[10rem] rounded-xl border border-gray-200 shadow-xl">
|
||||
@if (auth()->user()->rol->nombre == 'super')
|
||||
<button @click="$store.dd.open=false; $wire.editar($store.dd.userId)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100 hover:rounded-t-xl">Editar</button>
|
||||
<button @click="$store.dd.open=false; $wire.editarPassword($store.dd.userId)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Editar contraseña</button>
|
||||
<button @click="$store.dd.open=false; $wire.saldo($store.dd.userId)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Agregar saldo</button>
|
||||
<button @click="$store.dd.open=false; $wire.saldodesc($store.dd.userId)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Descontar saldo</button>
|
||||
<button @click="$store.dd.open=false; gestion=true; $wire.gestionar($store.dd.userId, $store.dd.rolId, $store.dd.userName)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Precio servicio</button>
|
||||
<button @click="$store.dd.open=false; gestionPromo=true; $wire.gestionarPromociones($store.dd.userId, $store.dd.userName)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Precio promoción</button>
|
||||
<button @click="$store.dd.open=false; $wire.eliminar($store.dd.userId)" class="text-white w-full py-1.5 text-sm bg-red-400 rounded-b-xl hover:bg-red-600">Eliminar</button>
|
||||
@elseif (Auth::user()->subvendedor && $config->subvendedor)
|
||||
<button @click="$store.dd.open=false; $wire.editar($store.dd.userId)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100 hover:rounded-t-xl">Editar</button>
|
||||
<button @click="$store.dd.open=false; $wire.editarPassword($store.dd.userId)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Editar contraseña</button>
|
||||
<template x-if="$store.dd.esSubvendedor">
|
||||
<button @click="$store.dd.open=false; $wire.quitarSubvendedor($store.dd.userId)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Quitar subvendedor</button>
|
||||
</template>
|
||||
<template x-if="!$store.dd.esSubvendedor">
|
||||
<button @click="$store.dd.open=false; $wire.ponerSubvendedor($store.dd.userId)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Habilitar subvendedor</button>
|
||||
</template>
|
||||
<button @click="$store.dd.open=false; gestion=true; $wire.gestionar($store.dd.userId, $store.dd.rolId, $store.dd.userName)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Precio servicio</button>
|
||||
<button @click="$store.dd.open=false; gestionPromo=true; $wire.gestionarPromociones($store.dd.userId, $store.dd.userName)" class="text-gray-600 w-full py-1.5 text-sm hover:bg-gray-50 border-b border-gray-100">Precio promoción</button>
|
||||
<button @click="$store.dd.open=false; $wire.eliminar($store.dd.userId)" class="text-white w-full py-1.5 text-sm bg-red-400 rounded-b-xl hover:bg-red-600">Eliminar</button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Gestionar precios --}}
|
||||
<div x-cloak x-show="gestion" x-transition:enter="transition duration-350"
|
||||
x-transition:enter-start="opacity-0 scale-100" x-transition:enter-end="opacity-100 scale-100"
|
||||
|
||||
Reference in New Issue
Block a user