implemented display of document positions
This commit is contained in:
35
frontend/src/routes/document/TemplateSelector.svelte
Normal file
35
frontend/src/routes/document/TemplateSelector.svelte
Normal file
@@ -0,0 +1,35 @@
|
||||
<script>
|
||||
import {onMount} from 'svelte';
|
||||
import {t} from '../../translations.svelte.js';
|
||||
let { caption, company, value = $bindable(0), onchange = () => console.log('changed')} = $props();
|
||||
let message = t('document.loading');
|
||||
let templates = $state(null);
|
||||
|
||||
async function loadTemplates(){
|
||||
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/templates`;
|
||||
var resp = await fetch(url,{
|
||||
credentials: 'include',
|
||||
method: 'POST',
|
||||
body: JSON.stringify({company:company})
|
||||
});
|
||||
if (resp.ok){
|
||||
templates = await resp.json();
|
||||
} else {
|
||||
message = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(loadTemplates)
|
||||
</script>
|
||||
|
||||
{#if templates}
|
||||
<select bind:value onchange={onchange}>
|
||||
<option value={0}>{caption}</option>
|
||||
{#each Object.entries(templates) as [id,template]}
|
||||
<option value={template.id}>{template.name}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<span>{message}</span>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user