implemented listing users on task index page

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-11-28 08:49:51 +01:00
parent 21759d1b12
commit 146ea80e4e
2 changed files with 22 additions and 24 deletions

View File

@@ -2,7 +2,7 @@
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js';
import { api, get, patch } from '../../urls.svelte.js';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte.js';
@@ -23,16 +23,10 @@
const prj = projects[task.project_id];
const stat = Object.keys(prj.allowed_states).find(k => prj.allowed_states[k] === state);
const url = api(`task/${tid}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'PATCH',
body : JSON.stringify({status:stat})
});
const resp = await patch(url,{status:stat});
if (resp.ok){
tasks[idx] = await resp.json();
} else {
error(resp);
}
} else error(resp);
}
function abort(idx){
@@ -66,17 +60,15 @@
async function loadProject(pid){
const url = api(`project/${pid}`);
const resp = await fetch(url,{credentials:'include'});
const resp = await get(url);
if (resp.ok){
projects[pid] = await resp.json();
} else {
error(resp);
}
} else error(resp);
}
async function load(){
const url = api(`task?offset=${bounds.offset}&limit=${bounds.limit}`);
const resp = await fetch(url,{credentials:'include'});
const resp = await get(url);
if (resp.ok){
let newTasks = await resp.json();
if (bounds.offset == 0) {
@@ -93,9 +85,7 @@
bounds.offset += bounds.limit;
load();
}
} else {
error(resp);
}
} else error(resp);
}
function open(idx){
@@ -139,13 +129,14 @@
<th>{t('state')}</th>
<th>{t('start_date')}</th>
<th>{t('due_date')}</th>
<th>{t('users')}</th>
<th>{t('actions')}</th>
</tr>
</thead>
<tbody>
{#each tasks as task,idx}
{#if task.status > 10 && task.status < 60 && !task.no_index && projects[task.project_id]?.status < 60 && !hidden[task.id] && filterApplies(task)}
<tr>
<tr title={task.description.source}>
<td onclick={() => go('task',task.id)}>{task.name}</td>
<td>
<a href="#" onclick={() => go('project',task.project_id)}> {projects[task.project_id]?.name}</a>
@@ -162,6 +153,16 @@
<td>
{task.due_date}
</td>
<td>
<ul>
{#each Object.values(task.members) as member}
<li>
{member.user.name}:
{t('permission_'+member.permission.name.toLowerCase())}
</li>
{/each}
</ul>
</td>
<td>
<button class="symbol" onclick={() => edit(task.id)} title={t('edit')} ></button>
<button class="symbol" onclick={() => postpone(idx)} title={t('postpone')} ></button>