implemented joining of times

This commit is contained in:
2025-09-01 23:31:46 +02:00
parent 50dbe9a4e5
commit 45c2f3978f
6 changed files with 111 additions and 15 deletions

View File

@@ -59,6 +59,26 @@
return result;
}
async function joinTimes(evt, id1, id2){
evt.preventDefault();
evt.stopPropagation();
const url = api('time/join');
const res = await fetch(url,{
credentials : 'include',
method : 'POST',
body : `${id1}+${id2}`
});
if (res.ok){
error = null;
let json = await res.json();
delete times[id1];
delete times[id2];
times[json.id] = json;
} else {
error = await res.text();
}
return false;
}
async function loadTimes(){
const url = api('time');
@@ -189,6 +209,9 @@
{:else}
<td class="start_end" onclick={e => toggleSelect(time.id)}>
{time.start}{#if time.end_time}<wbr><wbr>{time.start.startsWith(time.end_date)?time.end.substring(11):time.end}{/if}
{#if line>0 && Math.abs(sortedTimes[line-1].start_time - time.end_time)<100}
<button class="symbol join" title={t('join_objects',{objects:t('times')})} onclick={e => joinTimes(e, time.id, sortedTimes[line-1].id)} ></button>
{/if}
</td>
<td class="duration" onclick={e => {detail = time.id}}>
{#if time.duration}