working on extended states

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-08-01 20:48:12 +02:00
parent 2813fed670
commit 0511faa342
4 changed files with 9 additions and 33 deletions

View File

@@ -7,31 +7,14 @@
caption = t('select_state'),
selected = $bindable(0),
onchange = (val) => console.log('changed to '+val),
project_id = '?'
project = null
} = $props();
let message = $state(t('loading'));
let states = $state(null);
async function loadStates(){
const url = api(`project/${project_id}/states`);
const resp = await fetch(url,{credentials: 'include'});
if (resp.ok){
states = await resp.json();
} else {
message = await resp.text();
}
}
onMount(loadStates)
</script>
{#if states}
{#if project?.allowed_states}
<select bind:value={selected} onchange={() => onchange(selected)}>
{#each Object.entries(states) as [k,s]}
<option value={+k}>{t('state_'+s.toLowerCase())}</option>
{#each Object.entries(project.allowed_states) as [code,name]}
<option value={+code}>{t('state_'+name.toLowerCase())}</option>
{/each}
</select>
{:else}
<span>{message}</span>
{/if}