bugfix: moving of tasks in tree now works as intended
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user