Facturas de cliente
This commit is contained in:
parent
18c37692ea
commit
a946aa129a
@ -22,6 +22,12 @@ interface ItemsEditorProps {
|
|||||||
|
|
||||||
const createEmptyItem = () => defaultCustomerInvoiceItemFormData;
|
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) => {
|
export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEditorProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const form = useFormContext();
|
const form = useFormContext();
|
||||||
@ -86,13 +92,24 @@ export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEdi
|
|||||||
</colgroup>
|
</colgroup>
|
||||||
<TableHeader className="text-sm bg-muted backdrop-blur supports-[backdrop-filter]:bg-muted/60 ">
|
<TableHeader className="text-sm bg-muted backdrop-blur supports-[backdrop-filter]:bg-muted/60 ">
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableHead><div className='h-5'>
|
<TableHead>
|
||||||
<Checkbox
|
<div className='h-5'>
|
||||||
aria-label={t("common.select_row")}
|
<Checkbox
|
||||||
className='block h-5 w-5 leading-none align-middle'
|
aria-label={t("common.select_all")}
|
||||||
disabled={readOnly}
|
className='block h-5 w-5 leading-none align-middle'
|
||||||
/>
|
disabled={readOnly}
|
||||||
</div></TableHead>
|
checked={getSelectAllState(tableNav.fa.fields.length, selection.size)}
|
||||||
|
onCheckedChange={(next) => {
|
||||||
|
const shouldSelectAll = next !== false;
|
||||||
|
if (shouldSelectAll) {
|
||||||
|
setSelection(new Set(tableNav.fa.fields.map((_, i) => i)));
|
||||||
|
} else {
|
||||||
|
resetSelection();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</TableHead>
|
||||||
<TableHead>#</TableHead>
|
<TableHead>#</TableHead>
|
||||||
<TableHead>{t("form_fields.item.description.label")}</TableHead>
|
<TableHead>{t("form_fields.item.description.label")}</TableHead>
|
||||||
<TableHead className="text-right">{t("form_fields.item.quantity.label")}</TableHead>
|
<TableHead className="text-right">{t("form_fields.item.quantity.label")}</TableHead>
|
||||||
@ -121,8 +138,7 @@ export const ItemsEditor = ({ value = [], onChange, readOnly = false }: ItemsEdi
|
|||||||
checked={selection.has(rowIndex)}
|
checked={selection.has(rowIndex)}
|
||||||
onCheckedChange={() => toggleSel(rowIndex)}
|
onCheckedChange={() => toggleSel(rowIndex)}
|
||||||
disabled={readOnly}
|
disabled={readOnly}
|
||||||
/>
|
/> </div>
|
||||||
</div>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
{/* # */}
|
{/* # */}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user