working on extended states
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -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}
|
||||
@@ -63,7 +63,7 @@
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
project = await resp.json();
|
||||
console.log(project);
|
||||
// console.log(project);
|
||||
error = null;
|
||||
loadTasks();
|
||||
} else {
|
||||
@@ -143,7 +143,7 @@
|
||||
<tr>
|
||||
<th>{t('state')}</th>
|
||||
<td>
|
||||
<StateSelector selected={project.status} onchange={val => update({status:val})} project_id={id} />
|
||||
<StateSelector selected={project.status} onchange={val => update({status:val})} {project} />
|
||||
</td>
|
||||
</tr>
|
||||
{#if project.company}
|
||||
@@ -231,4 +231,4 @@
|
||||
<div class="notes">
|
||||
<h3>{t('notes')}</h3>
|
||||
<Notes module="project" entity_id={id} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
<tr>
|
||||
<th>{t('state')}</th>
|
||||
<td>
|
||||
<StateSelector selected={task.status} onchange={val => update({status:val})} project_id={task.project_id} />
|
||||
<StateSelector selected={task.status} onchange={val => update({status:val})} {project} />
|
||||
</td>
|
||||
</tr>
|
||||
{#if task.description}
|
||||
|
||||
Reference in New Issue
Block a user