implemented function to return estimated times of company.

Therefore task and project module had to be created and partially implemented
This commit is contained in:
2025-07-13 23:45:18 +02:00
parent ea888c2be4
commit bac04ac047
39 changed files with 642 additions and 61 deletions

View File

@@ -0,0 +1,11 @@
<script>
import { t } from '../translations.svelte.js';
let { item, onclick } = $props();
</script>
<fieldset {onclick}>
<legend>{item.code} | {item.name}</legend>
<div>{@html item.description.rendered}</div>
<span>{item.unit_price/100} {item.currency} / {item.unit}</span>
</fieldset>

View File

@@ -1,7 +1,39 @@
<script>
import { t } from '../../translations.svelte.js';
import { onMount } from 'svelte';
import EstimatedTime from '../../Components/Item.svelte';
let { company_id, onSelect = (item) => {} } = $props();
let items = $state(null);
let error = $state(null);
async function loadItems(){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/task/estimated_times`;
let data = { company_id: company_id };
const resp = await fetch(url,{
credentials:'include',
method: 'POST',
body: JSON.stringify(data)
});
if (resp.ok){
items = await resp.json();
} else {
error = await resp.body();
}
}
onMount(loadItems);
</script>
<div>
<h1>Estimated Times</h1>
<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)} />
{/each}
{/if}
</div>

View File

@@ -1,12 +1,21 @@
<script>
import { t } from '../../translations.svelte.js';
import { onMount } from 'svelte';
import Item from '../../Components/Item.svelte';
let { company_id, onSelect = (item) => {} } = $props();
let items = $state(null);
let error = $state(null);
async function loadItems(){
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/items/list`;
const resp = await fetch(url,{credentials:'include'});
let data = { company_id: company_id };
const resp = await fetch(url,{
credentials:'include',
method: 'POST',
body: JSON.stringify(data)
});
if (resp.ok){
items = await resp.json();
} else {
@@ -19,8 +28,13 @@
</script>
<div>
<h1>Items</h1>
<h1>{t('items.items')}</h1>
{#if error}
<span class="error">{error}</span>
{/if}
{#if items}
{#each items as item,id}
<Item item={item} onclick={() => onSelect(item)} />
{/each}
{/if}
</div>

View File

@@ -4,20 +4,36 @@
import ItemList from './ItemList.svelte';
import TimeList from './TimeList.svelte';
let { close = () => {}, doc = $bindable({}) } = $props();
let { close = () => {}, doc = $bindable({}), onSelect = (item) => {} } = $props();
let select = $state(0);
function estimateSelected(estimate){
onSelect({estimate:estimate});
close();
}
function itemSelected(item){
onSelect({item:item});
close();
}
</script>
<style>
div{
position: fixed;
top: 0;
bottom: 0;
bottom: 20px;
left: 0;
right: 0;
background: rgba(0,0,0,0.8);
background: rgba(0,0,0,0.9);
padding: 10px;
overflow: auto;
}
span{
position: sticky;
top: 0;
}
</style>
@@ -29,9 +45,9 @@
<button onclick={close}>{t('document.abort')}</button>
</span>
{#if select == 0}
<ItemList />
<ItemList company_id={doc.company.id} onSelect={itemSelected} />
{:else if select == 1}
<EstimateList />
<EstimateList company_id={doc.company.id} onSelect={estimateSelected} />
{:else}
<TimeList />
{/if}

View File

@@ -63,6 +63,12 @@
}
}
function addPosition(selected){
let newPos = {};
if (selected.item) newPos['item']=selected.item.id;
console.log(JSON.stringify({newPos:newPos}));
}
onMount(loadDoc);
</script>
@@ -186,5 +192,5 @@
{/if}
{#if position_select}
<PositionSelector close={() => position_select=false} {doc} />
<PositionSelector close={() => position_select=false} {doc} onSelect={addPosition} />
{/if}