feat(transactions): notes folded under rows, i shows them all
This commit is contained in:
1 parent
0ace2919aa
commit
4e774f5104
2 files changed
+53
-6
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Check from "@lucide/svelte/icons/check";
|
import Check from "@lucide/svelte/icons/check";
|
||||||
import ChevronRight from "@lucide/svelte/icons/chevron-right";
|
import ChevronRight from "@lucide/svelte/icons/chevron-right";
|
||||||
|
import NotebookText from "@lucide/svelte/icons/notebook-text";
|
||||||
import Paperclip from "@lucide/svelte/icons/paperclip";
|
import Paperclip from "@lucide/svelte/icons/paperclip";
|
||||||
import type { Split } from "#lib/api/types.js";
|
import type { Split } from "#lib/api/types.js";
|
||||||
import Amount from "#lib/components/Amount.svelte";
|
import Amount from "#lib/components/Amount.svelte";
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
signedForeign,
|
signedForeign,
|
||||||
sumByCurrency,
|
sumByCurrency,
|
||||||
} from "#lib/transactions/split.js";
|
} from "#lib/transactions/split.js";
|
||||||
|
import { ui } from "#lib/ui.svelte.js";
|
||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
import ActionBar, { type Mode } from "./ActionBar.svelte";
|
import ActionBar, { type Mode } from "./ActionBar.svelte";
|
||||||
import TypeIcon from "./TypeIcon.svelte";
|
import TypeIcon from "./TypeIcon.svelte";
|
||||||
@@ -58,6 +60,7 @@
|
|||||||
let menuArmed = $state(false);
|
let menuArmed = $state(false);
|
||||||
let barHeight = $state(0);
|
let barHeight = $state(0);
|
||||||
|
|
||||||
|
const HEAD_HEIGHT = 32;
|
||||||
const CHECKBOX = "size-3.5 cursor-pointer align-middle accent-(--ff-brand)";
|
const CHECKBOX = "size-3.5 cursor-pointer align-middle accent-(--ff-brand)";
|
||||||
|
|
||||||
const accountId = $derived(context.accountId);
|
const accountId = $derived(context.accountId);
|
||||||
@@ -137,6 +140,12 @@
|
|||||||
label: "Collapse row",
|
label: "Collapse row",
|
||||||
run: () => collapse(nav.current),
|
run: () => collapse(nav.current),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
group: "List",
|
||||||
|
keys: "i",
|
||||||
|
label: ui.notes ? "Hide notes under rows" : "Show notes under rows",
|
||||||
|
run: () => ui.toggleNotes(),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
group: "List",
|
group: "List",
|
||||||
keys: "c",
|
keys: "c",
|
||||||
@@ -295,6 +304,20 @@
|
|||||||
title={split.description}
|
title={split.description}
|
||||||
>{split.description}</a
|
>{split.description}</a
|
||||||
>
|
>
|
||||||
|
{#if split.notes && !(wide || ui.notes)}
|
||||||
|
<button
|
||||||
|
aria-label="Show notes"
|
||||||
|
class="grid size-4 shrink-0 place-items-center rounded text-cladd-fg-softer hover:bg-cladd-surface-next hover:text-cladd-fg"
|
||||||
|
onclick={(event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
opened = toggled(opened, row.key, true);
|
||||||
|
}}
|
||||||
|
title={split.notes}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<NotebookText class="size-3" />
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
{#if split.tags?.length}
|
{#if split.tags?.length}
|
||||||
<span
|
<span
|
||||||
class="ml-auto max-w-[45%] shrink-0 truncate text-[12px] 2xl:hidden"
|
class="ml-auto max-w-[45%] shrink-0 truncate text-[12px] 2xl:hidden"
|
||||||
@@ -302,7 +325,7 @@
|
|||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if split.notes}
|
{#if split.notes && (wide || ui.notes)}
|
||||||
<div
|
<div
|
||||||
class="flex min-w-0 items-start gap-0.5 text-[12px] text-cladd-fg-soft"
|
class="flex min-w-0 items-start gap-0.5 text-[12px] text-cladd-fg-soft"
|
||||||
>
|
>
|
||||||
@@ -482,7 +505,20 @@
|
|||||||
</th>
|
</th>
|
||||||
{/if}
|
{/if}
|
||||||
<th class="w-6 max-sm:hidden"><span class="sr-only">Type</span></th>
|
<th class="w-6 max-sm:hidden"><span class="sr-only">Type</span></th>
|
||||||
<th>Description</th>
|
<th>
|
||||||
|
Description
|
||||||
|
<button
|
||||||
|
aria-pressed={ui.notes}
|
||||||
|
class="ml-1 inline-grid size-5 place-items-center rounded align-middle hover:bg-cladd-surface-next hover:text-cladd-fg {ui.notes
|
||||||
|
? "text-cladd-fg"
|
||||||
|
: "text-cladd-fg-softer"}"
|
||||||
|
onclick={() => ui.toggleNotes()}
|
||||||
|
title={ui.notes ? "Hide notes (i)" : "Show notes (i)"}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<NotebookText class="size-3.5" />
|
||||||
|
</button>
|
||||||
|
</th>
|
||||||
<th class="w-28 text-right md:w-32">Amount</th>
|
<th class="w-28 text-right md:w-32">Amount</th>
|
||||||
<th class="w-24 text-right max-lg:hidden">Foreign</th>
|
<th class="w-24 text-right max-lg:hidden">Foreign</th>
|
||||||
{#if accountId}
|
{#if accountId}
|
||||||
@@ -504,6 +540,7 @@
|
|||||||
id={nav.rowId(index)}
|
id={nav.rowId(index)}
|
||||||
onclick={(event) => nav.click(index, event)}
|
onclick={(event) => nav.click(index, event)}
|
||||||
ondblclick={() => open(row)}
|
ondblclick={() => open(row)}
|
||||||
|
style:scroll-margin-top={`${barHeight + HEAD_HEIGHT}px`}
|
||||||
>
|
>
|
||||||
{#if selectable}
|
{#if selectable}
|
||||||
<td class="max-sm:hidden">
|
<td class="max-sm:hidden">
|
||||||
|
|||||||
+14
-4
@@ -1,14 +1,24 @@
|
|||||||
const SIDEBAR_KEY = "ffui.sidebar.collapsed";
|
const SIDEBAR_KEY = "ffui.sidebar.collapsed";
|
||||||
|
const NOTES_KEY = "ffui.notes.shown";
|
||||||
|
|
||||||
|
function stored(key: string): boolean {
|
||||||
|
return (
|
||||||
|
typeof localStorage !== "undefined" && localStorage.getItem(key) === "1"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
class Ui {
|
class Ui {
|
||||||
palette = $state(false);
|
palette = $state(false);
|
||||||
paletteQuery = $state("");
|
paletteQuery = $state("");
|
||||||
quickEntry = $state(false);
|
quickEntry = $state(false);
|
||||||
mobileNav = $state(false);
|
mobileNav = $state(false);
|
||||||
collapsed = $state(
|
collapsed = $state(stored(SIDEBAR_KEY));
|
||||||
typeof localStorage !== "undefined" &&
|
notes = $state(stored(NOTES_KEY));
|
||||||
localStorage.getItem(SIDEBAR_KEY) === "1"
|
|
||||||
);
|
toggleNotes() {
|
||||||
|
this.notes = !this.notes;
|
||||||
|
localStorage.setItem(NOTES_KEY, this.notes ? "1" : "0");
|
||||||
|
}
|
||||||
|
|
||||||
openPalette(query = "") {
|
openPalette(query = "") {
|
||||||
this.paletteQuery = query;
|
this.paletteQuery = query;
|
||||||
|
|||||||
Reference in new issue
Block a user