creado toggle habilitar grupo y correjido un par de bugs de
modalestatico
This commit is contained in:
@@ -109,10 +109,28 @@
|
||||
modaldat = "Fallo al hacer la request";
|
||||
}
|
||||
}
|
||||
|
||||
async function togglegrupo(grupo: GrupoDto) {
|
||||
try {
|
||||
const req = await fetch($urlG + "/api/grupo?id=" + grupo.idgrupo, {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
Auth: token,
|
||||
},
|
||||
});
|
||||
if (req.ok) {
|
||||
grupo.habilitado = !grupo.habilitado;
|
||||
}
|
||||
modaldat = (await req.json()).message;
|
||||
ObtenerGrupos();
|
||||
} catch {
|
||||
modaldat = "Fallo al hacer la request";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if modaldat != ""}
|
||||
<ModalEstatico payload={modaldat} />
|
||||
<ModalEstatico payload={modaldat} close={() => !!(modaldat = "")} />
|
||||
{/if}
|
||||
|
||||
{#if showModal}
|
||||
@@ -157,6 +175,14 @@
|
||||
aria-controls={grupo.idgrupo}
|
||||
>
|
||||
{grupo.nombre}
|
||||
<span
|
||||
class="ms-1 badge text-bg-secondary position-relative"
|
||||
style="top: -5px;"
|
||||
>
|
||||
{grupo.habilitado
|
||||
? "Habilitado"
|
||||
: "Desabilitado"}
|
||||
</span>
|
||||
</button>
|
||||
</h2>
|
||||
<div id={grupo.idgrupo} class="accordion-collapse collapse">
|
||||
@@ -202,6 +228,14 @@
|
||||
onclick={() => setModalEditar(grupo)}
|
||||
>Editar</button
|
||||
>
|
||||
<button
|
||||
class="btn"
|
||||
class:btn-danger={grupo.habilitado}
|
||||
class:btn-success={!grupo.habilitado}
|
||||
onclick={() => togglegrupo(grupo)}
|
||||
>
|
||||
{#if grupo.habilitado}Baja{:else}Alta{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
</script>
|
||||
|
||||
{#if modaldat != ""}
|
||||
<ModalEstatico payload={modaldat} />
|
||||
<ModalEstatico payload={modaldat} close={() => !!(modaldat = "")} />
|
||||
{/if}
|
||||
|
||||
<NavBarAutocompletable />
|
||||
|
||||
1
Front/src/types.d.ts
vendored
1
Front/src/types.d.ts
vendored
@@ -223,6 +223,7 @@ export type PatchPropiedad = {
|
||||
export type GrupoDto = {
|
||||
idgrupo:number,
|
||||
nombre:string,
|
||||
habilitado:boolean
|
||||
gruposIncluidos:string[],
|
||||
permisos:PermisoDto[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user