From c711e0ae24a14456bf3f76a272a771cc9b4d4b13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Sat, 10 Apr 2021 11:26:34 +0200 Subject: [PATCH] =?UTF-8?q?Es=20ist=20m=C3=B6glich=20einen=20neuen=20Eintr?= =?UTF-8?q?ag=20zu=20generieren.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/routes/WorkingHours.svelte | 101 ++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 26 deletions(-) diff --git a/ui/src/routes/WorkingHours.svelte b/ui/src/routes/WorkingHours.svelte index fae987b..137cb2f 100644 --- a/ui/src/routes/WorkingHours.svelte +++ b/ui/src/routes/WorkingHours.svelte @@ -5,7 +5,9 @@ import wrenchIcon from '@iconify-icons/oi/wrench'; import checkIcon from '@iconify-icons/oi/check'; import xIcon from '@iconify-icons/oi/x'; + import documentIcon from '@iconify-icons/oi/document'; let activeRecord = null; + let newRecord = false; params = { title: 'Einträge', records: [], @@ -50,6 +52,34 @@ console.log(err); }); }, + 'add': record => { + console.log(record); + // noinspection JSUnresolvedVariable + fetch(env.API_URL + '/working-hours', { + method: 'POST', + mode: 'no-cors', + cache: 'no-cache', + credentials: 'same-origin', + headers: { + 'Content-Type': 'application/json' + }, + redirect: 'follow', + referrerPolicy: 'no-referrer', + body: JSON.stringify(record) + }) + .then(res => { + if (!res.ok) { + throw new Error('Fail!'); + } + }) + .then(() => { + newRecord = false; + Records.browse(); + }) + .catch(err => { + console.log(err); + }); + }, 'update': (date, record) => { console.log(record); // noinspection JSUnresolvedVariable @@ -71,7 +101,6 @@ } }) .then(() => { - activeRecord = null; Records.browse(); }) .catch(err => { @@ -92,28 +121,40 @@

{title}

- - - - - - - - - - {#each params.records as record} + {#if params.isLoading === true} +

Loading...

+ {:else} + + +
+ +
+ +
DatumArbeitsstundenAktionen
+ - - - + + + - {/each} - -
{record.workingDay}{record.workingTime} - - DatumArbeitsstundenAktionen
+ + + {#each params.records as record} + + {record.workingDay} + {record.workingTime} + + + + + {/each} + + + {/if}
{:else} @@ -127,17 +168,25 @@
- +
- +
- + {#if newRecord === true} + + {:else} + + {/if}