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'), caption = t('select_state'),
selected = $bindable(0), selected = $bindable(0),
onchange = (val) => console.log('changed to '+val), onchange = (val) => console.log('changed to '+val),
project_id = '?' project = null
} = $props(); } = $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> </script>
{#if states} {#if project?.allowed_states}
<select bind:value={selected} onchange={() => onchange(selected)}> <select bind:value={selected} onchange={() => onchange(selected)}>
{#each Object.entries(states) as [k,s]} {#each Object.entries(project.allowed_states) as [code,name]}
<option value={+k}>{t('state_'+s.toLowerCase())}</option> <option value={+code}>{t('state_'+name.toLowerCase())}</option>
{/each} {/each}
</select> </select>
{:else}
<span>{message}</span>
{/if} {/if}

View File

@@ -63,7 +63,7 @@
const resp = await fetch(url,{credentials:'include'}); const resp = await fetch(url,{credentials:'include'});
if (resp.ok){ if (resp.ok){
project = await resp.json(); project = await resp.json();
console.log(project); // console.log(project);
error = null; error = null;
loadTasks(); loadTasks();
} else { } else {
@@ -143,7 +143,7 @@
<tr> <tr>
<th>{t('state')}</th> <th>{t('state')}</th>
<td> <td>
<StateSelector selected={project.status} onchange={val => update({status:val})} project_id={id} /> <StateSelector selected={project.status} onchange={val => update({status:val})} {project} />
</td> </td>
</tr> </tr>
{#if project.company} {#if project.company}
@@ -231,4 +231,4 @@
<div class="notes"> <div class="notes">
<h3>{t('notes')}</h3> <h3>{t('notes')}</h3>
<Notes module="project" entity_id={id} /> <Notes module="project" entity_id={id} />
</div> </div>

View File

@@ -186,7 +186,7 @@
<tr> <tr>
<th>{t('state')}</th> <th>{t('state')}</th>
<td> <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> </td>
</tr> </tr>
{#if task.description} {#if task.description}

View File

@@ -73,7 +73,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
head = path.pop(); head = path.pop();
yield switch (head) { yield switch (head) {
case null -> getProject(ex, projectId, user.get()); case null -> getProject(ex, projectId, user.get());
case STATES -> getStateList(ex); case STATES -> super.doGet(path, ex); // TODO THIS SHOULD NO LONGER BE REQUIRED
default -> super.doGet(path, ex); default -> super.doGet(path, ex);
}; };
} }
@@ -138,13 +138,6 @@ public class ProjectModule extends BaseHandler implements ProjectService {
return sendContent(ex,map); return sendContent(ex,map);
} }
private boolean getStateList(HttpExchange ex) throws IOException {
var map = new HashMap<Integer,String>();
for (var status : PREDEFINED) map.put(status.code(),status.name());
map.put(23,"evil");
return sendContent(ex,map);
}
public Map<Long, Project> listCompanyProjects(long companyId, boolean includeClosed) throws UmbrellaException { public Map<Long, Project> listCompanyProjects(long companyId, boolean includeClosed) throws UmbrellaException {
var projectList = projects.ofCompany(companyId, includeClosed); var projectList = projects.ofCompany(companyId, includeClosed);
loadMembers(projectList.values()); loadMembers(projectList.values());