made all document fields editable

This commit is contained in:
2025-07-11 23:13:09 +02:00
parent 2a7e9df334
commit e3e4dc16f9
5 changed files with 94 additions and 27 deletions

View File

@@ -11,7 +11,6 @@ import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.tools.Path;
import de.srsoftware.tools.PathHandler;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;

View File

@@ -37,5 +37,5 @@
{#if editable && editing}
<input bind:value={editValue} onkeyup={typed} autofocus />
{:else}
<div onclick={startEdit}>{value}</div>
<span onclick={startEdit}>{value}</span>
{/if}

View File

@@ -0,0 +1,50 @@
<script>
let { editable = false, value = $bindable(null) } = $props();
let editing = $state(false);
let editValue = $state(value);
let timer = null;
function applyEdit(){
value = editValue;
editing = false;
}
function resetEdit(){
editing = false;
editValue = value;
}
function startEdit(){
editing = editable;
}
function typed(ev){
if (ev.keyCode == 13 && ev.ctrlKey) applyEdit();
if (ev.keyCode == 27) resetEdit();
}
</script>
<style>
textarea{
width: 100%;
min-height: 100px;
}
div{
min-width: 40px;
min-height: 20px;
}
div:hover{
border: 1px dotted;
}
</style>
{#if editable && editing}
<textarea bind:value={editValue} onkeyup={typed} autofocus></textarea>
{:else}
<div onclick={startEdit}>
{#each value.split("\n") as line}
{line}<br/>
{/each}
</div>
{/if}

View File

@@ -2,10 +2,12 @@
import { onMount } from 'svelte';
import { t } from '../../translations.svelte.js';
import { useTinyRouter } from 'svelte-tiny-router';
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
import PositionList from './PositionList.svelte';
import StateSelector from './StateSelector.svelte';
import TemplateSelector from './TemplateSelector.svelte';
import LineEditor from '../../Components/LineEditor.svelte';
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
import MultilineEditor from '../../Components/MultilineEditor.svelte';
import PositionList from './PositionList.svelte';
import StateSelector from './StateSelector.svelte';
import TemplateSelector from './TemplateSelector.svelte';
let { id } = $props();
let error = null;
let doc = $state(null);
@@ -47,22 +49,26 @@
<tbody>
<tr>
<td colspan="2">
{#each doc.customer.name.split("\n") as line}
{line}<br/>
{/each}
<MultilineEditor bind:value={doc.customer.name} editable={editable} />
</td>
</tr>
<tr>
<th>{t('document.customer_id')}:</th>
<td>{doc.customer.id}</td>
<td>
<LineEditor bind:value={doc.customer.id} editable={editable} />
</td>
</tr>
<tr>
<th>{t('document.tax_id')}:</th>
<td>{doc.customer.tax_id}</td>
<td>
<LineEditor bind:value={doc.customer.tax_id} editable={editable} />
</td>
</tr>
<tr>
<th>{t('document.email')}:</th>
<td>{doc.customer.email}</td>
<td>
<LineEditor bind:value={doc.customer.email} editable={editable} />
</td>
</tr>
</tbody>
</table>
@@ -73,25 +79,25 @@
<tbody>
<tr>
<td colspan="2">
{#each doc.sender.name.split("\n") as line}
{line}<br/>
{/each}
<MultilineEditor bind:value={doc.sender.name} editable={editable} />
</td>
</tr>
<tr>
<th>{t('document.court')}:</th>
<td>{doc.sender.court}</td>
<td>
<LineEditor bind:value={doc.sender.court} editable={editable} />
</td>
</tr>
<tr>
<th>{t('document.tax_id')}:</th>
<td>{doc.sender.tax_id}</td>
<td>
<LineEditor bind:value={doc.sender.tax_id} editable={editable} />
</td>
</tr>
<tr>
<th>{t('document.bank_account')}:</th>
<td>
{#each doc.sender.bank_account.split("\n") as line}
{line}<br/>
{/each}
<MultilineEditor bind:value={doc.sender.bank_account} editable={editable} />
</td>
</tr>
</tbody>
@@ -99,10 +105,22 @@
</fieldset>
<fieldset class="left">
<legend>{t('document.type_'+doc.type)}</legend>
<div>{t('document.number')}: {doc.number}</div>
<div>{t('document.state')}: <StateSelector selected={doc.state} onchange={changeState} /></div>
<div>{t('document.date')}: {doc.date}</div>
<div>{t('document.delivery')}: {doc.delivery}</div>
<div>
{t('document.number')}:
<LineEditor bind:value={doc.number} editable={editable} />
</div>
<div>
{t('document.state')}:
<StateSelector selected={doc.state} onchange={changeState} />
</div>
<div>
{t('document.date')}:
<LineEditor bind:value={doc.date} editable={editable} />
</div>
<div>
{t('document.delivery')}:
<LineEditor bind:value={doc.delivery} editable={editable} />
</div>
<div>{t('document.template')}: <TemplateSelector company={doc.company.id} bind:value={doc.template.id} /></div>
</fieldset>
<fieldset class="clear">

View File

@@ -1,5 +1,8 @@
/* © SRSoftware 2025 */
package de.srsoftware.umbrella.markdown;
import static de.srsoftware.tools.MimeType.MIME_HTML;
import com.sun.net.httpserver.HttpExchange;
import de.srsoftware.tools.Path;
import de.srsoftware.tools.SessionToken;
@@ -8,12 +11,9 @@ import de.srsoftware.umbrella.core.Util;
import de.srsoftware.umbrella.core.api.UserService;
import de.srsoftware.umbrella.core.exceptions.UmbrellaException;
import de.srsoftware.umbrella.core.model.Token;
import java.io.IOException;
import java.util.Optional;
import static de.srsoftware.tools.MimeType.MIME_HTML;
public class MarkdownApi extends BaseHandler {
private final UserService users;