implemented changing project state from project page

This commit is contained in:
2025-07-20 14:48:51 +02:00
parent 680afd7700
commit c8b6c3feb7
9 changed files with 75 additions and 9 deletions

View File

@@ -0,0 +1,30 @@
<script>
import {onMount} from 'svelte';
import {t} from '../translations.svelte.js';
let { caption = t('select_state'), selected = $bindable(0), onchange = (val) => console.log('changed to '+val)} = $props();
let message = $state(t('loading'));
let states = $state(null);
async function loadStates(){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/task/states`;
var resp = await fetch(url,{credentials: 'include'});
if (resp.ok){
states = await resp.json();
} else {
message = await resp.text();
}
}
onMount(loadStates)
</script>
{#if states}
<select bind:value={selected} onchange={() => onchange(selected)}>
{#each Object.entries(states) as [k,s]}
<option value={+k}>{t('state_'+s.toLowerCase())}</option>
{/each}
</select>
{:else}
<span>{message}</span>
{/if}

View File

@@ -4,6 +4,7 @@
import TaskList from '../../Components/TaskList.svelte';
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
import LineEditor from '../../Components/LineEditor.svelte';
import StateSelector from '../../Components/StateSelector.svelte';
let { id } = $props();
let project = $state(null);
@@ -69,6 +70,12 @@
<LineEditor bind:value={project.name} editable={true} onSet={val => update({name:val})} />
</td>
</tr>
<tr>
<th>{t('state')}</th>
<td>
<StateSelector selected={project.status.code} onchange={val => update({status:val})}/>
</td>
</tr>
{#if project.company}
<tr>
<th>{t('company')}</th>