avance manejo de roles
parent
380632ce41
commit
add9428eab
|
@ -4,6 +4,7 @@
|
|||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>...</title>
|
||||
<link rel="shortcut icon" href="https://www.mtt.gob.cl/wp-content/themes/mtt/images/favicon.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
|
|
@ -67,6 +67,11 @@
|
|||
{#if ordering === 'nombre_app'}<i class="bi bi-caret-up-fill"></i>{/if}
|
||||
{#if ordering === '-nombre_app'}<i class="bi bi-caret-down-fill"></i>{/if}
|
||||
</th>
|
||||
<th>
|
||||
<a href={"#"} on:click|preventDefault={() => onOrderBy('path_app')}>Ruta URL</a>
|
||||
{#if ordering === 'path_app'}<i class="bi bi-caret-up-fill"></i>{/if}
|
||||
{#if ordering === '-path_app'}<i class="bi bi-caret-down-fill"></i>{/if}
|
||||
</th>
|
||||
<th>
|
||||
<a href={"#"} on:click|preventDefault={() => onOrderBy('vigente')}>Vigente</a>
|
||||
{#if ordering === 'vigente'}<i class="bi bi-caret-up-fill"></i>{/if}
|
||||
|
@ -80,6 +85,7 @@
|
|||
<td class="table-light">{offset + index + 1}</td>
|
||||
<td>{app.id_aplicacion}</td>
|
||||
<td><a href={"#"} on:click|preventDefault={() => onEdita(app)}>{app.nombre_app}</a></td>
|
||||
<td>{app.path_app}</td>
|
||||
<td>{app.vigente ? '✅':'🚫'}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
|
@ -92,7 +98,6 @@
|
|||
<i class="bi bi-arrow-repeat"></i>
|
||||
</a>
|
||||
<Paginate
|
||||
{offset}
|
||||
{limit}
|
||||
{count}
|
||||
on:page={ev => page = ev.detail}
|
||||
|
|
|
@ -66,9 +66,9 @@
|
|||
<div class="col-md-3">ID</div>
|
||||
<div class="col-md">
|
||||
{#if aplicacion.id_aplicacion}
|
||||
<input type="number" value={form.id_aplicacion} disabled class="form-control">
|
||||
<input type="number" value={form.id_aplicacion} disabled class="form-control">
|
||||
{:else}
|
||||
<input type="number" bind:value={form.id_aplicacion} required class="form-control">
|
||||
<input type="number" bind:value={form.id_aplicacion} class="form-control">
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -78,6 +78,12 @@
|
|||
<input type="text" bind:value={form.nombre_app} required class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-3">Ruta URL</div>
|
||||
<div class="col-md">
|
||||
<input type="text" bind:value={form.path_app} required class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" bind:checked={form.vigente} role="switch" id="vigente">
|
||||
|
|
|
@ -71,16 +71,10 @@
|
|||
loading = true;
|
||||
|
||||
if (rol.id_rol) {
|
||||
|
||||
|
||||
form = await updateRol(form)
|
||||
|
||||
form3 = CrearEditarEliminar(rol.id_rol,form_inicio,form3)
|
||||
|
||||
|
||||
|
||||
for(const obj1 of form3){
|
||||
|
||||
if (obj1.opcion == "Crear"){
|
||||
await createRolyaplicacion(obj1)
|
||||
}
|
||||
|
@ -90,7 +84,6 @@
|
|||
else if (obj1.opcion == "Eliminar"){
|
||||
await deleteRolyaplicacion(obj1.id_rol_app)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -230,14 +223,9 @@ function CrearEditarEliminar(id, arregloInicial, arregloFinal) {
|
|||
<input type="text" bind:value={form.nombre_rol} required class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="h4 mb-3">Permiso a aplicaciones </h4>
|
||||
<pre>
|
||||
|
||||
|
||||
</pre>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-secondary text-light">Permiso a Aplicaciones</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-bordered">
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
<th>Nombres</th>
|
||||
<th>Apellido 1</th>
|
||||
<th>Apellido 2</th>
|
||||
<th>Rol</th>
|
||||
<th>Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -55,6 +56,7 @@
|
|||
<td>{row.persona.nombres}</td>
|
||||
<td>{row.persona.apellido_a}</td>
|
||||
<td>{row.persona.apellido_b}</td>
|
||||
<td>{row.rol.nombre_rol}</td>
|
||||
<td>{row.persona.email}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
<script>
|
||||
import { getRoles } from "$/services/roles";
|
||||
|
||||
export let form = {}
|
||||
export let es_nuevo = true
|
||||
export let clave2 = ''
|
||||
let roles = []
|
||||
|
||||
getRoles().then(data => roles = data).catch(error => alert(error))
|
||||
</script>
|
||||
|
||||
<div class="row">
|
||||
|
@ -9,7 +14,19 @@
|
|||
Login
|
||||
<input type="text" bind:value={form.login} class="form-control" required disabled={!es_nuevo}>
|
||||
</div>
|
||||
<div class="col-md mb-3">
|
||||
Rol
|
||||
<select required bind:value={form.id_rol} class="form-select">
|
||||
{#each roles as rol}
|
||||
<option value={rol.id_rol}>{rol.nombre_rol}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md mb-3 pt-3">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" bind:checked={form.superuser} id="usuario-superuser">
|
||||
<label class="form-check-label" for="usuario-superuser">Super usuario</label>
|
||||
</div>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" bind:checked={form.vigente} id="usuario-vigente">
|
||||
<label class="form-check-label" for="usuario-vigente">Vigente</label>
|
||||
|
|
|
@ -28,7 +28,7 @@ export async function createAplicacion(data) {
|
|||
return res.json()
|
||||
}
|
||||
|
||||
export async function updateAplicacion({ id_aplicacion: id, ...data }) {
|
||||
export async function updateAplicacion({ id_aplicacion: id = null, ...data }) {
|
||||
const res = await fetch(`${base}/aplicaciones/${id}/`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(data),
|
||||
|
|
|
@ -27,7 +27,7 @@ export async function createRol(data) {
|
|||
return res.json()
|
||||
}
|
||||
|
||||
export async function updateRol({ id_rol: id, ...data }) {
|
||||
export async function updateRol({ id_rol: id = null, ...data }) {
|
||||
const res = await fetch(`${base}/roles/${id}/`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(data),
|
||||
|
|
|
@ -38,7 +38,7 @@ export async function createRolyaplicacion(data) {
|
|||
return res.json()
|
||||
}
|
||||
|
||||
export async function updateRolyaplicacion({ id_rol_app: id, ...data }) {
|
||||
export async function updateRolyaplicacion({ id_rol_app: id = null, ...data }) {
|
||||
const res = await fetch(`${base}/rolyaplicacion/${id}/`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(data),
|
||||
|
|
|
@ -28,7 +28,7 @@ export async function createUsuario(data) {
|
|||
return res.json()
|
||||
}
|
||||
|
||||
export async function updateUsuario({ login: id, ...data }) {
|
||||
export async function updateUsuario({ login: id = null, ...data }) {
|
||||
const res = await fetch(`${base}/usuarios/${id}/`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(data),
|
||||
|
|
Loading…
Reference in New Issue