9 changed files with 91 additions and 8 deletions
@ -0,0 +1,68 @@
@@ -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> |
||||
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
export function api(rel_path){ |
||||
return `${location.protocol}//${location.host.replace('5173','8080')}/api/${rel_path}`; |
||||
} |
||||
Loading…
Reference in new issue