implemented removal of required task
This commit is contained in:
@@ -22,20 +22,14 @@
|
||||
error = null;
|
||||
let newTask = await resp.json();
|
||||
if (newTask.project_id != task.project_id){
|
||||
alert('prject mismatch!');
|
||||
alert('project mismatch!');
|
||||
return;
|
||||
}
|
||||
task.required_tasks_ids.push(new_task_id);
|
||||
requiredTasks[new_task_id] = newTask;
|
||||
url = api(`task/${task.id}`);
|
||||
resp = await fetch(url,{
|
||||
credentials : 'include',
|
||||
method : 'PATCH',
|
||||
body : JSON.stringify({required_tasks_ids:task.required_tasks_ids})
|
||||
});
|
||||
await patch();
|
||||
delete candidates[new_task_id];
|
||||
}
|
||||
if (!resp.ok) {
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
@@ -90,6 +84,24 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
async function patch(){
|
||||
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})
|
||||
});
|
||||
if (!resp.ok){
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
async function unlink(required_task){
|
||||
task.required_tasks_ids = task.required_tasks_ids.filter(item => item != required_task.id);
|
||||
patch();
|
||||
delete requiredTasks[required_task.id];
|
||||
}
|
||||
|
||||
onMount(loadTasks);
|
||||
</script>
|
||||
|
||||
@@ -97,7 +109,7 @@
|
||||
<ul class="required task list">
|
||||
{#each Object.values(requiredTasks) as task}
|
||||
<li class="task" >
|
||||
<a href="/task/{task.id}/view" onclick={openTask} >{task.name}</a>
|
||||
<a href="/task/{task.id}/view" onclick={openTask} >{task.name}</a> <button onclick={() => unlink(task)} class="symbol"></button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user