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