implemented saving of task/project from tag input field

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2026-05-19 16:05:43 +02:00
parent 8b139b1bed
commit a1164e416a
2 changed files with 70 additions and 75 deletions
+68 -74
View File
@@ -1,7 +1,7 @@
<script> <script>
import { useTinyRouter } from 'svelte-tiny-router'; import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte.js'; import { api, post } from '../../urls.svelte.js';
import { error, yikes } from '../../warn.svelte'; import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte.js'; import { t } from '../../translations.svelte.js';
@@ -21,13 +21,9 @@
}); });
async function onsubmit(ev){ async function onsubmit(ev){
ev.preventDefault(); if (ev) ev.preventDefault();
const url = api('project'); const url = api('project');
var resp = await fetch(url,{ var resp = await post(url,project);
credentials : 'include',
method : 'POST',
body : JSON.stringify(project)
});
if (resp.ok){ if (resp.ok){
var newProject = await resp.json(); var newProject = await resp.json();
router.navigate(`/project/${newProject.id}/view`); router.navigate(`/project/${newProject.id}/view`);
@@ -50,72 +46,70 @@
label{ display: block } label{ display: block }
</style> </style>
<form {onsubmit}> <fieldset>
<legend>
{t('create_new_project')}
</legend>
<fieldset> <fieldset>
<legend> <legend>{t('basic_data')}</legend>
{t('create_new_project')} <table>
</legend> <tbody>
<fieldset> <tr>
<legend>{t('basic_data')}</legend> <th>
<table> {t('company_optional')}
<tbody> </th>
<tr> <td>
<th> <CompanySelector caption={t('no_company')} {onselect} />
{t('company_optional')} </td>
</th> </tr>
<td> <tr>
<CompanySelector caption={t('no_company')} {onselect} /> <th>
</td> {t('Name')}
</tr> </th>
<tr> <td>
<th> <input type="text" bind:value={project.name}/>
{t('Name')} </td>
</th> </tr>
<td> <tr>
<input type="text" bind:value={project.name}/> <th>
</td> {t('description')}
</tr> </th>
<tr> <td>
<th> <MarkdownEditor bind:value={project.description} simple={true} />
{t('description')} </td>
</th> </tr>
<td> {#if showSettings}
<MarkdownEditor bind:value={project.description} simple={true} /> <tr>
</td> <th>
</tr> {t('settings')}
{#if showSettings} </th>
<tr> <td>
<th> <label>
{t('settings')} <input type="checkbox" bind:checked={project.settings.show_closed} />
</th> {t('display_closed_tasks')}
<td> </label>
<label> </td>
<input type="checkbox" bind:checked={project.settings.show_closed} /> </tr>
{t('display_closed_tasks')} {:else}
</label> <tr>
</td> <th>
</tr> {t('settings')}
{:else} </th>
<tr> <td>
<th> <button onclick={toggleSettings} >{t('extended_settings')}</button>
{t('settings')} </td>
</th> </tr>
<td> {/if}
<button onclick={toggleSettings} >{t('extended_settings')}</button> <tr>
</td> <th>
</tr> {t('tags')}
{/if} </th>
<tr> <td>
<th> <Tags module={null} bind:tags={project.tags} onEmptyCommit={onsubmit} />
{t('tags')} </td>
</th> </tr>
<td> </tbody>
<Tags module="project" bind:tags={project.tags} /> </table>
</td>
</tr>
</tbody>
</table>
</fieldset>
<button type="submit" disabled={!ready}>{t('create')}</button>
</fieldset> </fieldset>
</form> <button onclick={onsubmit} disabled={!ready}>{t('create')}</button>
</fieldset>
+2 -1
View File
@@ -79,6 +79,7 @@
task.members[assignee] = project.members[assignee]; task.members[assignee] = project.members[assignee];
task.members[assignee].permission = { name : "ASSIGNEE", code : 3 } task.members[assignee].permission = { name : "ASSIGNEE", code : 3 }
} }
if (task.taks.length < 1) task.tags = project.tags;
yikes(); yikes();
} else { } else {
error(resp); error(resp);
@@ -154,7 +155,7 @@
</div> </div>
<div>{t('tags')}</div> <div>{t('tags')}</div>
<div> <div>
<Tags module="task" bind:tags={task.tags} /> <Tags module={null} bind:tags={task.tags} onEmptyCommit={saveTask} />
</div> </div>
{#if extendedSettings} {#if extendedSettings}