diff --git a/ui/src/components/TimekeepingDate.svelte b/ui/src/components/TimekeepingDate.svelte deleted file mode 100644 index 3d23739..0000000 --- a/ui/src/components/TimekeepingDate.svelte +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/ui/src/lib/Repositories.svelte b/ui/src/lib/Repositories.svelte index f60d4e7..24ff9a0 100644 --- a/ui/src/lib/Repositories.svelte +++ b/ui/src/lib/Repositories.svelte @@ -121,7 +121,6 @@ * @param {Object} record */ 'update': async (api_url, date, record) => { - console.debug(record); return MyFetch.put(api_url + '/working-hours/' + date, JSON.stringify(record)) }, /** @@ -130,7 +129,6 @@ * @param {Object} record */ 'addOrUpdate': async (api_url, date, record) => { - console.debug(record); let request_options = MyFetch._buildRequestOptions(JSON.stringify(record), false) let response = await MyFetch._pureFetch(api_url + '/working-hours', request_options) if (response.status === 409) { diff --git a/ui/src/routes/+layout.svelte b/ui/src/routes/+layout.svelte index 8e70e58..ee2e041 100644 --- a/ui/src/routes/+layout.svelte +++ b/ui/src/routes/+layout.svelte @@ -1,14 +1,19 @@ diff --git a/ui/src/routes/WorkingHours/Formular.svelte b/ui/src/routes/WorkingHours/Formular.svelte deleted file mode 100644 index 4403b29..0000000 --- a/ui/src/routes/WorkingHours/Formular.svelte +++ /dev/null @@ -1,126 +0,0 @@ - - -
- - {#if period_of_edit === DAILY_EDIT} - - {/if} - {#if period_of_edit === WEEKLY_EDIT} - - {/if} - {#if period_of_edit === CSV_IMPORT} - - {/if} -
- - -
- \ No newline at end of file diff --git a/ui/src/routes/WorkingHours/Formular/EditByDay.svelte b/ui/src/routes/WorkingHours/Formular/EditByDay.svelte deleted file mode 100644 index 3099bea..0000000 --- a/ui/src/routes/WorkingHours/Formular/EditByDay.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - -{#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 deleted file mode 100644 index 3cd9e8b..0000000 --- a/ui/src/routes/WorkingHours/Formular/EditByWeek.svelte +++ /dev/null @@ -1,62 +0,0 @@ - - - - - -{#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/WorkingHours/List.svelte b/ui/src/routes/WorkingHours/List.svelte deleted file mode 100644 index e0a0761..0000000 --- a/ui/src/routes/WorkingHours/List.svelte +++ /dev/null @@ -1,95 +0,0 @@ - - - -
-
- -
-
-{#if isLoading === true} -

Loading...

-{:else} - - - - - - - - - - - - - - - {#each paginatedItems as record} - - - - - - {/each} - - - - - - -
DatumArbeitsstundenAktionen
{record.workingDay}{record.workingTime} - -
- -
-{/if} \ No newline at end of file diff --git a/ui/src/routes/working-hours/+page.server.js b/ui/src/routes/working-hours/+page.server.js new file mode 100644 index 0000000..c452440 --- /dev/null +++ b/ui/src/routes/working-hours/+page.server.js @@ -0,0 +1,64 @@ +import {env} from '$env/dynamic/private'; +import {WorkingHoursRepository} from "$lib/Repositories.svelte"; + +export function load() { + return { + promise: WorkingHoursRepository.browse(env.API_URL) + }; +} + +/** @param {Date} actualDayObject **/ +const getMonday = actualDayObject => { + if (actualDayObject.getDate() === 0) { + actualDayObject.setDate(actualDayObject.getDate() - 7) + } + if (actualDayObject.getDate() !== 1) { + actualDayObject.setDate(actualDayObject.getDate() - (actualDayObject.getDay() - 1)) + } + return actualDayObject +} + +/** @type {String[]} **/ +const day_list = ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sontag'] + +/** @param {Date} actualDayObject **/ +const getDateString = actualDayObject => { + return actualDayObject.getFullYear() + "-" + + (actualDayObject.getMonth() + 1).toString().padStart(2, '0') + "-" + + actualDayObject.getDate().toString().padStart(2, '0') +} + +export const actions = { + update: async ({ request }) => { + const data = await request.formData(); + const body_data = { + workingDay: data.get('workingDay'), + workingTime: data.get('workingTime'), + } + await WorkingHoursRepository.update(env.API_URL, data.get('workingDay'), body_data); + }, + create: async ({ request }) => { + const form_data = await request.formData(); + const body_data = { + workingDay: form_data.get('workingDay'), + workingTime: form_data.get('workingTime'), + } + await WorkingHoursRepository.add(env.API_URL, body_data); + }, + "create-by-week": async ({ request }) => { + const form_data = await request.formData(); + // @ts-ignore + let actualDayObject = getMonday(new Date(form_data.get('week'))) + day_list.forEach(day => { + if (form_data.get(day) !== '00:00:00' && form_data.get(day) !== '00:00') { + const working_day = getDateString(actualDayObject) + const body_data = { + workingDay: working_day, + workingTime: form_data.get(day), + } + WorkingHoursRepository.addOrUpdate(env.API_URL, working_day, body_data); + } + actualDayObject.setDate(actualDayObject.getDate() + 1) + }) + } +}; \ No newline at end of file diff --git a/ui/src/routes/working-hours/+page.svelte b/ui/src/routes/working-hours/+page.svelte new file mode 100644 index 0000000..8a36f4e --- /dev/null +++ b/ui/src/routes/working-hours/+page.svelte @@ -0,0 +1,73 @@ + + + + {TITLE} + + +
+
+

{TITLE}

+
+
+ +
+
+ Neuer Eintrag + + +
+ {#if records === null} +

Loading...

+ {:else} + + + + + + + + + + + + + + + {#each records as record} + + + + + + {/each} + +
DatumArbeitsstundenAktionen
{record.workingDay}{record.workingTime} + +
+ {/if} +
+
+
\ No newline at end of file diff --git a/ui/src/routes/working-hours/[working_day]/+page.server.js b/ui/src/routes/working-hours/[working_day]/+page.server.js new file mode 100644 index 0000000..a633bc5 --- /dev/null +++ b/ui/src/routes/working-hours/[working_day]/+page.server.js @@ -0,0 +1,9 @@ +import {env} from '$env/dynamic/private'; +import {WorkingHoursRepository} from "$lib/Repositories.svelte"; + +export function load({ params }) { + return { + working_day: params.working_day, + promise: WorkingHoursRepository.read(env.API_URL, params.working_day) + }; +} \ No newline at end of file diff --git a/ui/src/routes/working-hours/[working_day]/+page.svelte b/ui/src/routes/working-hours/[working_day]/+page.svelte new file mode 100644 index 0000000..d1e2dc1 --- /dev/null +++ b/ui/src/routes/working-hours/[working_day]/+page.svelte @@ -0,0 +1,57 @@ + + + + {TITLE} + + + +
+
+

{TITLE}

+
+
+
+ {#if activeDate === null} +

Loading...

+ {:else} +
+
+ + +
+
+ + +
+
+ {/if} +
+ + +
+
+
+
\ No newline at end of file diff --git a/ui/src/routes/working-hours/create-by-day/+page.svelte b/ui/src/routes/working-hours/create-by-day/+page.svelte new file mode 100644 index 0000000..80d1fd0 --- /dev/null +++ b/ui/src/routes/working-hours/create-by-day/+page.svelte @@ -0,0 +1,43 @@ + + + + {TITLE} + + + +
+
+

{TITLE}

+
+
+
+
+
+ + +
+
+ + +
+
+
+ + +
+
+
+
\ No newline at end of file diff --git a/ui/src/routes/working-hours/create-by-week/+page.svelte b/ui/src/routes/working-hours/create-by-week/+page.svelte new file mode 100644 index 0000000..0a0d9a3 --- /dev/null +++ b/ui/src/routes/working-hours/create-by-week/+page.svelte @@ -0,0 +1,74 @@ + + + + {TITLE} + + + + + +
+
+

{TITLE}

+
+
+
+
+
+ + +
+
+
+
+ + + {#each ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag'] as day} + + + + + {/each} + + + {#each ['Samstag', 'Sontag'] as day} + + + + + {/each} + +
+ {day} + + +
+ {day} + + +
+
+
+
+ + +
+
+
+
\ No newline at end of file