implemented selecting tasks by estimated time
This commit is contained in:
27
frontend/src/Components/EstimatedTask.svelte
Normal file
27
frontend/src/Components/EstimatedTask.svelte
Normal file
@@ -0,0 +1,27 @@
|
||||
<script>
|
||||
import {t} from '../translations.svelte.js';
|
||||
|
||||
let { task, onSelect = (task) => {} } = $props();
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<div title={'task_'+task.id}>
|
||||
{#if task.estimated_time}
|
||||
<span class="estimate" onclick={() => onSelect(task)}>
|
||||
{task.estimated_time} {t(task.estimated_time != 1 ? 'task.hours' : 'task.hour')}
|
||||
</span>
|
||||
{/if}
|
||||
{task.name}
|
||||
</div>
|
||||
<div>
|
||||
{@html task.description.rendered}
|
||||
</div>
|
||||
{#if task.children}
|
||||
<ul>
|
||||
{#each task.children as child,tid}
|
||||
<svelte:self task={child} />
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
@@ -1,10 +1,10 @@
|
||||
<script>
|
||||
import { t } from '../../translations.svelte.js';
|
||||
import { onMount } from 'svelte';
|
||||
import EstimatedTime from '../../Components/Item.svelte';
|
||||
let { company_id, onSelect = (item) => {} } = $props();
|
||||
import EstimatedTask from '../../Components/EstimatedTask.svelte';
|
||||
let { company_id, onSelect = (task) => {} } = $props();
|
||||
|
||||
let items = $state(null);
|
||||
let projects = $state(null);
|
||||
let error = $state(null);
|
||||
|
||||
async function loadItems(){
|
||||
@@ -16,7 +16,7 @@
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
if (resp.ok){
|
||||
items = await resp.json();
|
||||
projects = await resp.json();
|
||||
} else {
|
||||
error = await resp.body();
|
||||
}
|
||||
@@ -26,14 +26,31 @@
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
:global(.estimate){
|
||||
border: 1px solid;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div>
|
||||
<h1>{t('task.estimated_times')}</h1>
|
||||
{#if error}
|
||||
<span class="error">{error}</span>
|
||||
{/if}
|
||||
{#if items}
|
||||
{#each items as item,id}
|
||||
<EstimatedTime item={item} onclick={() => onSelect(item)} />
|
||||
{#if projects}
|
||||
{#each projects as project,pid}
|
||||
<fieldset>
|
||||
<legend>{project.name}</legend>
|
||||
{#each project.tasks as task,tid}
|
||||
<ul>
|
||||
<li>
|
||||
<EstimatedTask {task} {onSelect} />
|
||||
</li>
|
||||
</ul>
|
||||
{/each}
|
||||
</fieldset>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
@@ -9,7 +9,7 @@
|
||||
let select = $state(0);
|
||||
|
||||
function estimateSelected(estimate){
|
||||
onSelect({estimate:estimate});
|
||||
onSelect({task:estimate});
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
<div>
|
||||
<span class="tabs">
|
||||
<button onclick={() => select=0}>{t('document.items')}</button>
|
||||
<button onclick={() => select=1}>{t('document.timetrack')}</button>
|
||||
<button onclick={() => select=2}>{t('document.estimated_times')}</button>
|
||||
<button onclick={() => select=1}>{t('document.estimated_times')}</button>
|
||||
<button onclick={() => select=2}>{t('document.timetrack')}</button>
|
||||
<button onclick={close}>{t('document.abort')}</button>
|
||||
</span>
|
||||
{#if select == 0}
|
||||
|
||||
@@ -64,8 +64,10 @@
|
||||
}
|
||||
|
||||
function addPosition(selected){
|
||||
console.log(selected);
|
||||
let newPos = {};
|
||||
if (selected.item) newPos['item']=selected.item.id;
|
||||
if (selected.task) newPos['task']=selected.task.id;
|
||||
console.log(JSON.stringify({newPos:newPos}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user