workin on document creation: frontend work

This commit is contained in:
2025-07-09 23:49:01 +02:00
parent 003899f75d
commit d68dc991d0
11 changed files with 271 additions and 20 deletions

View File

@@ -0,0 +1,37 @@
<script>
import {onMount} from 'svelte';
import {t} from '../translations.svelte.js';
let { caption, onselect = (contact) => console.log('selected '+contact.FN||contact.ORG) } = $props();
let message = t('contacts.loading');
let contacts = $state(null);
let value = 0;
async function loadContacts(){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/document/contacts`;
var resp = await fetch(url,{ credentials: 'include'});
if (resp.ok){
contacts = await resp.json();
} else {
message = await resp.text();
}
}
function select(){
onselect(contacts[value]);
}
onMount(loadContacts)
</script>
{#if contacts}
<select onchange={select} bind:value>
<option value={0}>{caption}</option>
{#each contacts as contact,idx}
<option value={idx}>{contact.FN||contact.ORG}</option>
{/each}
</select>
{:else}
<span>{message}</span>
{/if}

View File

@@ -14,7 +14,6 @@ async function fetchModules(){
if (resp.ok){
const arr = await resp.json();
for (let entry of arr) modules.push({name:t('menu.'+entry.module),url:entry.url});
console.log(modules);
} else {
console.log('error');
}