|
|
|
|
@ -1,7 +1,7 @@
@@ -1,7 +1,7 @@
|
|
|
|
|
<script> |
|
|
|
|
import { onMount } from 'svelte'; |
|
|
|
|
import { useTinyRouter } from 'svelte-tiny-router'; |
|
|
|
|
import { api } from '../../urls.svelte.js'; |
|
|
|
|
import { api, drop, patch, post } from '../../urls.svelte.js'; |
|
|
|
|
import { error, yikes } from '../../warn.svelte'; |
|
|
|
|
import { t } from '../../translations.svelte.js'; |
|
|
|
|
import { timetrack } from '../../user.svelte.js'; |
|
|
|
|
@ -33,11 +33,7 @@
@@ -33,11 +33,7 @@
|
|
|
|
|
|
|
|
|
|
async function addTime(task_id){ |
|
|
|
|
const url = api(`time/track_task/${task_id}`); |
|
|
|
|
const resp = await fetch(url,{ |
|
|
|
|
credentials : 'include', |
|
|
|
|
method : 'POST', |
|
|
|
|
body : now() |
|
|
|
|
}); // create new time or return time with assigned tasks |
|
|
|
|
const resp = await post(url,now()); // create new time or return time with assigned tasks |
|
|
|
|
if (resp.ok) { |
|
|
|
|
const track = await resp.json(); |
|
|
|
|
timetrack.running = track; |
|
|
|
|
@ -85,11 +81,7 @@
@@ -85,11 +81,7 @@
|
|
|
|
|
evt.preventDefault(); |
|
|
|
|
evt.stopPropagation(); |
|
|
|
|
const url = api('time/join'); |
|
|
|
|
const res = await fetch(url,{ |
|
|
|
|
credentials : 'include', |
|
|
|
|
method : 'POST', |
|
|
|
|
body : `${id1}+${id2}` |
|
|
|
|
}); |
|
|
|
|
const res = await post(url,`${id1}+${id2}`); |
|
|
|
|
if (res.ok){ |
|
|
|
|
yikes(); |
|
|
|
|
let json = await res.json(); |
|
|
|
|
@ -139,10 +131,7 @@
@@ -139,10 +131,7 @@
|
|
|
|
|
|
|
|
|
|
async function onDrop(time_id){ |
|
|
|
|
const url = api(`time/${time_id}`); |
|
|
|
|
const res = await fetch(url,{ |
|
|
|
|
credentials:'include', |
|
|
|
|
method:'DELETE' |
|
|
|
|
}); |
|
|
|
|
const res = await drop(url); |
|
|
|
|
if (res.ok){ |
|
|
|
|
delete times[time_id]; |
|
|
|
|
yikes(); |
|
|
|
|
@ -151,6 +140,16 @@
@@ -151,6 +140,16 @@
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function multi_update(changeSet){ |
|
|
|
|
console.log({ids:Object.keys(selected),patch:patch}); |
|
|
|
|
const url = api('time'); |
|
|
|
|
const res = await patch(url,changeSet); |
|
|
|
|
if (res.ok){ |
|
|
|
|
yikes(); |
|
|
|
|
alert('todo'); |
|
|
|
|
} else error(res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function openProject(pid){ |
|
|
|
|
router.navigate(`/project/${pid}/view`); |
|
|
|
|
} |
|
|
|
|
@ -211,6 +210,9 @@
@@ -211,6 +210,9 @@
|
|
|
|
|
{#if selectionSum} |
|
|
|
|
<div class="timetracks sum"> |
|
|
|
|
{t('sum_of_records')}: <span>{selectionSum.toFixed(3)} {t('hours')}</span> |
|
|
|
|
<button class="symbol" title={t('open')} onclick={e => multi_update({status:'open'})} ></button> |
|
|
|
|
<button class="symbol" title={t('waiting')} onclick={e => multi_update({status:'waiting'})} ></button> |
|
|
|
|
<button class="symbol" title={t('closed')} onclick={e => multi_update({status:'closed'})} ></button> |
|
|
|
|
</div> |
|
|
|
|
{/if} |
|
|
|
|
<table class="timetracks"> |
|
|
|
|
|