Table in transaction history.
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
amount: 200
|
amount: 200
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
checked: true,
|
checked: false,
|
||||||
id: 3,
|
id: 3,
|
||||||
name: 'Yet another transaction',
|
name: 'Yet another transaction',
|
||||||
description: 'Yet another description, but longer than the others',
|
description: 'Yet another description, but longer than the others',
|
||||||
|
|||||||
@@ -1,6 +1,70 @@
|
|||||||
|
<script lang="ts" module>
|
||||||
|
type ScheduledTransaction = {
|
||||||
|
checked: boolean;
|
||||||
|
id: number;
|
||||||
|
description: string;
|
||||||
|
account: string;
|
||||||
|
amount: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns: Column<ScheduledTransaction>[] = [
|
||||||
|
{ key: 'checked' },
|
||||||
|
{ key: 'id', label: '#' },
|
||||||
|
{ key: 'description', label: 'Description', ratio: 1 },
|
||||||
|
{ key: 'account', label: 'Account' },
|
||||||
|
{ key: 'amount', label: 'Amount' }
|
||||||
|
];
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Checkbox from '#lib/components/checkbox.svelte';
|
||||||
|
import Table, { type Column } from '#lib/components/table.svelte';
|
||||||
|
|
||||||
|
const data: ScheduledTransaction[] = $state([
|
||||||
|
{
|
||||||
|
checked: false,
|
||||||
|
id: 1,
|
||||||
|
description: 'Some description',
|
||||||
|
account: 'Some account',
|
||||||
|
amount: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checked: false,
|
||||||
|
id: 2,
|
||||||
|
description: 'Another description',
|
||||||
|
account: 'Another account',
|
||||||
|
amount: 200
|
||||||
|
},
|
||||||
|
{
|
||||||
|
checked: false,
|
||||||
|
id: 3,
|
||||||
|
description: 'Yet another description, but longer than the others',
|
||||||
|
account: 'Yet another account',
|
||||||
|
amount: 300
|
||||||
|
}
|
||||||
|
]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Transaction history | Expenses</title>
|
<title>Transaction history | Expenses</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
|
<Table {columns} {data} style={({ row }) => (row?.checked ? ['highlight'] : [])}>
|
||||||
|
{#snippet header({ key, label })}
|
||||||
|
{#if key === 'checked'}
|
||||||
|
<Checkbox
|
||||||
|
onchange={(e) => data.forEach((row) => (row.checked = e.currentTarget.checked))}
|
||||||
|
checked={data.every((row) => row.checked)}
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
{label}
|
||||||
|
{/if}
|
||||||
|
{/snippet}
|
||||||
|
{#snippet cell({ key, value, row })}
|
||||||
|
{#if key === 'checked'}
|
||||||
|
<Checkbox bind:checked={row.checked} />
|
||||||
|
{:else}
|
||||||
|
{value}
|
||||||
|
{/if}
|
||||||
|
{/snippet}
|
||||||
|
</Table>
|
||||||
|
|||||||
Reference in New Issue
Block a user