|
27 | 27 | let payee = $derived(entry.payee); |
28 | 28 | let narration = $derived(entry.get_narration_tags_links()); |
29 | 29 |
|
| 30 | + let payee_accounts = $derived( |
| 31 | + $payees.includes(payee) |
| 32 | + ? fetch_payee_accounts($ledger_mtime, payee) |
| 33 | + : undefined, |
| 34 | + ); |
| 35 | +
|
30 | 36 | // Autofill complete transactions. |
31 | 37 | async function autocomplete_select_payee() { |
32 | 38 | if (entry.narration || entry.postings.some((p) => !p.is_empty())) { |
|
119 | 125 | <div class="flex-row hide-on-desktop"> |
120 | 126 | <span class="label">{_("Postings")}:</span> |
121 | 127 | </div> |
122 | | -{#each entry.postings, index} |
123 | | - <!-- Using the indexed access (instead of `as posting` in the each) seems to track |
124 | | - the reactivity differently and avoids cursor jumping on the posting inputs. --> |
125 | | - {@const posting = entry.postings[index]} |
126 | | - {#if posting != null} |
127 | | - <PostingSvelte |
128 | | - bind:posting={ |
129 | | - () => posting, |
130 | | - (posting: Posting) => { |
131 | | - entry = entry.set("postings", entry.postings.with(index, posting)); |
132 | | - } |
| 128 | +<!-- eslint-disable-next-line svelte/require-each-key --> |
| 129 | +{#each entry.postings as posting, index} |
| 130 | + <PostingSvelte |
| 131 | + bind:posting={ |
| 132 | + () => posting, |
| 133 | + (posting: Posting) => { |
| 134 | + entry = entry.set("postings", entry.postings.with(index, posting)); |
133 | 135 | } |
134 | | - {index} |
135 | | - suggestions={$payees.includes(payee) |
136 | | - ? fetch_payee_accounts($ledger_mtime, payee).data |
137 | | - : undefined} |
138 | | - date={entry.date} |
139 | | - move={({ from, to }: { from: number; to: number }) => { |
140 | | - entry = entry.set("postings", move(entry.postings, from, to)); |
141 | | - }} |
142 | | - remove={() => { |
143 | | - entry = entry.set("postings", entry.postings.toSpliced(index, 1)); |
144 | | - }} |
145 | | - /> |
146 | | - {/if} |
| 136 | + } |
| 137 | + {index} |
| 138 | + suggestions={payee_accounts?.data} |
| 139 | + date={entry.date} |
| 140 | + move={({ from, to }: { from: number; to: number }) => { |
| 141 | + entry = entry.set("postings", move(entry.postings, from, to)); |
| 142 | + }} |
| 143 | + remove={() => { |
| 144 | + entry = entry.set("postings", entry.postings.toSpliced(index, 1)); |
| 145 | + }} |
| 146 | + /> |
147 | 147 | {/each} |
148 | 148 |
|
149 | 149 | <style> |
|
0 commit comments