wirking on global error display

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-09-26 14:45:19 +02:00
parent 9c4c71f7dd
commit 2a6392cd2b
14 changed files with 113 additions and 116 deletions

View File

@@ -4,6 +4,7 @@
import { dragged } from './dragndrop.svelte';
import { api } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
import { timetrack } from '../../user.svelte';
import { now } from '../../time.svelte';
@@ -20,7 +21,6 @@
} = $props();
let children = $state(null);
let deleted = $state(false);
let error = $state(null);
const router = useTinyRouter();
let start = 0;
@@ -39,7 +39,7 @@
const track = await resp.json();
timetrack.running = track;
} else {
error = await resp.text();
error(await resp.text());
}
}
@@ -53,7 +53,7 @@
if (resp.ok){
deleted = true;
} else {
error = await resp.text();
error(await resp.text())
}
}
}
@@ -78,7 +78,7 @@
children[dragged.element.id]=dragged.element;
if (dragged.siblings[dragged.element.id]) delete dragged.siblings[dragged.element.id];
} else {
error = await resp.text();
error(await resp.text());
}
return false;
}
@@ -97,9 +97,9 @@
});
if (resp.ok){
children = await resp.json();
error = null;
yikes();
} else {
error = await resp.text();
error(await resp.text());
}
}
@@ -121,7 +121,7 @@
task = await resp.json();
return true;
} else {
error = await resp.text();
error(await resp.text());
return false;
}
}
@@ -168,9 +168,6 @@
<button class="symbol" title={t('delete_object',{object:t('subtask')})} onclick={deleteTask} ></button>
<button class="symbol" title={t('add_object',{object:t('subtask')})} onclick={addSubtask}></button>
<button class="symbol" title={t('timetracking')} onclick={addTime}></button>
{#if error}
<span class="error">{error}</span>
{/if}
{#if children}
<TaskList {states} tasks={children} {estimated_time} {show_closed} />
{/if}

View File

@@ -3,12 +3,12 @@
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
let { task = null } = $props();
let candidates = $state({});
let error = $state(null);
let key = $state(null);
let requiredTasks = $state({});
let router = useTinyRouter();
@@ -19,7 +19,7 @@
let url = api(`task/${new_task_id}`);
let resp = await fetch(url,{ credentials : 'include' });
if (resp.ok){
error = null;
yikes();
let newTask = await resp.json();
if (newTask.project_id != task.project_id){
alert('project mismatch!');
@@ -30,7 +30,7 @@
await patch();
delete candidates[new_task_id];
} else {
error = await resp.text();
error(await resp.text());
}
}
@@ -47,12 +47,12 @@
body : JSON.stringify(data)
});
if (res.ok) {
error = null;
yikes();
candidates = await res.json();
for (var taskId of Object.keys(requiredTasks)) delete candidates[taskId];
delete candidates[task.id];
} else {
error = await res.text();
error(await res.text());
}
}
@@ -65,10 +65,10 @@
body : JSON.stringify({ids:task.required_tasks_ids})
});
if (res.ok){
error = null;
yikes();
requiredTasks = await res.json();
} else {
error = await res.text();
error(await res.text());
}
}
@@ -91,9 +91,7 @@
method : 'PATCH',
body : JSON.stringify({required_tasks_ids:task.required_tasks_ids})
});
if (!resp.ok){
error = await resp.text();
}
if (!resp.ok) error(await resp.text());
}
async function unlink(required_task){

View File

@@ -2,8 +2,9 @@
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js';
import { t } from '../../translations.svelte.js';
import { api } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
import { timetrack } from '../../user.svelte.js';
import { now } from '../../time.svelte';
@@ -19,7 +20,6 @@
let { id } = $props();
let children = $state(null);
let dummy = $derived(updateOn(id));
let error = $state(null);
let estimated_time = $state({sum:0});
let project = $state(null);
const router = useTinyRouter();
@@ -47,8 +47,9 @@
if (resp.ok) {
const track = await resp.json();
timetrack.running = track;
yikes();
} else {
error = await resp.text();
error(await resp.text());
}
}
@@ -87,9 +88,9 @@
});
if (resp.ok){
children = await resp.json();
error = null;
yikes();
} else {
error = await resp.text();
error(await resp.text());
}
}
@@ -99,7 +100,7 @@
if (resp.ok){
task.parent = await resp.json();
} else {
error = await resp.text();
error(await resp.text());
}
}
@@ -108,14 +109,14 @@
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
task = await resp.json();
error = null;
yikes();
project = null;
children = null;
loadChildren();
if (task.project_id) loadProject();
if (task.parent_task_id) loadParent();
} else {
error = await resp.text();
error(await resp.text());
}
}
@@ -124,9 +125,9 @@
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
project = await resp.json();
error = null;
yikes();
} else {
error = await resp.text();
error(await resp.text());
}
}
@@ -142,13 +143,13 @@
body : JSON.stringify(data)
});
if (resp.ok){
error = null;
yikes();
let old_task = task;
task = await resp.json();
if (task.parent_id == old_task.parent_id) task.parent = old_task.parent;
return true;
} else {
error = await resp.text();
error(await resp.text());
return false;
}
}
@@ -177,9 +178,6 @@
<title>Umbrella {t('task')}: {task?.name}</title>
</svelte:head>
{#if error}
<span class="error">{error}</span>
{/if}
{#if task}
<div class={`task grid2 prio_${task.total_prio} p${Math.floor(task.total_prio/10)*10} p${task.total_prio % 10}`} >
{#if project}