improved handling of null values when mapping entities to json
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { t } from '../../translations.svelte.js';
|
||||
|
||||
import CompanySelector from '../../Components/CompanySelector.svelte';
|
||||
import MarkdownEditor from '../../Components/MarkdownEditor.svelte';
|
||||
import Settings from './Settings.svelte';
|
||||
let showSettings = $state(false);
|
||||
let ready = $derived(!!project.name.trim())
|
||||
@@ -11,7 +12,7 @@
|
||||
|
||||
let project = $state({
|
||||
name:'',
|
||||
description:'',
|
||||
description : { source : '', rendered : '' },
|
||||
settings:{
|
||||
show_closed:false
|
||||
}
|
||||
@@ -53,21 +54,44 @@
|
||||
</legend>
|
||||
<fieldset>
|
||||
<legend>{t('basic_data')}</legend>
|
||||
<label>
|
||||
<CompanySelector caption={t('no_company')} {onselect} />
|
||||
{t('company_optional')}
|
||||
</label>
|
||||
<label>
|
||||
<input type="text" bind:value={project.name}/>
|
||||
{t('Name')}
|
||||
</label>
|
||||
<label>
|
||||
<textarea bind:value={project.description}></textarea>
|
||||
{t('description')}
|
||||
</label>
|
||||
{#if !showSettings}
|
||||
<button onclick={() => showSettings = true}>{t('extended_settings')}</button>
|
||||
{/if}
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
{t('company_optional')}
|
||||
</th>
|
||||
<td>
|
||||
<CompanySelector caption={t('no_company')} {onselect} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
{t('Name')}
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" bind:value={project.name}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
{t('description')}
|
||||
</th>
|
||||
<td>
|
||||
<MarkdownEditor bind:value={project.description} simple={true} />
|
||||
</td>
|
||||
</tr>
|
||||
{#if !showSettings}
|
||||
<tr>
|
||||
<th>
|
||||
{t('settings')}
|
||||
</th>
|
||||
<td>
|
||||
<button onclick={() => showSettings = true}>{t('extended_settings')}</button>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</fieldset>
|
||||
{#if showSettings}
|
||||
<Settings bind:settings={project.settings}/>
|
||||
|
||||
@@ -84,7 +84,9 @@
|
||||
});
|
||||
if (resp.ok) {
|
||||
task = await resp.json();
|
||||
router.navigate(`/task/${task.id}/view`);
|
||||
if (task.parent_task_id){
|
||||
router.navigate(`/task/${task.parent_task_id}/view`);
|
||||
} else router.navigate(`/task/${task.id}/view`);
|
||||
error = null;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
|
||||
@@ -175,9 +175,11 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{t('subtasks')}</th>
|
||||
<td class="children">
|
||||
<th>
|
||||
{t('subtasks')}
|
||||
<button onclick={addChild} >{t('add_subtask')}</button>
|
||||
</th>
|
||||
<td class="children">
|
||||
{#if children}
|
||||
<TaskList tasks={children} {estimated_time} />
|
||||
{/if}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
<script>
|
||||
import { t } from '../translations.svelte.js';
|
||||
import { checkUser } from '../user.svelte.js';
|
||||
|
||||
let { key, onUpdate, value } = $props();
|
||||
|
||||
let input = $state(false);
|
||||
|
||||
function edit(){
|
||||
input = true;
|
||||
}
|
||||
|
||||
function check_key(evt){
|
||||
if (evt.key === 'Enter'){
|
||||
input = false;
|
||||
let obj = {};
|
||||
obj[key] = value;
|
||||
onUpdate(obj);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if input}
|
||||
<input type="text" bind:value onkeyup={check_key} />
|
||||
{:else}
|
||||
<span onclick={edit}>{value}</span>
|
||||
{/if}
|
||||
@@ -1,34 +0,0 @@
|
||||
<script>
|
||||
import { t } from '../translations.svelte.js';
|
||||
import { checkUser } from '../user.svelte.js';
|
||||
|
||||
let { fetchOptions, key, value, onUpdate } = $props();
|
||||
|
||||
let options = $state([]);
|
||||
|
||||
async function loadOptions(){
|
||||
const resp = await fetchOptions();
|
||||
const arr = await resp.json();
|
||||
for (let entry of arr){
|
||||
const value = entry.value;
|
||||
const caption = entry.caption ? entry.caption : value;
|
||||
options.push({caption:caption,value:value})
|
||||
}
|
||||
}
|
||||
|
||||
function propagate(){
|
||||
let changeset = {}
|
||||
changeset[key] = value;
|
||||
onUpdate(changeset);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if options.length > 0}
|
||||
<select bind:value onchange={propagate} >
|
||||
{#each options as entry,i}
|
||||
<option value={entry.value}>{entry.caption}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else}
|
||||
<span onclick={loadOptions}>{value}</span>
|
||||
{/if}
|
||||
@@ -1,31 +0,0 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { checkUser } from '../../user.svelte.js';
|
||||
|
||||
let { key, onUpdate, value } = $props();
|
||||
|
||||
let input = $state(false);
|
||||
|
||||
function edit(){
|
||||
input = true;
|
||||
}
|
||||
|
||||
function check_key(evt){
|
||||
if (evt.key === 'Enter'){
|
||||
input = false;
|
||||
let obj = {};
|
||||
obj[key] = value;
|
||||
onUpdate(obj);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<tr>
|
||||
<th>{t(key)}</th>
|
||||
{#if input}
|
||||
<td >
|
||||
<input type="text" bind:value onkeyup={check_key} />
|
||||
</td>
|
||||
{:else}
|
||||
<td onclick={edit}>{value}</td>
|
||||
{/if}
|
||||
</tr>
|
||||
Reference in New Issue
Block a user