Arreglo de filtros, click con compoartmiento de exit, reactividad al ingresar un registro, ademmsa del docble click
This commit is contained in:
@@ -29,6 +29,7 @@ prevalidator_crud = TenantCRUDRoutes(
|
|||||||
tags=["Prevalidators"],
|
tags=["Prevalidators"],
|
||||||
resource_name="Prevalidator",
|
resource_name="Prevalidator",
|
||||||
enable_list=True,
|
enable_list=True,
|
||||||
|
enable_filters=True,
|
||||||
list_permissions=["cat_prevalidators.view"],
|
list_permissions=["cat_prevalidators.view"],
|
||||||
get_permissions=["cat_prevalidators.view"],
|
get_permissions=["cat_prevalidators.view"],
|
||||||
create_permissions=["cat_prevalidators.create"],
|
create_permissions=["cat_prevalidators.create"],
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ class SignatureService:
|
|||||||
if filters.get("code"):
|
if filters.get("code"):
|
||||||
query = query.filter(
|
query = query.filter(
|
||||||
models.Signature.code.ilike(f"%{filters['code']}%"))
|
models.Signature.code.ilike(f"%{filters['code']}%"))
|
||||||
|
if filters.get("signature"):
|
||||||
|
query = query.filter(
|
||||||
|
models.Signature.signature.ilike(f"%{filters['signature']}%"))
|
||||||
|
|
||||||
total = query.count()
|
total = query.count()
|
||||||
signatures = query.offset(skip).limit(limit).all()
|
signatures = query.offset(skip).limit(limit).all()
|
||||||
|
|||||||
@@ -37,17 +37,17 @@ export async function getPrevalidators(
|
|||||||
filters: Record<string, any> = {},
|
filters: Record<string, any> = {},
|
||||||
companyId?: number
|
companyId?: number
|
||||||
): Promise<ApiResponse<PrevalidatorListResponse>> {
|
): Promise<ApiResponse<PrevalidatorListResponse>> {
|
||||||
const params = new URLSearchParams({
|
const paramObj: Record<string, string> = {
|
||||||
page: page.toString(),
|
page: page.toString(),
|
||||||
page_size: pageSize.toString(),
|
page_size: pageSize.toString()
|
||||||
...filters
|
};
|
||||||
|
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) {
|
const params = new URLSearchParams(paramObj);
|
||||||
params.append('company_id', companyId.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await api.get(`/v1/a76/prevalidators/?${params.toString()}`);
|
return api.get(`/v1/a76/prevalidators/?${params.toString()}`);
|
||||||
return response.data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getPrevalidator(id: number, companyId?: number): Promise<Prevalidator> {
|
export async function getPrevalidator(id: number, companyId?: number): Promise<Prevalidator> {
|
||||||
|
|||||||
@@ -36,19 +36,20 @@ export interface SignatureListResponse {
|
|||||||
export async function getSignatures(
|
export async function getSignatures(
|
||||||
page: number = 1,
|
page: number = 1,
|
||||||
pageSize: number = 50,
|
pageSize: number = 50,
|
||||||
companyId: number,
|
companyId: number,
|
||||||
filters: Record<string, any> = {}
|
filters: Record<string, any> = {}
|
||||||
): Promise<ApiResponse<SignatureListResponse>> {
|
): Promise<ApiResponse<SignatureListResponse>> {
|
||||||
const params = new URLSearchParams({
|
const paramObj: Record<string, string> = {
|
||||||
page: page.toString(),
|
page: page.toString(),
|
||||||
page_size: pageSize.toString(),
|
page_size: pageSize.toString(),
|
||||||
company_id: companyId.toString(),
|
company_id: companyId.toString()
|
||||||
...filters
|
};
|
||||||
|
Object.entries(filters).forEach(([k, v]) => {
|
||||||
|
if (v !== undefined && v !== null && v !== '') paramObj[k] = String(v);
|
||||||
});
|
});
|
||||||
|
const params = new URLSearchParams(paramObj);
|
||||||
|
|
||||||
|
return api.get(`/v1/a76/signatures/?${params.toString()}`);
|
||||||
const response = await api.get(`/v1/a76/signatures/?${params.toString()}`);
|
|
||||||
return response.data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Dialog.Root bind:open>
|
<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.Header>
|
||||||
<Dialog.Title>{title}</Dialog.Title>
|
<Dialog.Title>{title}</Dialog.Title>
|
||||||
</Dialog.Header>
|
</Dialog.Header>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Dialog.Root bind:open>
|
<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.Header>
|
||||||
<Dialog.Title>{title}</Dialog.Title>
|
<Dialog.Title>{title}</Dialog.Title>
|
||||||
</Dialog.Header>
|
</Dialog.Header>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import * as Card from '$lib/components/ui/card';
|
import * as Card from '$lib/components/ui/card';
|
||||||
import { Button } from '$lib/components/ui/button';
|
import { Button } from '$lib/components/ui/button';
|
||||||
import { Input } from '$lib/components/ui/input';
|
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 InfiniteDataTable from '$lib/components/dashboard/common/infinite-data-table.svelte';
|
||||||
import { createColumns } from '$lib/components/dashboard/general_catalogs/prevalidators/columns';
|
import { createColumns } from '$lib/components/dashboard/general_catalogs/prevalidators/columns';
|
||||||
import CreateEditDialog from '$lib/components/dashboard/general_catalogs/prevalidators/create-edit-dialog.svelte';
|
import CreateEditDialog from '$lib/components/dashboard/general_catalogs/prevalidators/create-edit-dialog.svelte';
|
||||||
@@ -226,7 +226,9 @@
|
|||||||
size="sm"
|
size="sm"
|
||||||
class="h-9"
|
class="h-9"
|
||||||
onclick={reloadData}
|
onclick={reloadData}
|
||||||
|
disabled={loading}
|
||||||
>
|
>
|
||||||
|
<RefreshCw class="mr-2 h-4 w-4 {loading ? 'animate-spin' : ''}" />
|
||||||
Actualizar
|
Actualizar
|
||||||
</Button>
|
</Button>
|
||||||
{#if canCreate}
|
{#if canCreate}
|
||||||
@@ -262,7 +264,17 @@
|
|||||||
</Card.Header>
|
</Card.Header>
|
||||||
<Card.Content class="p-0 flex-1 overflow-hidden min-h-0">
|
<Card.Content class="p-0 flex-1 overflow-hidden min-h-0">
|
||||||
<div class="rounded-md border bg-background overflow-hidden h-full">
|
<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>
|
</div>
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
</Card.Root>
|
</Card.Root>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ error = null;
|
|||||||
try {
|
try {
|
||||||
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
||||||
code: searchCode || undefined,
|
code: searchCode || undefined,
|
||||||
description: searchDesc || undefined,
|
signature: searchDesc || undefined,
|
||||||
page: '1',
|
page: '1',
|
||||||
page_size: pageSize.toString()
|
page_size: pageSize.toString()
|
||||||
});
|
});
|
||||||
@@ -101,8 +101,8 @@ loading = false;
|
|||||||
const url = new URL($page.url);
|
const url = new URL($page.url);
|
||||||
if (searchCode) url.searchParams.set('code', searchCode);
|
if (searchCode) url.searchParams.set('code', searchCode);
|
||||||
else url.searchParams.delete('code');
|
else url.searchParams.delete('code');
|
||||||
if (searchDesc) url.searchParams.set('description', searchDesc);
|
if (searchDesc) url.searchParams.set('signature', searchDesc);
|
||||||
else url.searchParams.delete('description');
|
else url.searchParams.delete('signature');
|
||||||
history.replaceState(history.state, '', url);
|
history.replaceState(history.state, '', url);
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ loading = true;
|
|||||||
try {
|
try {
|
||||||
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
||||||
code: searchCode || undefined,
|
code: searchCode || undefined,
|
||||||
description: searchDesc || undefined,
|
signature: searchDesc || undefined,
|
||||||
page: (currentPage + 1).toString(),
|
page: (currentPage + 1).toString(),
|
||||||
page_size: pageSize.toString()
|
page_size: pageSize.toString()
|
||||||
});
|
});
|
||||||
@@ -134,7 +134,7 @@ error = null;
|
|||||||
try {
|
try {
|
||||||
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
const response = await signaturesApi.list(companyStore.activeCompany.id, {
|
||||||
code: searchCode || undefined,
|
code: searchCode || undefined,
|
||||||
description: searchDesc || undefined,
|
signature: searchDesc || undefined,
|
||||||
page: '1',
|
page: '1',
|
||||||
page_size: pageSize.toString()
|
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>
|
<p class="text-muted-foreground">Catálogo de Firmas del sistema</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<Button variant="outline" size="sm" class="h-9" onclick={reloadData}>
|
<Button variant="outline" size="sm" class="h-9" onclick={reloadData} disabled={loading}>
|
||||||
<RefreshCw class="mr-2 h-4 w-4" /> Actualizar
|
<RefreshCw class="mr-2 h-4 w-4 {loading ? 'animate-spin' : ''}" /> Actualizar
|
||||||
</Button>
|
</Button>
|
||||||
{#if !isError && canCreate}
|
{#if !isError && canCreate}
|
||||||
<Button class="h-9" onclick={() => { editingItem = null; createDialogOpen = true; }}>
|
<Button class="h-9" onclick={() => { editingItem = null; createDialogOpen = true; }}>
|
||||||
@@ -189,7 +189,7 @@ onRetry={reloadData}
|
|||||||
<Card.Title>Listado de Firmas</Card.Title>
|
<Card.Title>Listado de Firmas</Card.Title>
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
<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="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>
|
||||||
</div>
|
</div>
|
||||||
</Card.Header>
|
</Card.Header>
|
||||||
|
|||||||
Reference in New Issue
Block a user