started to implement updates on transactions
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -9,8 +9,9 @@
|
||||
onclick = evt => { evt.preventDefault(); startEdit(); return false },
|
||||
onSet = newVal => {return true;},
|
||||
title = t('click_to_edit'),
|
||||
type = 'div',
|
||||
value = $bindable(null)
|
||||
type = 'text',
|
||||
value = $bindable(null),
|
||||
wrapper = 'div'
|
||||
} = $props();
|
||||
|
||||
let editing = $state(simple);
|
||||
@@ -110,7 +111,7 @@
|
||||
</style>
|
||||
|
||||
{#if editable && editing}
|
||||
<input bind:value={editValue} onkeyup={typed} {title} autofocus />
|
||||
<input bind:value={editValue} onkeyup={typed} {title} {type} autofocus />
|
||||
{:else}
|
||||
<svelte:element this={type} href={href} onclick={ignore} {onmousedown} {onmouseup} {ontouchstart} {ontouchend} {oncontextmenu} class={{editable}} {title} >{value}</svelte:element>
|
||||
<svelte:element this={wrapper} href={href} onclick={ignore} {onmousedown} {onmouseup} {ontouchstart} {ontouchend} {oncontextmenu} class={{editable}} {title} >{value}</svelte:element>
|
||||
{/if}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import { t } from '../../translations.svelte';
|
||||
|
||||
import EntryForm from './add_entry.svelte';
|
||||
import Transaction from './transaction.svelte';
|
||||
|
||||
let { id } = $props();
|
||||
let account = $state(null);
|
||||
@@ -67,31 +68,7 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each transactions as transaction, i}
|
||||
<tr>
|
||||
<td>{transaction.date}</td>
|
||||
{#each Object.entries(users) as [id,user]}
|
||||
<td class="amount">
|
||||
{#if id == transaction.source.id}
|
||||
{(-transaction.amount).toFixed(2)} {account.currency}
|
||||
{/if}
|
||||
{#if id == transaction.destination.id}
|
||||
{(+transaction.amount).toFixed(2)} {account.currency}
|
||||
{/if}
|
||||
</td>
|
||||
{/each}
|
||||
<td class="party">
|
||||
{#if !transaction.source.id}
|
||||
← {transaction.source.value}
|
||||
{/if}
|
||||
{#if !transaction.destination.id}
|
||||
→ {transaction.destination.value}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="purpose">{transaction.purpose}</td>
|
||||
<td class="tags">
|
||||
{transaction.tags.join(', ')}
|
||||
</td>
|
||||
</tr>
|
||||
<Transaction {account} {transaction} {users} />
|
||||
{/each}
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
49
frontend/src/routes/accounting/transaction.svelte
Normal file
49
frontend/src/routes/accounting/transaction.svelte
Normal file
@@ -0,0 +1,49 @@
|
||||
<script>
|
||||
import LineEditor from '../../Components/LineEditor.svelte';
|
||||
import { api, patch } from '../../urls.svelte';
|
||||
import { error, yikes } from '../../warn.svelte';
|
||||
let { account, transaction, users } = $props();
|
||||
|
||||
async function update(changes){
|
||||
let url = api('accounting/transaction/'+transaction.id);
|
||||
let res = await patch(url,changes);
|
||||
if (res.ok){
|
||||
yikes();
|
||||
return true;
|
||||
}
|
||||
error(res);
|
||||
return false;
|
||||
}
|
||||
|
||||
async function setDate(newDate){
|
||||
return await update({date:newDate});
|
||||
}
|
||||
</script>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<LineEditor type="date" wrapper="span" editable="true" value={transaction.date} onSet={setDate} />
|
||||
</td>
|
||||
{#each Object.entries(users) as [id,user]}
|
||||
<td class="amount">
|
||||
{#if id == transaction.source.id}
|
||||
{(-transaction.amount).toFixed(2)} {account.currency}
|
||||
{/if}
|
||||
{#if id == transaction.destination.id}
|
||||
{(+transaction.amount).toFixed(2)} {account.currency}
|
||||
{/if}
|
||||
</td>
|
||||
{/each}
|
||||
<td class="party">
|
||||
{#if !transaction.source.id}
|
||||
← {transaction.source.value}
|
||||
{/if}
|
||||
{#if !transaction.destination.id}
|
||||
→ {transaction.destination.value}
|
||||
{/if}
|
||||
</td>
|
||||
<td class="purpose">{transaction.purpose}</td>
|
||||
<td class="tags">
|
||||
{transaction.tags.join(', ')}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -36,11 +36,11 @@
|
||||
<span class="symbol {home?'':'inactive'}" onclick={toggleHome}></span>
|
||||
<span class="symbol {work?'':'inactive'}" onclick={toggleWork} ></span>
|
||||
</div>
|
||||
<LineEditor type="span" editable={true} value={address.box} onSet={newVal => onSet(address.box,newVal)} title={t('post_box')} />
|
||||
<LineEditor type="span" editable={true} value={address.ext} onSet={newVal => onSet(address.ext,newVal)} title={t('extended_address')} />
|
||||
<LineEditor type="span" editable={true} value={address.street} onSet={newVal => onSet(address.street,newVal)} title={t('street')} />
|
||||
<LineEditor type="span" editable={true} value={address.post_code} onSet={newVal => onSet(address.post_code,newVal)} title={t('post_code')} />
|
||||
<LineEditor type="span" editable={true} value={address.locality} onSet={newVal => onSet(address.locality,newVal)} title={t('locality')} />
|
||||
<LineEditor type="span" editable={true} value={address.region} onSet={newVal => onSet(address.region,newVal)} title={t('region')} />
|
||||
<LineEditor type="span" editable={true} value={address.country} onSet={newVal => onSet(address.country,newVal)} title={t('country')} />
|
||||
<LineEditor wrapper="span" editable={true} value={address.box} onSet={newVal => onSet(address.box,newVal)} title={t('post_box')} />
|
||||
<LineEditor wrapper="span" editable={true} value={address.ext} onSet={newVal => onSet(address.ext,newVal)} title={t('extended_address')} />
|
||||
<LineEditor wrapper="span" editable={true} value={address.street} onSet={newVal => onSet(address.street,newVal)} title={t('street')} />
|
||||
<LineEditor wrapper="span" editable={true} value={address.post_code} onSet={newVal => onSet(address.post_code,newVal)} title={t('post_code')} />
|
||||
<LineEditor wrapper="span" editable={true} value={address.locality} onSet={newVal => onSet(address.locality,newVal)} title={t('locality')} />
|
||||
<LineEditor wrapper="span" editable={true} value={address.region} onSet={newVal => onSet(address.region,newVal)} title={t('region')} />
|
||||
<LineEditor wrapper="span" editable={true} value={address.country} onSet={newVal => onSet(address.country,newVal)} title={t('country')} />
|
||||
</div>
|
||||
@@ -33,5 +33,5 @@
|
||||
{#if value}
|
||||
<span class="symbol {home?'':'inactive'}" onclick={toggleHome}></span>
|
||||
<span class="symbol {work?'':'inactive'}" onclick={toggleWork} ></span>
|
||||
<LineEditor type="span" editable={true} {value} {onSet} /><br/>
|
||||
<LineEditor wrapper="span" editable={true} {value} {onSet} /><br/>
|
||||
{/if}
|
||||
@@ -19,7 +19,7 @@
|
||||
{#if field.value.includes('\\n')}
|
||||
<MultiLineEditor type="div" editable={true} value={field.value.replaceAll('\\n','\n')} {onSet} title={t(field.name)+' – '+t('right_click_to_edit')} />
|
||||
{:else}
|
||||
<LineEditor type="div" editable={true} value={field.value} {onSet} title={t(field.name)+' – '+t('click_to_edit')} />
|
||||
<LineEditor editable={true} value={field.value} {onSet} title={t(field.name)+' – '+t('click_to_edit')} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -14,5 +14,5 @@
|
||||
</script>
|
||||
|
||||
{#if value}
|
||||
<LineEditor type="span" editable={true} {value} {onSet} title={t('formatted_name')}/>
|
||||
<LineEditor wrapper="span" editable={true} {value} {onSet} title={t('formatted_name')}/>
|
||||
{/if}
|
||||
@@ -16,18 +16,18 @@
|
||||
|
||||
<div class="name">
|
||||
{#if n.prefix}
|
||||
<LineEditor type="span" editable={true} value={n.prefix} onSet={newVal => onSet(n.prefix,newVal)} title={t('name_prefix')} />
|
||||
<LineEditor wrapper="span" editable={true} value={n.prefix} onSet={newVal => onSet(n.prefix,newVal)} title={t('name_prefix')} />
|
||||
{/if}
|
||||
{#if n.given}
|
||||
<LineEditor type="span" editable={true} value={n.given} onSet={newVal => onSet(n.given,newVal)} title={t('given_name')} />
|
||||
<LineEditor wrapper="span" editable={true} value={n.given} onSet={newVal => onSet(n.given,newVal)} title={t('given_name')} />
|
||||
{/if}
|
||||
{#if n.additional}
|
||||
<LineEditor type="span" editable={true} value={n.additional} onSet={newVal => onSet(n.additional,newVal)} title={t('additional_name')} />
|
||||
<LineEditor wrapper="span" editable={true} value={n.additional} onSet={newVal => onSet(n.additional,newVal)} title={t('additional_name')} />
|
||||
{/if}
|
||||
{#if n.family}
|
||||
<LineEditor type="span" editable={true} value={n.family} onSet={newVal => onSet(n.family,newVal)} title={t('family_name')} />
|
||||
<LineEditor wrapper="span" editable={true} value={n.family} onSet={newVal => onSet(n.family,newVal)} title={t('family_name')} />
|
||||
{/if}
|
||||
{#if n.suffix}
|
||||
<LineEditor type="span" editable={true} value={n.suffix} onSet={newVal => onSet(n.suffix,newVal)} title={t('<name_suffix></name_suffix>')} />
|
||||
<LineEditor wrapper="span" editable={true} value={n.suffix} onSet={newVal => onSet(n.suffix,newVal)} title={t('<name_suffix></name_suffix>')} />
|
||||
{/if}
|
||||
</div>
|
||||
@@ -39,5 +39,5 @@
|
||||
<span class="symbol {cell?'':'inactive'}" onclick={toggleCell} ></span>
|
||||
<span class="symbol {home?'':'inactive'}" onclick={toggleHome}></span>
|
||||
<span class="symbol {work?'':'inactive'}" onclick={toggleWork} ></span>
|
||||
<LineEditor type="span" editable={true} {value} {onSet} /><br/>
|
||||
<LineEditor wrapper="span" editable={true} {value} {onSet} /><br/>
|
||||
{/if}
|
||||
@@ -14,5 +14,5 @@
|
||||
</script>
|
||||
|
||||
{#if value}
|
||||
<LineEditor type="span" editable={true} {value} {onSet} title={t('organization')}/>
|
||||
<LineEditor wrapper="span" editable={true} {value} {onSet} title={t('organization')}/>
|
||||
{/if}
|
||||
@@ -14,5 +14,5 @@
|
||||
</script>
|
||||
|
||||
{#if value}
|
||||
<LineEditor type="div" editable={true} {value} {onSet} title={t('url')}/>
|
||||
<LineEditor editable={true} {value} {onSet} title={t('url')}/>
|
||||
{/if}
|
||||
@@ -263,7 +263,7 @@
|
||||
<div class="items">
|
||||
{#if location}
|
||||
<h3>
|
||||
<LineEditor editable={true} bind:value={location.name} type="span" onSet={newName => patchLocation(location,'name',newName)} />
|
||||
<LineEditor editable={true} bind:value={location.name} wrapper="span" onSet={newName => patchLocation(location,'name',newName)} />
|
||||
<button class="symbol" title={t('delete_object',{object:t('location')})} onclick={e => deleteLocation(location)}></button>
|
||||
{#if location.parent_location_id}
|
||||
<button class="symbol" title={t('move_to_top')} onclick={e => moveToTop(location)}></button>
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
</script>
|
||||
|
||||
{#if item}
|
||||
<LineEditor type="h3" editable={true} value={item.name} onSet={v => update('name',v)} />
|
||||
<LineEditor wrapper="h3" editable={true} value={item.name} onSet={v => update('name',v)} />
|
||||
<button class="clone symbol" title={t('clone')} onclick={doClone}></button>
|
||||
<div>
|
||||
{@html item.description.rendered}
|
||||
@@ -80,7 +80,7 @@
|
||||
{t('ID')}
|
||||
</td>
|
||||
<td>
|
||||
<LineEditor type="span" editable={true} value={item.code} onSet={v => update('code',v)} />
|
||||
<LineEditor wrapper="span" editable={true} value={item.code} onSet={v => update('code',v)} />
|
||||
</td>
|
||||
</tr>
|
||||
{#each item.properties.toSorted(byName) as prop}
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
|
||||
{#if !deleted}
|
||||
<li draggable="true" {ondrop} ondragover={e => e.preventDefault()} {ondragstart} class="task {states[task.status]?.toLowerCase()}">
|
||||
<LineEditor bind:value={task.name} onclick={openTask} editable={true} onSet={setName} type="a" href={`/task/${task.id}/view`} />
|
||||
<LineEditor bind:value={task.name} onclick={openTask} editable={true} onSet={setName} wrapper="a" href={`/task/${task.id}/view`} />
|
||||
{#if task.est_time}
|
||||
<span class="estimated_time">({+task.est_time} h)</span>
|
||||
{/if}
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
</span>
|
||||
{/each}
|
||||
</div>
|
||||
<LineEditor value={page.title} type="h2" {editable} onSet={t => patchTitle(t)} />
|
||||
<LineEditor value={page.title} wrapper="h2" {editable} onSet={t => patchTitle(t)} />
|
||||
{#if page.version != page.versions[0]}
|
||||
<span class="warn">{t('not_recent_version')}</span>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user