Compare commits

...

6 Commits

Author SHA1 Message Date
StephanRichter 098811547a Merge branch 'module/projects' into dev
Build Docker Image / Docker-Build (push) Successful in 5m20s
Build Docker Image / Clean-Registry (push) Successful in 3s
2026-05-11 20:14:32 +02:00
StephanRichter 9bec33d5de implemented editing of custom states
Build Docker Image / Docker-Build (push) Successful in 3m32s
Build Docker Image / Clean-Registry (push) Successful in 1s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-11 20:14:24 +02:00
StephanRichter 6193b727bd Merge branch 'module/projects' into dev
Build Docker Image / Docker-Build (push) Successful in 3m5s
Build Docker Image / Clean-Registry (push) Successful in 3s
2026-05-07 18:26:44 +02:00
StephanRichter f35882c967 bugfix: moving of tasks in tree now works as intended
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-07 18:26:37 +02:00
StephanRichter 1d1520534c Merge branch 'module/notes' into dev
Build Docker Image / Docker-Build (push) Successful in 3m7s
Build Docker Image / Clean-Registry (push) Successful in 2s
2026-05-06 09:26:13 +02:00
StephanRichter fe57749d9c improving note lsit
Build Docker Image / Docker-Build (push) Successful in 2m39s
Build Docker Image / Clean-Registry (push) Successful in 3s
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
2026-05-06 09:25:45 +02:00
10 changed files with 65 additions and 88 deletions
+2 -1
View File
@@ -33,6 +33,7 @@
authors = {...authors, ...data.authors};
loader.offset += loader.limit;
loader.active = false;
console.log({authors});
yikes();
if (Object.keys(data.notes).length) onscroll(null); // when notes were received, check whether they fill up the page
@@ -78,4 +79,4 @@
</svelte:head>
<svelte:window {onscroll} />
<List {notes} />
<List {notes} {authors} />
+1
View File
@@ -64,6 +64,7 @@
<legend class="entity" onclick={() => goToEntity(note)}>{title(note)}</legend>
{/if}
<legend class="time">
{#if !module} {authors[note.user_id].name} {/if}
{note.timestamp.replace('T',' ')}
{#if user.id == note.user_id}
<button class="symbol" onclick={() => drop(note.id)}></button>
+20 -12
View File
@@ -2,7 +2,7 @@
import { onMount, onDestroy } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api, eventStream } from '../../urls.svelte';
import { api, eventStream, patch, post } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
@@ -35,11 +35,7 @@
async function addState(){
const url = api(`project/${id}/state`);
const resp = await fetch(url,{
credentials: 'include',
method: 'POST',
body: JSON.stringify(new_state)
});
const resp = await post(url,new_state);
if (resp.ok){
const json = await resp.json();
project.allowed_states[json.code] = json.name;
@@ -139,11 +135,7 @@
async function update(data){
const url = api(`project/${id}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'PATCH',
body : JSON.stringify(data)
});
const resp = await patch(url,data);
if (resp.ok){
yikes();
project = await resp.json();
@@ -160,6 +152,20 @@
update({members:members});
}
async function updateStateName(state_id,name){
const url = api(`project/${id}/state`);
const resp = await patch(url,{id:state_id,name});
if (resp.ok){
const json = await resp.json();
project.allowed_states[json.code]=json.name;
yikes();
return true;
} else {
error(resp);
return false;
}
}
function showClosed(){
show_closed = !show_closed;
loadTasks();
@@ -243,7 +249,9 @@
{/if}
{key}
</div>
<div>{project.allowed_states[key]}</div>
<div>
<LineEditor value={project.allowed_states[key]} editable={true} onSet={newName => updateStateName(+key,newName)} />
</div>
{/each}
<div>
<input type="number" bind:value={new_state.code} />
+2 -6
View File
@@ -2,7 +2,7 @@
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api, get } from '../../urls.svelte.js';
import { api, get, post } from '../../urls.svelte.js';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte.js';
import { user } from '../../user.svelte.js';
@@ -104,11 +104,7 @@
async function saveTask(){
const url = api('task/add');
const resp = await fetch(url,{
credentials : 'include',
method : 'POST',
body : JSON.stringify(task)
});
const resp = await post(url,task);
if (resp.ok) {
localStorage.removeItem(`task/${task.id}/description`);
if (!assignee) { // if assignee is set, this form was opened within an external context. hence we don`t want to navigate somewhere else!
+6 -23
View File
@@ -3,7 +3,7 @@
import { useTinyRouter } from 'svelte-tiny-router';
import { dragged } from './dragndrop.svelte';
import { api } from '../../urls.svelte';
import { api, drop, patch, post } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
import { timetrack } from '../../user.svelte';
@@ -47,10 +47,7 @@
async function deleteTask(){
if (confirm(t('confirm_delete',{element:task.name}))){
const url = api(`task/${task.id}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'DELETE'
});
const resp = await drop(url);
if (resp.ok){
deleted = true;
} else {
@@ -70,11 +67,7 @@
ev.stopPropagation();
if (dragged.element.id == task.id) return;
const url = api(`task/${dragged.element.id}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'PATCH',
body : JSON.stringify({ parent_task_id : task.id})
});
const resp = await patch(url, { parent_task_id : task.id});
if (resp.ok) {
yikes();
} else {
@@ -90,11 +83,7 @@
show_closed : show_closed
};
if (task.show_closed) data.show_closed = true;
const resp = await fetch(url,{
credentials : 'include',
method : 'POST',
body : JSON.stringify(data)
});
const resp = await post(url,data);
if (resp.ok){
children = await resp.json();
yikes();
@@ -112,11 +101,7 @@
async function patchTask(changeset){
const url = api(`task/${task.id}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'PATCH',
body : JSON.stringify(changeset)
});
const resp = await patch(url,changeset);
if (resp.ok){
task = await resp.json();
return true;
@@ -145,9 +130,7 @@
if (children && lastEvent && lastEvent.task) {
if (lastEvent.event == 'delete' || lastEvent.task.parent_task_id != task.id){
delete children[lastEvent.task.id];
} else {
children[lastEvent.task.id] = lastEvent.task;
}
} else children[lastEvent.task.id] = lastEvent.task;
}
});
+8 -18
View File
@@ -2,7 +2,7 @@
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte';
import { api, get, patch, post } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
@@ -17,7 +17,7 @@
async function add(new_task_id){
let url = api(`task/${new_task_id}`);
let resp = await fetch(url,{ credentials : 'include' });
let resp = await get(url);
if (resp.ok){
yikes();
let newTask = await resp.json();
@@ -27,7 +27,7 @@
}
task.required_tasks_ids.push(new_task_id);
requiredTasks[new_task_id] = newTask;
await patch();
await update();
delete candidates[new_task_id];
} else {
error(resp);
@@ -59,17 +59,11 @@
async function loadTasks(){
if (!task || !task.required_tasks_ids || !task.required_tasks_ids.length) return;
const url = api('task/list');
const res = await fetch(url,{
credentials : 'include',
method : 'POST',
body : JSON.stringify({ids:task.required_tasks_ids})
});
const res = await post(url,{ids:task.required_tasks_ids});
if (res.ok){
yikes();
requiredTasks = await res.json();
} else {
error(resp);
}
} else error(resp);
}
function oninput(){
@@ -84,19 +78,15 @@
return false;
}
async function patch(){
async function update(){
const url = api(`task/${task.id}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'PATCH',
body : JSON.stringify({required_tasks_ids:task.required_tasks_ids})
});
const resp = await patch(url,{required_tasks_ids:task.required_tasks_ids});
if (!resp.ok) error(resp);
}
async function unlink(required_task){
task.required_tasks_ids = task.required_tasks_ids.filter(item => item != required_task.id);
patch();
update();
delete requiredTasks[required_task.id];
}
+1 -1
View File
@@ -8,7 +8,7 @@
</script>
<ul>
{#each sortedTasks as task}
{#each sortedTasks as task (task.id)}
<ListTask {states} {task} {lastEvent} siblings={tasks} {est_time} show_closed={show_closed || task.show_closed} />
{/each}
</ul>
+10 -26
View File
@@ -2,7 +2,7 @@
import { onDestroy } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api, eventStream } from '../../urls.svelte';
import { api, eventStream, get, patch, post } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
import { timetrack } from '../../user.svelte.js';
@@ -99,32 +99,24 @@
parent_task_id : +task.id,
show_closed : show_closed
};
const resp = await fetch(url,{
credentials : 'include',
method : 'POST',
body:JSON.stringify(data)
});
const resp = await post(url,data);
if (resp.ok){
yikes();
children = await resp.json();
} else {
error(resp);
}
} else error(resp);
}
async function loadParent(){
const url = api(`task/${task.parent_task_id}`);
const resp = await fetch(url,{credentials:'include'});
const resp = await get(url);
if (resp.ok){
task.parent = await resp.json();
} else {
error(resp);
}
} else error(resp);
}
async function loadTask(){
const url = api(`task/${id}`);
const resp = await fetch(url,{credentials:'include'});
const resp = await get(url);
if (resp.ok){
yikes();
task = await resp.json();
@@ -132,20 +124,16 @@
loadChildren();
if (task.project_id) loadProject();
if (task.parent_task_id) loadParent();
} else {
error(resp);
}
} else error(resp);
}
async function loadProject(){
const url = api(`project/${task.project_id}`);
const resp = await fetch(url,{credentials:'include'});
const resp = await get(url);
if (resp.ok){
project = await resp.json();
yikes();
} else {
error(await resp.text());
}
} else error(await resp.text());
}
function showClosed(){
@@ -169,11 +157,7 @@
async function update(data){
const url = api(`task/${id}`);
const resp = await fetch(url,{
credentials : 'include',
method : 'PATCH',
body : JSON.stringify(data)
});
const resp = await patch(url,data);
if (resp.ok){
yikes();
let json = await resp.json();
@@ -97,6 +97,7 @@ public class ProjectModule extends BaseHandler implements ProjectService {
head = path.pop();
yield switch (head){
case null -> patchProject(ex,projectId,user.get());
case Path.STATE -> patchProjectState(ex,projectId,user.get());
default -> super.doPatch(path,ex);
};
}
@@ -229,6 +230,19 @@ public class ProjectModule extends BaseHandler implements ProjectService {
return sendContent(ex,project.toMap());
}
private boolean patchProjectState(HttpExchange ex, long projectId, UmbrellaUser user) throws IOException {
var project = loadMembers(projectDb.load(projectId));
if (!project.hasMember(user)) throw notAmember(t(PROJECT_WITH_ID,ID,project.name()));
var json = json(ex);
if (!json.has(ID)) throw missingField(ID);
if (!json.has(NAME)) throw missingField(NAME);
if (!(json.get(ID) instanceof Number fieldId)) throw invalidField(ID,Text.NUMBER);
var newName = json.getString(NAME);
if (newName.isBlank()) throw invalidField(NAME, STRING);
var newState = new Status(newName,fieldId.intValue());
return sendContent(ex, projectDb.save(projectId,newState));
}
private boolean postNewState(HttpExchange ex, long projectId, UmbrellaUser user) throws IOException {
var project = loadMembers(load(projectId));
@@ -267,7 +267,7 @@ CREATE TABLE IF NOT EXISTS {0} (
@Override
public Status save(long projectId, Status newState) {
try {
insertInto(TABLE_CUSTOM_STATES, PROJECT_ID, Field.CODE, NAME).values(projectId,newState.code(),newState.name()).execute(db).close();
replaceInto(TABLE_CUSTOM_STATES, PROJECT_ID, Field.CODE, NAME).values(projectId,newState.code(),newState.name()).execute(db).close();
return newState;
} catch (SQLException e) {
throw databaseException(FAILED_TO_CREATE_STATE).causedBy(e);