implemented selector for document state
This commit is contained in:
@@ -9,13 +9,17 @@ import java.util.regex.Pattern;
|
||||
public class Constants {
|
||||
private Constants(){}
|
||||
|
||||
|
||||
public static final Pattern POST_CODE = compile("(.*\\w+.*)\n(.*\\d+.*)\n(\\d{5}) (\\w+)",DOTALL);
|
||||
|
||||
public static final String COMPANIES = "companies";
|
||||
public static final String COMPANY = "company";
|
||||
|
||||
public static final String CONFIG_DATABASE = "umbrella.modules.document.database";
|
||||
public static final String CONTACTS = "contacts";
|
||||
public static final String CUSTOMERS = "customers";
|
||||
|
||||
public static final String ERROR_ADDRESS_MISSING = "{0} address does not contain street address / post code / city";
|
||||
public static final String PROJECT_ID = "project_id";
|
||||
|
||||
|
||||
public static final String FIELD_AMOUNT = "amount";
|
||||
@@ -75,6 +79,9 @@ public class Constants {
|
||||
public static final String PATH_POSITIONS = "positions";
|
||||
public static final String PATH_SEND = "send";
|
||||
public static final String PATH_TYPES = "types";
|
||||
public static final String PROJECT_ID = "project_id";
|
||||
|
||||
public static final String STATES = "states";
|
||||
|
||||
public static final String TABLE_COMPANY_SETTINGS = "company_settings";
|
||||
public static final String TABLE_CUSTOMER_SETTINGS = "company_customer_settings";
|
||||
@@ -84,7 +91,4 @@ public class Constants {
|
||||
public static final String TABLE_PRICES = "customer_prices";
|
||||
public static final String TABLE_TEMPLATES = "templates";
|
||||
|
||||
public static final String COMPANIES = "companies";
|
||||
public static final String COMPANY = "company";
|
||||
public static final String CUSTOMERS = "customers";
|
||||
}
|
||||
|
||||
@@ -28,8 +28,11 @@ import de.srsoftware.umbrella.documents.model.*;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@@ -92,6 +95,7 @@ public class DocumentApi extends BaseHandler {
|
||||
case COMPANIES -> getCompanies(ex,user.get(),token.orElse(null));
|
||||
case CONTACTS -> getContacts(ex,user.get(),token.orElse(null));
|
||||
case PATH_TYPES -> getDocTypes(ex);
|
||||
case STATES -> getDocStates(ex);
|
||||
case null -> super.doGet(path,ex);
|
||||
default -> {
|
||||
try {
|
||||
@@ -136,6 +140,11 @@ public class DocumentApi extends BaseHandler {
|
||||
return sendContent(ex,getLegacyContacts(ex,user,token));
|
||||
}
|
||||
|
||||
private boolean getDocStates(HttpExchange ex) throws IOException {
|
||||
var map = Stream.of(Document.State.values()).collect(Collectors.toMap(Document.State::code, Document.State::name));
|
||||
return sendContent(ex,map);
|
||||
}
|
||||
|
||||
private boolean getDocTypes(HttpExchange ex) throws UmbrellaException, IOException {
|
||||
var types = db.listTypes();
|
||||
var map = types.values().stream().collect(Collectors.toMap(Type::id, Type::name));
|
||||
|
||||
@@ -85,8 +85,7 @@
|
||||
<th>{t('document.state')}</th>
|
||||
<th>
|
||||
{t('document.actions')}
|
||||
{docType}
|
||||
<TypeSelector caption={t('document.create_new')} bind:value={docType} onchange={createDoc}/>
|
||||
<TypeSelector caption={t('document.create_new')} bind:value={docType} onchange={createDoc} />
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -1,7 +1,30 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import {onMount} from 'svelte';
|
||||
import {t} from '../../translations.svelte.js';
|
||||
let { caption = t('document.select_state'), selected = $bindable(0), onchange = (val) => console.log('changed to '+val)} = $props();
|
||||
|
||||
let message = $state(t('document.loading'));
|
||||
let states = $state(null);
|
||||
|
||||
async function loadStates(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/states`;
|
||||
var resp = await fetch(url,{credentials: 'include'});
|
||||
if (resp.ok){
|
||||
states = await resp.json();
|
||||
} else {
|
||||
message = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(loadStates)
|
||||
</script>
|
||||
|
||||
<select>
|
||||
<option>{t('document.select_type')}</option>
|
||||
</select>
|
||||
{#if states}
|
||||
<select bind:value={selected} onchange={() => onchange(selected)}>
|
||||
{#each Object.entries(states) as [k,s]}
|
||||
<option value={+k}>{t('document.state_'+s.toLowerCase())}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<span>{message}</span>
|
||||
{/if}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
async function loadTypes(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/types`;
|
||||
var resp = await fetch(url,{ credentials: 'include'});
|
||||
var resp = await fetch(url,{credentials: 'include'});
|
||||
if (resp.ok){
|
||||
types = await resp.json();
|
||||
} else {
|
||||
@@ -16,8 +16,6 @@
|
||||
}
|
||||
|
||||
onMount(loadTypes)
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
{#if types}
|
||||
|
||||
@@ -17,6 +17,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
function changeState(newVal){
|
||||
if (doc.state == 1 || confirm(t('document.confirm_state'))){
|
||||
doc.state = newVal;
|
||||
} else {
|
||||
const dummy = doc.state;
|
||||
doc.state = null; // we need to alter in between,
|
||||
doc.state = dummy; // otherwise the state will not be re-set
|
||||
}
|
||||
}
|
||||
|
||||
onMount(loadDoc);
|
||||
</script>
|
||||
|
||||
@@ -25,7 +35,7 @@
|
||||
{/if}
|
||||
|
||||
{#if doc}
|
||||
<fieldset>
|
||||
<fieldset class="left">
|
||||
<legend>{t('document.customer')}</legend>
|
||||
<div>
|
||||
{#each doc.customer.name.split("\n") as line}
|
||||
@@ -42,7 +52,7 @@
|
||||
<span>{t('document.email',doc.customer.email)}</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<fieldset class="left">
|
||||
<legend>{t('document.sender')}</legend>
|
||||
<div>
|
||||
{#each doc.sender.name.split("\n") as line}
|
||||
@@ -56,18 +66,23 @@
|
||||
<span>{t('document.tax_id',doc.sender.tax_id)}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span>{t('document.bank_account',doc.sender.bank_account)}</span>
|
||||
<span>
|
||||
{t('document.bank_account')}:
|
||||
{#each doc.sender.bank_account.split("\n") as line}
|
||||
{line}<br/>
|
||||
{/each}
|
||||
</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<fieldset class="left">
|
||||
<legend>{t('document.type_'+doc.type)}</legend>
|
||||
<div>{t('document.number')}: {doc.number}</div>
|
||||
<div>{t('document.state')}: <StateSelector /></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.template')}: {doc.template.name} <span class="error">SElektor hier!</span></div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<fieldset class="clear">
|
||||
<legend>{t('document.head')}</legend>
|
||||
{doc.head}
|
||||
</fieldset>
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
"sender_tax_id": "Steuernummer",
|
||||
"state": "Status",
|
||||
"state_declined": "abgelehnt",
|
||||
"state_delayed": "verspätet",
|
||||
"state_error": "Fehler",
|
||||
"state_new":"neu",
|
||||
"state_payed": "bezahlt",
|
||||
"state_sent": "versendet",
|
||||
|
||||
@@ -49,4 +49,11 @@ fieldset[tabindex="0"]{
|
||||
|
||||
fieldset[tabindex="0"]:focus-within{
|
||||
max-height: unset;
|
||||
}
|
||||
.left{
|
||||
float: left;
|
||||
}
|
||||
|
||||
.clear{
|
||||
clear: both;
|
||||
}
|
||||
Reference in New Issue
Block a user