Arreglo de filtros, click con compoartmiento de exit, reactividad al ingresar un registro, ademmsa del docble click
This commit is contained in:
@@ -37,17 +37,17 @@ export async function getPrevalidators(
|
||||
filters: Record<string, any> = {},
|
||||
companyId?: number
|
||||
): Promise<ApiResponse<PrevalidatorListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
const paramObj: Record<string, string> = {
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
...filters
|
||||
page_size: pageSize.toString()
|
||||
};
|
||||
if (companyId) paramObj.company_id = companyId.toString();
|
||||
Object.entries(filters).forEach(([k, v]) => {
|
||||
if (v !== undefined && v !== null && v !== '') paramObj[k] = String(v);
|
||||
});
|
||||
if (companyId) {
|
||||
params.append('company_id', companyId.toString());
|
||||
}
|
||||
const params = new URLSearchParams(paramObj);
|
||||
|
||||
const response = await api.get(`/v1/a76/prevalidators/?${params.toString()}`);
|
||||
return response.data;
|
||||
return api.get(`/v1/a76/prevalidators/?${params.toString()}`);
|
||||
}
|
||||
|
||||
export async function getPrevalidator(id: number, companyId?: number): Promise<Prevalidator> {
|
||||
|
||||
@@ -36,19 +36,20 @@ export interface SignatureListResponse {
|
||||
export async function getSignatures(
|
||||
page: number = 1,
|
||||
pageSize: number = 50,
|
||||
companyId: number,
|
||||
companyId: number,
|
||||
filters: Record<string, any> = {}
|
||||
): Promise<ApiResponse<SignatureListResponse>> {
|
||||
const params = new URLSearchParams({
|
||||
const paramObj: Record<string, string> = {
|
||||
page: page.toString(),
|
||||
page_size: pageSize.toString(),
|
||||
company_id: companyId.toString(),
|
||||
...filters
|
||||
company_id: companyId.toString()
|
||||
};
|
||||
Object.entries(filters).forEach(([k, v]) => {
|
||||
if (v !== undefined && v !== null && v !== '') paramObj[k] = String(v);
|
||||
});
|
||||
const params = new URLSearchParams(paramObj);
|
||||
|
||||
|
||||
const response = await api.get(`/v1/a76/signatures/?${params.toString()}`);
|
||||
return response.data;
|
||||
return api.get(`/v1/a76/signatures/?${params.toString()}`);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
</script>
|
||||
|
||||
<Dialog.Root bind:open>
|
||||
<Dialog.Content class="sm:max-w-[500px]">
|
||||
<Dialog.Content class="sm:max-w-[500px]" onInteractOutside={(e) => e.preventDefault()}>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{title}</Dialog.Title>
|
||||
</Dialog.Header>
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</script>
|
||||
|
||||
<Dialog.Root bind:open>
|
||||
<Dialog.Content class="sm:max-w-[500px]">
|
||||
<Dialog.Content class="sm:max-w-[500px]" onInteractOutside={(e) => e.preventDefault()}>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{title}</Dialog.Title>
|
||||
</Dialog.Header>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
import { Pencil, Plus, Trash2 } from 'lucide-svelte';
|
||||
import { Pencil, Plus, Trash2, RefreshCw } from 'lucide-svelte';
|
||||
import InfiniteDataTable from '$lib/components/dashboard/common/infinite-data-table.svelte';
|
||||
import { createColumns } from '$lib/components/dashboard/general_catalogs/prevalidators/columns';
|
||||
import CreateEditDialog from '$lib/components/dashboard/general_catalogs/prevalidators/create-edit-dialog.svelte';
|
||||
@@ -226,7 +226,9 @@
|
||||
size="sm"
|
||||
class="h-9"
|
||||
onclick={reloadData}
|
||||
disabled={loading}
|
||||
>
|
||||
<RefreshCw class="mr-2 h-4 w-4 {loading ? 'animate-spin' : ''}" />
|
||||
Actualizar
|
||||
</Button>
|
||||
{#if canCreate}
|
||||
@@ -262,7 +264,17 @@
|
||||
</Card.Header>
|
||||
<Card.Content class="p-0 flex-1 overflow-hidden min-h-0">
|
||||
<div class="rounded-md border bg-background overflow-hidden h-full">
|
||||
<InfiniteDataTable data={allItems} {columns} {loading} {hasMore} {loadMore} />
|
||||
<InfiniteDataTable
|
||||
data={allItems}
|
||||
{columns}
|
||||
{loading}
|
||||
{hasMore}
|
||||
{loadMore}
|
||||
{selectedIds}
|
||||
onSelectedIdsChange={(ids) => (selectedIds = ids)}
|
||||
onRowClick={handleRowClick}
|
||||
onRowDoubleClick={handleRowDoubleClick}
|
||||
/>
|
||||
</div>
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
@@ -83,7 +83,7 @@ error = null;
|
||||
try {
|
||||
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
||||
code: searchCode || undefined,
|
||||
description: searchDesc || undefined,
|
||||
signature: searchDesc || undefined,
|
||||
page: '1',
|
||||
page_size: pageSize.toString()
|
||||
});
|
||||
@@ -101,8 +101,8 @@ loading = false;
|
||||
const url = new URL($page.url);
|
||||
if (searchCode) url.searchParams.set('code', searchCode);
|
||||
else url.searchParams.delete('code');
|
||||
if (searchDesc) url.searchParams.set('description', searchDesc);
|
||||
else url.searchParams.delete('description');
|
||||
if (searchDesc) url.searchParams.set('signature', searchDesc);
|
||||
else url.searchParams.delete('signature');
|
||||
history.replaceState(history.state, '', url);
|
||||
}, 500);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ loading = true;
|
||||
try {
|
||||
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
||||
code: searchCode || undefined,
|
||||
description: searchDesc || undefined,
|
||||
signature: searchDesc || undefined,
|
||||
page: (currentPage + 1).toString(),
|
||||
page_size: pageSize.toString()
|
||||
});
|
||||
@@ -134,7 +134,7 @@ error = null;
|
||||
try {
|
||||
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
||||
code: searchCode || undefined,
|
||||
description: searchDesc || undefined,
|
||||
signature: searchDesc || undefined,
|
||||
page: '1',
|
||||
page_size: pageSize.toString()
|
||||
});
|
||||
@@ -165,8 +165,8 @@ const columns = $derived(createColumns(handleSuccess, { canEdit, canDelete }));
|
||||
<p class="text-muted-foreground">Catálogo de Firmas del sistema</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<Button variant="outline" size="sm" class="h-9" onclick={reloadData}>
|
||||
<RefreshCw class="mr-2 h-4 w-4" /> Actualizar
|
||||
<Button variant="outline" size="sm" class="h-9" onclick={reloadData} disabled={loading}>
|
||||
<RefreshCw class="mr-2 h-4 w-4 {loading ? 'animate-spin' : ''}" /> Actualizar
|
||||
</Button>
|
||||
{#if !isError && canCreate}
|
||||
<Button class="h-9" onclick={() => { editingItem = null; createDialogOpen = true; }}>
|
||||
@@ -189,7 +189,7 @@ onRetry={reloadData}
|
||||
<Card.Title>Listado de Firmas</Card.Title>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Input placeholder="Código" bind:value={searchCode} oninput={handleSearch} class="h-9 w-36 bg-card lg:w-44" />
|
||||
<Input placeholder="Descripción" bind:value={searchDesc} oninput={handleSearch} class="h-9 w-44 bg-card lg:w-64" />
|
||||
<Input placeholder="Firma" bind:value={searchDesc} oninput={handleSearch} class="h-9 w-44 bg-card lg:w-64" />
|
||||
</div>
|
||||
</div>
|
||||
</Card.Header>
|
||||
|
||||
Reference in New Issue
Block a user