implemented selector for document state
This commit is contained in:
@@ -9,13 +9,17 @@ import java.util.regex.Pattern;
|
|||||||
public class Constants {
|
public class Constants {
|
||||||
private Constants(){}
|
private Constants(){}
|
||||||
|
|
||||||
|
|
||||||
public static final Pattern POST_CODE = compile("(.*\\w+.*)\n(.*\\d+.*)\n(\\d{5}) (\\w+)",DOTALL);
|
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 CONFIG_DATABASE = "umbrella.modules.document.database";
|
||||||
public static final String CONTACTS = "contacts";
|
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 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";
|
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_POSITIONS = "positions";
|
||||||
public static final String PATH_SEND = "send";
|
public static final String PATH_SEND = "send";
|
||||||
public static final String PATH_TYPES = "types";
|
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_COMPANY_SETTINGS = "company_settings";
|
||||||
public static final String TABLE_CUSTOMER_SETTINGS = "company_customer_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_PRICES = "customer_prices";
|
||||||
public static final String TABLE_TEMPLATES = "templates";
|
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.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -92,6 +95,7 @@ public class DocumentApi extends BaseHandler {
|
|||||||
case COMPANIES -> getCompanies(ex,user.get(),token.orElse(null));
|
case COMPANIES -> getCompanies(ex,user.get(),token.orElse(null));
|
||||||
case CONTACTS -> getContacts(ex,user.get(),token.orElse(null));
|
case CONTACTS -> getContacts(ex,user.get(),token.orElse(null));
|
||||||
case PATH_TYPES -> getDocTypes(ex);
|
case PATH_TYPES -> getDocTypes(ex);
|
||||||
|
case STATES -> getDocStates(ex);
|
||||||
case null -> super.doGet(path,ex);
|
case null -> super.doGet(path,ex);
|
||||||
default -> {
|
default -> {
|
||||||
try {
|
try {
|
||||||
@@ -136,6 +140,11 @@ public class DocumentApi extends BaseHandler {
|
|||||||
return sendContent(ex,getLegacyContacts(ex,user,token));
|
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 {
|
private boolean getDocTypes(HttpExchange ex) throws UmbrellaException, IOException {
|
||||||
var types = db.listTypes();
|
var types = db.listTypes();
|
||||||
var map = types.values().stream().collect(Collectors.toMap(Type::id, Type::name));
|
var map = types.values().stream().collect(Collectors.toMap(Type::id, Type::name));
|
||||||
|
|||||||
@@ -85,8 +85,7 @@
|
|||||||
<th>{t('document.state')}</th>
|
<th>{t('document.state')}</th>
|
||||||
<th>
|
<th>
|
||||||
{t('document.actions')}
|
{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>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
@@ -1,7 +1,30 @@
|
|||||||
<script>
|
<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>
|
</script>
|
||||||
|
|
||||||
<select>
|
{#if states}
|
||||||
<option>{t('document.select_type')}</option>
|
<select bind:value={selected} onchange={() => onchange(selected)}>
|
||||||
</select>
|
{#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(){
|
async function loadTypes(){
|
||||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/types`;
|
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){
|
if (resp.ok){
|
||||||
types = await resp.json();
|
types = await resp.json();
|
||||||
} else {
|
} else {
|
||||||
@@ -16,8 +16,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMount(loadTypes)
|
onMount(loadTypes)
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if types}
|
{#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);
|
onMount(loadDoc);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -25,7 +35,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if doc}
|
{#if doc}
|
||||||
<fieldset>
|
<fieldset class="left">
|
||||||
<legend>{t('document.customer')}</legend>
|
<legend>{t('document.customer')}</legend>
|
||||||
<div>
|
<div>
|
||||||
{#each doc.customer.name.split("\n") as line}
|
{#each doc.customer.name.split("\n") as line}
|
||||||
@@ -42,7 +52,7 @@
|
|||||||
<span>{t('document.email',doc.customer.email)}</span>
|
<span>{t('document.email',doc.customer.email)}</span>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset class="left">
|
||||||
<legend>{t('document.sender')}</legend>
|
<legend>{t('document.sender')}</legend>
|
||||||
<div>
|
<div>
|
||||||
{#each doc.sender.name.split("\n") as line}
|
{#each doc.sender.name.split("\n") as line}
|
||||||
@@ -56,18 +66,23 @@
|
|||||||
<span>{t('document.tax_id',doc.sender.tax_id)}</span>
|
<span>{t('document.tax_id',doc.sender.tax_id)}</span>
|
||||||
</div>
|
</div>
|
||||||
<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>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset class="left">
|
||||||
<legend>{t('document.type_'+doc.type)}</legend>
|
<legend>{t('document.type_'+doc.type)}</legend>
|
||||||
<div>{t('document.number')}: {doc.number}</div>
|
<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.date')}: {doc.date}</div>
|
||||||
<div>{t('document.delivery')}: {doc.delivery}</div>
|
<div>{t('document.delivery')}: {doc.delivery}</div>
|
||||||
<div>{t('document.template')}: {doc.template.name} <span class="error">SElektor hier!</span></div>
|
<div>{t('document.template')}: {doc.template.name} <span class="error">SElektor hier!</span></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset class="clear">
|
||||||
<legend>{t('document.head')}</legend>
|
<legend>{t('document.head')}</legend>
|
||||||
{doc.head}
|
{doc.head}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
"sender_tax_id": "Steuernummer",
|
"sender_tax_id": "Steuernummer",
|
||||||
"state": "Status",
|
"state": "Status",
|
||||||
"state_declined": "abgelehnt",
|
"state_declined": "abgelehnt",
|
||||||
|
"state_delayed": "verspätet",
|
||||||
|
"state_error": "Fehler",
|
||||||
"state_new":"neu",
|
"state_new":"neu",
|
||||||
"state_payed": "bezahlt",
|
"state_payed": "bezahlt",
|
||||||
"state_sent": "versendet",
|
"state_sent": "versendet",
|
||||||
|
|||||||
@@ -49,4 +49,11 @@ fieldset[tabindex="0"]{
|
|||||||
|
|
||||||
fieldset[tabindex="0"]:focus-within{
|
fieldset[tabindex="0"]:focus-within{
|
||||||
max-height: unset;
|
max-height: unset;
|
||||||
|
}
|
||||||
|
.left{
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.clear{
|
||||||
|
clear: both;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user