preparing addition of tasks
This commit is contained in:
68
frontend/src/routes/task/Add.svelte
Normal file
68
frontend/src/routes/task/Add.svelte
Normal file
@@ -0,0 +1,68 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { api } from '../../urls.svelte.js';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||
|
||||
let { project_id = null } = $props();
|
||||
let error = $state(null);
|
||||
let project = $state(null)
|
||||
let task = $state({
|
||||
name : '',
|
||||
description : { source : 'new_task', rendered : '' }
|
||||
});
|
||||
|
||||
function load(){
|
||||
if (project_id) loadProject();
|
||||
}
|
||||
|
||||
async function loadProject(){
|
||||
var url = api(`project/${project_id}`);
|
||||
const resp = await fetch(url,{credentials:'include'});
|
||||
if (resp.ok){
|
||||
project = await resp.json();
|
||||
task.project_id = project_id;
|
||||
error = null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
}
|
||||
|
||||
onMount(load);
|
||||
</script>
|
||||
|
||||
|
||||
<fieldset>
|
||||
<legend>Add Task</legend>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
{t('name')}
|
||||
</th>
|
||||
<td>
|
||||
<input bind:value={task.name}>
|
||||
</td>
|
||||
</tr>
|
||||
{#if project}
|
||||
<tr>
|
||||
<th>
|
||||
{t('project')}
|
||||
</th>
|
||||
<td>
|
||||
{project.name}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<th>
|
||||
{t('description')}
|
||||
</th>
|
||||
<td>
|
||||
<MarkdownEditor bind:value={task.description} editing={true}/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user