implemented updating of projects

This commit is contained in:
2025-07-20 01:30:56 +02:00
parent 20d527286b
commit 85ab2dd853
10 changed files with 183 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
<script>
import { activeField } from './field_sync.svelte.js';
import { t } from '../translations.svelte.js';
let { editable = false, value = $bindable(null), onSet = (newVal) => {return true;} } = $props();
let editing = $state(false);
@@ -47,5 +48,5 @@
{#if editable && editing}
<input bind:value={editValue} onkeyup={typed} autofocus />
{:else}
<div onclick={startEdit} class={{editable}}>{value}</div>
<div ondblclick={startEdit} class={{editable}} title={t('double_click_to_edit')} >{value}</div>
{/if}

View File

@@ -51,6 +51,6 @@
<span class="error">{error}</span>
{/if}
{#if children}
<TaskList tasks={children} bind:estimated_time={estimated_time} />
<TaskList tasks={children} {estimated_time} />
{/if}
</li>

View File

@@ -1,5 +1,6 @@
<script>
import { activeField } from './field_sync.svelte.js';
import { t } from '../translations.svelte.js';
let { editable = false, value = $bindable(null), onSet = (newVal) => {} } = $props();
let editing = $state(false);
@@ -65,4 +66,4 @@
{#if editing}
<textarea bind:value={editValue.source} onkeyup={typed} autofocus></textarea>
{/if}
<div onclick={startEdit} class={{editable}}>{@html editValue.rendered}</div>
<div ondblclick={startEdit} class={{editable}} title={t('double_click_to_edit')} >{@html editValue.rendered}</div>

View File

@@ -1,5 +1,6 @@
<script>
import { activeField } from './field_sync.svelte.js';
import { t } from '../translations.svelte.js';
let { editable = false, value = $bindable(null), onSet = (newVal) => {} } = $props();
let editing = $state(false);
@@ -28,6 +29,7 @@
if (ev.keyCode == 13 && ev.ctrlKey) applyEdit();
if (ev.keyCode == 27) resetEdit();
}
console.log(value);
activeField.subscribe((val) => resetEdit());
</script>
@@ -49,9 +51,11 @@
{#if editable && editing}
<textarea bind:value={editValue} onkeyup={typed} autofocus></textarea>
{:else}
<div onclick={startEdit} class={{editable}}>
{#each value.split("\n") as line}
{line}<br/>
{/each}
</div>
{#if value}
<div ondblclick={startEdit} class={{editable}} title={t('double_click_to_edit')} >
{#each value.split("\n") as line}
{line}<br/>
{/each}
</div>
{/if}
{/if}

View File

@@ -11,6 +11,6 @@
<ul>
{#each sortedTasks as task}
<ListTask {task} bind:estimated_time={estimated_time} />
<ListTask {task} {estimated_time} />
{/each}
</ul>

View File

@@ -2,6 +2,8 @@
import { t } from '../../translations.svelte.js';
import { onMount } from 'svelte';
import TaskList from '../../Components/TaskList.svelte';
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
import LineEditor from '../../Components/LineEditor.svelte';
let { id } = $props();
let project = $state(null);
@@ -36,6 +38,21 @@
}
}
async function update(data){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/project/${id}`;
const resp = await fetch(url,{
credentials:'include',
method:'PATCH',
body:JSON.stringify(data)
});
if (resp.ok){
error = null;
project = await resp.json();
} else {
error = await resp.text();
}
}
onMount(loadProject);
</script>
@@ -48,7 +65,9 @@
<tbody>
<tr>
<th>{t('project')}</th>
<td class="name">{project.name}</td>
<td class="name">
<LineEditor bind:value={project.name} editable={true} onSet={val => update({name:val})} />
</td>
</tr>
{#if project.company}
<tr>
@@ -66,7 +85,9 @@
</tr>
<tr>
<th>{t('description')}</th>
<td class="description">{@html project.description.rendered}</td>
<td class="description">
<MarkdownEditor bind:value={project.description} editable={true} onSet={val => update({description:val})} />
</td>
</tr>
{#if estimated_time.sum}
<tr>
@@ -78,7 +99,7 @@
<th>{t('tasks')}</th>
<td class="tasks">
{#if tasks}
<TaskList {tasks} bind:estimated_time={estimated_time} />
<TaskList {tasks} {estimated_time} />
{/if}
</td>
</tr>