From f3ff303b9362cdd12a127652dacbd29ee76d3a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Tue, 14 Dec 2021 12:28:58 +0100 Subject: [PATCH 01/19] refactor: REST-API-Abfrage ist in eigenes Modul ausgelagert worden --- ui/src/components/Repositories.svelte | 71 +++++++++++++++ ui/src/routes/WorkingHours.svelte | 119 ++++---------------------- 2 files changed, 90 insertions(+), 100 deletions(-) create mode 100644 ui/src/components/Repositories.svelte diff --git a/ui/src/components/Repositories.svelte b/ui/src/components/Repositories.svelte new file mode 100644 index 0000000..190dc03 --- /dev/null +++ b/ui/src/components/Repositories.svelte @@ -0,0 +1,71 @@ + \ No newline at end of file diff --git a/ui/src/routes/WorkingHours.svelte b/ui/src/routes/WorkingHours.svelte index 15b7682..1820117 100644 --- a/ui/src/routes/WorkingHours.svelte +++ b/ui/src/routes/WorkingHours.svelte @@ -7,122 +7,41 @@ 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: [], isLoading: true } - const Records = { - 'browse': () => { - // noinspection JSUnresolvedVariable - fetch(env.API_URL + '/working-hours') - .then(res => { - if (!res.ok) { - throw new Error('Fail!'); - } - return res.json(); - }) - .then(data => { - Controller.cancelActiveRecord(); - params.records = data; - params.isLoading = false; - }) - .catch(err => { - params.isLoading = false; - console.log(err); - }); - }, - 'read': date => { - // noinspection JSUnresolvedVariable - fetch(env.API_URL + '/working-hours/' + date) - .then(res => { - if (!res.ok) { - throw new Error('Fail!'); - } - return res.json(); - }) - .then(data => { - activeRecord = data; - if (date === null) { - Controller.listRecords(); - } - }) - .catch(err => { - console.log(err); - }); - }, - 'add': async record => { - console.log(record); - // noinspection JSUnresolvedVariable - await fetch(env.API_URL + '/working-hours', { - method: 'POST', - mode: 'cors', - cache: 'no-cache', - credentials: 'omit', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(record) - }) - .then(res => { - if (!res.ok) { - throw new Error('Fail!'); - } - }) - .then(() => { - Controller.listRecords(); - }) - .catch(err => { - console.log(err); - }); - }, - 'update': async (date, record) => { - console.log(record); - // noinspection JSUnresolvedVariable - await fetch(env.API_URL + '/working-hours/' + date, { - method: 'PUT', - mode: 'cors', - cache: 'no-cache', - credentials: 'omit', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify(record) - }) - .then(res => { - if (!res.ok) { - throw new Error('Fail!'); - } - }) - .then(() => { - Controller.listRecords(); - }) - .catch(err => { - console.log(err); - }); - } - }; const Controller = { 'listRecords': () => { - Controller.cancelActiveRecord(); - Records.browse(); + WorkingHoursRepository.browse().then(data => { + activeRecord = null; + params.records = data; + params.isLoading = false; + }) }, 'newRecord': () => { - activeRecord = {workingTime: '00:00:00'}; - newRecord = true; + activeRecord = {workingTime: '00:00:00', workingDay: null}; }, 'saveRecord': () => { - if (newRecord === true) { - Records.add(activeRecord); + if (activeRecord.workingDay === null) { + WorkingHoursRepository.add(activeRecord).then(() => { + Controller.listRecords() + }); } else { - Records.update(activeRecord.workingDay, activeRecord); + WorkingHoursRepository.update(activeRecord.workingDay, activeRecord).then(() => { + Controller.listRecords() + }) } }, - 'selectActiveRecord': record => Records.read(record.workingDay), + 'selectActiveRecord': record => WorkingHoursRepository.read(record.workingDay).then(data => { + activeRecord = data; + if (activeRecord === null) { + Controller.listRecords() + } + }), 'cancelActiveRecord': () => { activeRecord = null; - newRecord = false; } }; const initSite = () => { From fafc2a0ad5a799c7653771d1a78c92b766c1fdea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Tue, 14 Dec 2021 12:32:22 +0100 Subject: [PATCH 02/19] refactor: Eintrag-Feldset ist in eigenen Modul besser aufgehoben MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Eine Erweiterung auf weitere Möglichkeiten lassen sich so besser umsetzen. --- ui/src/routes/WorkingHours.svelte | 140 +++++++++----------- ui/src/routes/working-hours/NewByDay.svelte | 17 +++ 2 files changed, 80 insertions(+), 77 deletions(-) create mode 100644 ui/src/routes/working-hours/NewByDay.svelte diff --git a/ui/src/routes/WorkingHours.svelte b/ui/src/routes/WorkingHours.svelte index 1820117..27c8b97 100644 --- a/ui/src/routes/WorkingHours.svelte +++ b/ui/src/routes/WorkingHours.svelte @@ -1,11 +1,13 @@ - {title} + {TITLE} -{#if activeRecord === null} -
-
-

{title}

-
-
- {#if params.isLoading === true} -

Loading...

- {:else} - -
-
- -
-
- - - - - - - - - - - - - - - {#each params.records as record} - - - - - - {/each} - -
DatumArbeitsstundenAktionen
{record.workingDay}{record.workingTime} - -
- {/if} -
-
-{:else} -
-
-

{title}

-
-
+
+
+

{TITLE}

+
+ {#if activeRecord === null} +
+ {#if params.isLoading === true} +

Loading...

+ {:else} -
-
-
- - -
-
- - -
-
-
- -
-
-
-{/if} + + + + + + + + + + + + + + + {#each params.records as record} + + + + + + {/each} + +
DatumArbeitsstundenAktionen
{record.workingDay}{record.workingTime} + +
+ {/if} +
+ {:else} +
+ +
+ +
+ + +
+ +
+ {/if} +
diff --git a/ui/src/routes/working-hours/NewByDay.svelte b/ui/src/routes/working-hours/NewByDay.svelte new file mode 100644 index 0000000..79e721e --- /dev/null +++ b/ui/src/routes/working-hours/NewByDay.svelte @@ -0,0 +1,17 @@ + + + +
+
+ + +
+
+ + +
+
\ No newline at end of file From d13fce569b7c5fa869a904f02f0e3b4d8424d22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Tue, 14 Dec 2021 12:49:52 +0100 Subject: [PATCH 03/19] fix: Richtige Methode nutzen --- ui/src/components/Repositories.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/Repositories.svelte b/ui/src/components/Repositories.svelte index 190dc03..d898730 100644 --- a/ui/src/components/Repositories.svelte +++ b/ui/src/components/Repositories.svelte @@ -65,7 +65,7 @@ static async 'update'(date, record) { console.debug(record); - return MyFetch.post('/working-hours/' + date, JSON.stringify(record)) + return MyFetch.put('/working-hours/' + date, JSON.stringify(record)) } } \ No newline at end of file From b46f5634c82a0ea89c4a946b9cce883486202d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Wed, 12 Jan 2022 13:20:50 +0100 Subject: [PATCH 04/19] Bugfix: Warnung abschalten --- ui/src/routes/Home.svelte | 5 +++-- ui/src/routes/WorkingHours.svelte | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/src/routes/Home.svelte b/ui/src/routes/Home.svelte index 4a0fa9d..1d66b11 100644 --- a/ui/src/routes/Home.svelte +++ b/ui/src/routes/Home.svelte @@ -1,5 +1,6 @@ - + \ No newline at end of file diff --git a/ui/src/routes/WorkingHours.svelte b/ui/src/routes/WorkingHours.svelte index 16ef696..b4f7871 100644 --- a/ui/src/routes/WorkingHours.svelte +++ b/ui/src/routes/WorkingHours.svelte @@ -1,7 +1,7 @@ + +{#if activeRecordList.length < 1} +

Loading...

+{:else} +
+
+ + +
+
+ + +
+
+{/if} \ No newline at end of file diff --git a/ui/src/routes/WorkingHours/Formular/EditByWeek.svelte b/ui/src/routes/WorkingHours/Formular/EditByWeek.svelte new file mode 100644 index 0000000..3cd9e8b --- /dev/null +++ b/ui/src/routes/WorkingHours/Formular/EditByWeek.svelte @@ -0,0 +1,62 @@ + + + + + +{#if activeRecordList.length < 1} +

Loading...

+{:else} +
+
+ + +
+
+
+
+ + + {#each ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag'] as day, index} + + + + + {/each} + + + {#each ['Samstag', 'Sontag'] as day, index} + + + + + {/each} + +
+ {day} + + +
+ {day} + + +
+
+
+{/if} \ No newline at end of file diff --git a/ui/src/routes/working-hours/NewByDay.svelte b/ui/src/routes/working-hours/NewByDay.svelte deleted file mode 100644 index 79e721e..0000000 --- a/ui/src/routes/working-hours/NewByDay.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - - -
-
- - -
-
- - -
-
\ No newline at end of file From 18c5c45c26a516e9b180e78dd9ff7df37b2b4ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20L=C3=BCcke?= Date: Fri, 25 Feb 2022 10:59:12 +0100 Subject: [PATCH 18/19] =?UTF-8?q?Fix:=20=C3=84nderungen=20des=20Datums=20m?= =?UTF-8?q?=C3=BCssen=20verarbeitet=20werden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/routes/WorkingHours/Formular/EditByDay.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/src/routes/WorkingHours/Formular/EditByDay.svelte b/ui/src/routes/WorkingHours/Formular/EditByDay.svelte index c366758..3099bea 100644 --- a/ui/src/routes/WorkingHours/Formular/EditByDay.svelte +++ b/ui/src/routes/WorkingHours/Formular/EditByDay.svelte @@ -1,4 +1,5 @@
-
-
- - -
-
- - -
-
+ + {#if period_of_edit === DAILY_EDIT} + + {/if} + {#if period_of_edit === WEEKLY_EDIT} + + {/if}