From 74fd96cf25fa0380b408b2d27a5248dfea384fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Fri, 9 Apr 2021 21:56:08 +0200 Subject: [PATCH] =?UTF-8?q?Ein=20Eintrag=20kann=20ver=C3=A4ndert=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/routes/WorkingHours.svelte | 40 +++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/ui/src/routes/WorkingHours.svelte b/ui/src/routes/WorkingHours.svelte index 441c32a..fae987b 100644 --- a/ui/src/routes/WorkingHours.svelte +++ b/ui/src/routes/WorkingHours.svelte @@ -22,6 +22,7 @@ return res.json(); }) .then(data => { + activeRecord = null; params.records = data; params.isLoading = false; }) @@ -41,6 +42,37 @@ }) .then(data => { activeRecord = data; + if (date === null) { + Records.browse(); + } + }) + .catch(err => { + console.log(err); + }); + }, + 'update': (date, record) => { + console.log(record); + // noinspection JSUnresolvedVariable + fetch(env.API_URL + '/working-hours/' + date, { + method: 'PUT', + 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(() => { + activeRecord = null; + Records.browse(); }) .catch(err => { console.log(err); @@ -103,8 +135,12 @@
- - + +