re-implemented rendering of document
This commit is contained in:
@@ -48,7 +48,6 @@ import de.srsoftware.umbrella.core.model.Token;
|
|||||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||||
import de.srsoftware.umbrella.documents.model.*;
|
import de.srsoftware.umbrella.documents.model.*;
|
||||||
import de.srsoftware.umbrella.documents.model.Customer;
|
import de.srsoftware.umbrella.documents.model.Customer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
/* © SRSoftware 2025 */
|
/* © SRSoftware 2025 */
|
||||||
package de.srsoftware.umbrella.documents;
|
package de.srsoftware.umbrella.documents;
|
||||||
|
|
||||||
import de.srsoftware.configuration.JsonConfig;
|
|
||||||
import de.srsoftware.document.api.*;
|
|
||||||
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import static de.srsoftware.tools.MimeType.*;
|
import static de.srsoftware.tools.MimeType.*;
|
||||||
import static de.srsoftware.umbrella.core.Constants.ERROR_MISSING_FIELD;
|
import static de.srsoftware.umbrella.core.Constants.ERROR_MISSING_FIELD;
|
||||||
import static de.srsoftware.umbrella.core.Constants.USER;
|
import static de.srsoftware.umbrella.core.Constants.USER;
|
||||||
@@ -17,6 +9,13 @@ import static java.lang.System.Logger.Level.TRACE;
|
|||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.text.MessageFormat.format;
|
import static java.text.MessageFormat.format;
|
||||||
|
|
||||||
|
import de.srsoftware.configuration.JsonConfig;
|
||||||
|
import de.srsoftware.document.api.*;
|
||||||
|
import de.srsoftware.umbrella.core.model.UmbrellaUser;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
public abstract class TemplateDoc implements Document {
|
public abstract class TemplateDoc implements Document {
|
||||||
private static final Pattern TOKEN_PATTERN = Pattern.compile("<\\? (([^?]|\\?[^>])+) \\?>");
|
private static final Pattern TOKEN_PATTERN = Pattern.compile("<\\? (([^?]|\\?[^>])+) \\?>");
|
||||||
private static final Pattern POSITION_PATTERN = Pattern.compile("<!-- positions -->(.*)<!-- positions -->",Pattern.DOTALL);
|
private static final Pattern POSITION_PATTERN = Pattern.compile("<!-- positions -->(.*)<!-- positions -->",Pattern.DOTALL);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package de.srsoftware.umbrella.documents;
|
|||||||
import de.srsoftware.document.api.Document;
|
import de.srsoftware.document.api.Document;
|
||||||
import de.srsoftware.document.api.DocumentFactory;
|
import de.srsoftware.document.api.DocumentFactory;
|
||||||
import de.srsoftware.document.api.DocumentRegistry;
|
import de.srsoftware.document.api.DocumentRegistry;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class TemplateProcessor implements DocumentFactory {
|
public class TemplateProcessor implements DocumentFactory {
|
||||||
|
|||||||
@@ -142,7 +142,7 @@
|
|||||||
<span class="right"><? document.date ?></span>
|
<span class="right"><? document.date ?></span>
|
||||||
</h2>
|
</h2>
|
||||||
<hr/>
|
<hr/>
|
||||||
<div class="head"><? document.head ?></div>
|
<div class="head"><? document.head.rendered ?></div>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th><? Position ?></th>
|
<th><? Position ?></th>
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><? optional ?></td>
|
<td><? optional ?></td>
|
||||||
<td colspan="5" class="description"><? description ?></td>
|
<td colspan="5" class="description"><? description.rendered ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!-- positions -->
|
<!-- positions -->
|
||||||
@@ -191,7 +191,7 @@
|
|||||||
<th class="right"><? document.gross_sum ?></th>
|
<th class="right"><? document.gross_sum ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div class="foot"><? document.footer ?></div>
|
<div class="foot"><? document.footer.rendered ?></div>
|
||||||
<table class="bottom">
|
<table class="bottom">
|
||||||
<tr>
|
<tr>
|
||||||
<td><? document.sender.name ?></td>
|
<td><? document.sender.name ?></td>
|
||||||
|
|||||||
@@ -81,12 +81,7 @@
|
|||||||
|
|
||||||
async function render(){
|
async function render(){
|
||||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${doc.id}/pdf`;
|
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/${doc.id}/pdf`;
|
||||||
const resp = fetch(url,{credentials:'include'});
|
location.href = url;
|
||||||
if (resp.ok){
|
|
||||||
error = null;
|
|
||||||
} else {
|
|
||||||
error = await resp.text();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(loadDoc);
|
onMount(loadDoc);
|
||||||
|
|||||||
Reference in New Issue
Block a user