| 1 |
<script lang="ts"> |
| 2 |
import { urlFor } from "../helpers"; |
| 3 |
import { _ } from "../i18n"; |
| 4 |
import { keyboardShortcut } from "../keyboard-shortcuts"; |
| 5 |
import { errors, extensions, ledgerData } from "../stores"; |
| 6 |
import AccountSelector from "./AccountSelector.svelte"; |
| 7 |
import Link from "./SidebarLink.svelte"; |
| 8 |
|
| 9 |
const truncate = (s: string) => (s.length < 25 ? s : `${s.slice(25)}…`); |
| 10 |
|
| 11 |
let user_queries = $derived($ledgerData.user_queries); |
| 12 |
let upcoming_events_count = $derived($ledgerData.upcoming_events_count); |
| 13 |
let sidebar_links = $derived($ledgerData.sidebar_links); |
| 14 |
let extension_reports = $derived( |
| 15 |
$extensions.filter((e) => e.report_title != null), |
| 16 |
); |
| 17 |
</script> |
| 18 |
|
| 19 |
{#if sidebar_links.length} |
| 20 |
<ul class="navigation"> |
| 21 |
{#each sidebar_links as [label, link]} |
| 22 |
<Link report={link} name={label} remote /> |
| 23 |
{/each} |
| 24 |
</ul> |
| 25 |
{/if} |
| 26 |
<ul class="navigation"> |
| 27 |
<Link report="income_statement" name={_("Income Statement")} key="g i" /> |
| 28 |
<Link report="balance_sheet" name={_("Balance Sheet")} key="g b" /> |
| 29 |
<Link report="trial_balance" name={_("Trial Balance")} key="g t" /> |
| 30 |
<Link report="journal" name={_("Journal")} key="g j" /> |
| 31 |
<Link report="query" name={_("Query")} key="g q"> |
| 32 |
{#if user_queries.length} |
| 33 |
<ul class="submenu"> |
| 34 |
{#each user_queries as { query_string, name }} |
| 35 |
<li> |
| 36 |
<a href={$urlFor("query/", { query_string })}>{truncate(name)}</a> |
| 37 |
</li> |
| 38 |
{/each} |
| 39 |
</ul> |
| 40 |
{/if} |
| 41 |
</Link> |
| 42 |
<AccountSelector /> |
| 43 |
</ul> |
| 44 |
<ul class="navigation"> |
| 45 |
<Link report="holdings" name={_("Holdings")} key="g h" /> |
| 46 |
<Link report="commodities" name={_("Commodities")} key="g c" /> |
| 47 |
<Link report="documents" name={_("Documents")} key="g d" /> |
| 48 |
<Link |
| 49 |
report="events" |
| 50 |
name={_("Events")} |
| 51 |
key="g E" |
| 52 |
bubble={[upcoming_events_count, "info"]} |
| 53 |
/> |
| 54 |
<Link report="statistics" name={_("Statistics")} key="g s" /> |
| 55 |
</ul> |
| 56 |
<ul class="navigation"> |
| 57 |
<Link report="editor" name={_("Editor")} key="g e"> |
| 58 |
<a |
| 59 |
href="#add-transaction" |
| 60 |
class="secondary add-transaction" |
| 61 |
title={_("Add Journal Entry")} |
| 62 |
use:keyboardShortcut={"n"}>+</a |
| 63 |
> |
| 64 |
</Link> |
| 65 |
{#if $errors.length > 0} |
| 66 |
<Link |
| 67 |
report="errors" |
| 68 |
name={_("Errors")} |
| 69 |
bubble={[$errors.length, "error"]} |
| 70 |
/> |
| 71 |
{/if} |
| 72 |
<Link report="import" name={_("Import")} key="g n"> |
| 73 |
<a href="#export" class="secondary" title={_("Export")}>⬇</a> |
| 74 |
</Link> |
| 75 |
<Link report="options" name={_("Options")} key="g o" /> |
| 76 |
<Link report="help" name={_("Help")} key="g H" /> |
| 77 |
</ul> |
| 78 |
{#if extension_reports.length} |
| 79 |
<ul class="navigation"> |
| 80 |
{#each extension_reports as ext} |
| 81 |
<Link report={`extension/${ext.name}`} name={ext.report_title ?? ""} /> |
| 82 |
{/each} |
| 83 |
</ul> |
| 84 |
{/if} |
| 85 |
|
| 86 |
<style> |
| 87 |
.navigation { |
| 88 |
padding-bottom: 0.5rem; |
| 89 |
margin: 0; |
| 90 |
} |
| 91 |
|
| 92 |
.navigation + .navigation { |
| 93 |
padding-top: 0.5rem; |
| 94 |
border-top: 1px solid var(--sidebar-border); |
| 95 |
} |
| 96 |
|
| 97 |
a { |
| 98 |
display: block; |
| 99 |
padding: 0.25em 0.5em 0.25em 1em; |
| 100 |
color: inherit; |
| 101 |
} |
| 102 |
|
| 103 |
a:hover { |
| 104 |
color: var(--sidebar-hover-color); |
| 105 |
background-color: var(--sidebar-border); |
| 106 |
} |
| 107 |
|
| 108 |
.secondary { |
| 109 |
width: 30px; |
| 110 |
padding: 3px 9px; |
| 111 |
line-height: 22px; |
| 112 |
color: inherit; |
| 113 |
background-color: var(--sidebar-background); |
| 114 |
} |
| 115 |
|
| 116 |
.add-transaction { |
| 117 |
font-size: 23px; |
| 118 |
} |
| 119 |
|
| 120 |
.submenu { |
| 121 |
width: 100%; |
| 122 |
margin: 0 0 0.5em; |
| 123 |
} |
| 124 |
|
| 125 |
.submenu a { |
| 126 |
width: 100%; |
| 127 |
padding-left: 35px; |
| 128 |
} |
| 129 |
|
| 130 |
.submenu li { |
| 131 |
font-size: 0.9em; |
| 132 |
} |
| 133 |
</style> |