Private
Public Access
algunos refactors y arregle el tema de que no se eliminaban los
subgrupos
This commit is contained in:
1 parent
ab88be0ba5
commit
df2412f29a
25 files changed
+415
-261
No files matched your search
@@ -0,0 +1,46 @@
|
||||
<script lang="ts">
|
||||
import { ComboBox, Modal } from 'carbon-components-svelte';
|
||||
import type { Permiso } from '../../types';
|
||||
|
||||
let {
|
||||
open = $bindable(false),
|
||||
permisosDisponibles = [],
|
||||
alSeleccionar,
|
||||
alCerrar
|
||||
}: {
|
||||
open: boolean;
|
||||
permisosDisponibles: Permiso[];
|
||||
alSeleccionar?: (item: { id: number; text: string }) => void;
|
||||
alCerrar?: () => void;
|
||||
} = $props();
|
||||
|
||||
let itemSeleccionado: { id: number; text: string } | null = $state(null);
|
||||
|
||||
function enviar() {
|
||||
if (!itemSeleccionado) return;
|
||||
alSeleccionar?.(itemSeleccionado);
|
||||
}
|
||||
</script>
|
||||
|
||||
<form id="permiso-form" onsubmit={enviar}>
|
||||
<Modal
|
||||
bind:open
|
||||
modalHeading="Agregar Permiso"
|
||||
primaryButtonText="Agregar"
|
||||
secondaryButtonText="Cancelar"
|
||||
formId="permiso-form"
|
||||
hasForm
|
||||
on:click:button--secondary={() => alCerrar?.()}
|
||||
>
|
||||
{#if permisosDisponibles.length === 0}
|
||||
<p class="text-secondary">No hay permisos disponibles para agregar.</p>
|
||||
{:else}
|
||||
<ComboBox
|
||||
labelText="Seleccionar permiso"
|
||||
items={permisosDisponibles.map((p) => ({ id: p.id, text: `${p.nombre} (${p.alias})` }))}
|
||||
itemToString={(item: { id: number; text: string } | null) => (item ? item.text : '')}
|
||||
on:select={(e) => (itemSeleccionado = e.detail.selectedItem)}
|
||||
/>
|
||||
{/if}
|
||||
</Modal>
|
||||
</form>
|
||||
Reference in new issue
Block a user