From a946aa129ac49f619e5187a0b2e5f07911972618 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 8 Oct 2025 19:02:38 +0200 Subject: [PATCH] Facturas de cliente --- .../components/editor/items/items-editor.tsx | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/modules/customer-invoices/src/web/components/editor/items/items-editor.tsx b/modules/customer-invoices/src/web/components/editor/items/items-editor.tsx index 8d088f2d..10ba25d4 100644 --- a/modules/customer-invoices/src/web/components/editor/items/items-editor.tsx +++ b/modules/customer-invoices/src/web/components/editor/items/items-editor.tsx @@ -22,6 +22,12 @@ interface ItemsEditorProps { const createEmptyItem = () => defaultCustomerInvoiceItemFormData; +function getSelectAllState(totalRows: number, selectedCount: number): boolean | 'indeterminate' { + if (totalRows === 0 || selectedCount === 0) return false; + if (selectedCount === totalRows) return true; + return 'indeterminate'; +} + export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEditorProps) => { const { t } = useTranslation(); const form = useFormContext(); @@ -86,13 +92,24 @@ export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEdi -
- -
+ +
+ { + const shouldSelectAll = next !== false; + if (shouldSelectAll) { + setSelection(new Set(tableNav.fa.fields.map((_, i) => i))); + } else { + resetSelection(); + } + }} + /> +
+
# {t("form_fields.item.description.label")} {t("form_fields.item.quantity.label")} @@ -121,8 +138,7 @@ export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEdi checked={selection.has(rowIndex)} onCheckedChange={() => toggleSel(rowIndex)} disabled={readOnly} - /> - + /> {/* # */}