implemented deletion of tasks
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -94,7 +94,11 @@
|
||||
});
|
||||
if (resp.ok){
|
||||
delete tasks[task.assignee][task.status.code][task.id]
|
||||
if (!tasks[user]) tasks[user] = {}
|
||||
if (!tasks[user][state]) tasks[user][state] = {}
|
||||
tasks[user][state][task.id] = task;
|
||||
task.assignee = user;
|
||||
task.status = {code:state,name:states[state]};
|
||||
error = null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
|
||||
@@ -13,11 +13,27 @@
|
||||
let children = $state(null);
|
||||
let error = $state(null);
|
||||
let start = 0;
|
||||
let deleted = $state(false);
|
||||
|
||||
function addSubtask(){
|
||||
router.navigate(`/task/${task.id}/add_subtask`);
|
||||
}
|
||||
|
||||
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'
|
||||
});
|
||||
if (resp.ok){
|
||||
deleted = true;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function loadChildren(){
|
||||
const url = api('task/list');
|
||||
var data = {
|
||||
@@ -70,6 +86,7 @@
|
||||
onMount(loadChildren);
|
||||
</script>
|
||||
|
||||
{#if !deleted}
|
||||
<li class="task {task.status.name.toLowerCase()}">
|
||||
<LineEditor bind:value={task.name} onclick={openTask} editable={true} onSet={setName} type="span" />
|
||||
{#if task.estimated_time}
|
||||
@@ -90,7 +107,7 @@
|
||||
{#if task.status.name != 'CANCELLED'}
|
||||
<button class="symbol" title={t('abort')} onclick={() => patchTask({status:'CANCELLED'})} ></button>
|
||||
{/if}
|
||||
|
||||
<button class="symbol" title={t('delete_task')} onclick={deleteTask} ></button>
|
||||
<button class="symbol" title={t('add_subtask')} onclick={addSubtask}></button>
|
||||
{#if error}
|
||||
<span class="error">{error}</span>
|
||||
@@ -99,3 +116,4 @@
|
||||
<TaskList tasks={children} {estimated_time} {show_closed} />
|
||||
{/if}
|
||||
</li>
|
||||
{/if}
|
||||
@@ -7,7 +7,7 @@ export async function loadTranslation(lang){
|
||||
translations.values = await fetch(url).then(resp => resp.json());
|
||||
}
|
||||
|
||||
export function t(key,...args){
|
||||
export function t(key,args = {}){
|
||||
if (key === undefined) return "";
|
||||
if (key instanceof Response) key = 'status.'+key.status;
|
||||
let set = translations.values;
|
||||
@@ -19,6 +19,6 @@ export function t(key,...args){
|
||||
}
|
||||
set = set[token];
|
||||
}
|
||||
for (var i in args) set = set.replace(`{${i}}`,args[i]);
|
||||
for (var key of Object.keys(args)) set = set.replace(`{${key}}`,args[key]);
|
||||
return set;
|
||||
}
|
||||
Reference in New Issue
Block a user