Nutze neueste Version für Svelte5
Ignoriere die Pagination der Tabellen und das Bearbeiten der Einträge.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<script>
|
||||
let { children } = $props();
|
||||
</script>
|
||||
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="/">Home</a></li>
|
||||
<li><a href="/views/weekly">Wochenansicht</a></li>
|
||||
<li><a href="/views/monthly">Monatsansicht</a></li>
|
||||
<li><a href="/views/yearly">Jahresansicht</a></li>
|
||||
<!-- <li><a href="/working-hours">Einträge</a></li>-->
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
{@render children()}
|
||||
</main>
|
||||
|
||||
<footer><p>© Torsten Lücke 2021</p></footer>
|
||||
@@ -0,0 +1,9 @@
|
||||
import {env} from '$env/dynamic/private';
|
||||
import {WorkingHoursViewsRepository} from "../lib/Repositories.svelte";
|
||||
|
||||
export function load() {
|
||||
return {
|
||||
title: 'Wochenansicht',
|
||||
promise: WorkingHoursViewsRepository.weekly(env.API_URL)
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import Views from "$lib/Views.svelte";
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Views params={data}/>
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
<WeeklyViews />
|
||||
|
||||
<script>
|
||||
import WeeklyViews from "./WeeklyViews.svelte";
|
||||
export const params = {};
|
||||
</script>
|
||||
@@ -1,11 +0,0 @@
|
||||
<script>
|
||||
import Views from "./Views.svelte";
|
||||
import {WorkingHoursViewsRepository} from "../components/Repositories.svelte";
|
||||
export let params
|
||||
params = {
|
||||
title: 'Monatsansicht',
|
||||
promise: WorkingHoursViewsRepository.monthly()
|
||||
}
|
||||
</script>
|
||||
|
||||
<Views {params} />
|
||||
@@ -1,81 +0,0 @@
|
||||
<script>
|
||||
import { paginate, PaginationNav } from 'svelte-paginate'
|
||||
|
||||
export let params = {}
|
||||
let records = []
|
||||
let isLoading = true
|
||||
console.log(params)
|
||||
let currentPage = 1
|
||||
let pageSize = 15
|
||||
$: paginatedItems = paginate({ items: records, pageSize, currentPage })
|
||||
if (!String.prototype.startsWith) {
|
||||
String.prototype.startsWith = function (searchString, position) {
|
||||
position = position || 0
|
||||
return this.indexOf(searchString, position) === position
|
||||
}
|
||||
}
|
||||
$: isNegative = time => time.startsWith('-') ? 'absence-time' : ''
|
||||
$: cutMinusChar = time => time.startsWith('-') ? time.substr(1) : time
|
||||
|
||||
const init = async () => await params.promise.then(data => {
|
||||
records = data
|
||||
isLoading = false
|
||||
})
|
||||
init()
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{params.title}</title>
|
||||
</svelte:head>
|
||||
|
||||
<section id="list-records">
|
||||
<header>
|
||||
<h1>{params.title}</h1>
|
||||
</header>
|
||||
<article>
|
||||
{#if isLoading === true}
|
||||
<p>Loading...</p>
|
||||
{:else}
|
||||
<table>
|
||||
<colgroup>
|
||||
<col/>
|
||||
<col/>
|
||||
<col/>
|
||||
<col/>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zeitraum</th>
|
||||
<th>Arbeitstage</th>
|
||||
<th>Arbeitsstunden</th>
|
||||
<th>Über- / Unterstunden</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each paginatedItems as record}
|
||||
<tr>
|
||||
<td>{record.period}</td>
|
||||
<td>{record.workingDays}</td>
|
||||
<td>{record.totalHours}</td>
|
||||
<td class="{ isNegative(record.overtime) }">{cutMinusChar(record.overtime)}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<PaginationNav
|
||||
totalItems="{records.length}"
|
||||
pageSize="{pageSize}"
|
||||
currentPage="{currentPage}"
|
||||
limit="{1}"
|
||||
showStepOptions="{true}"
|
||||
on:setPage="{(e) => currentPage = e.detail.page}"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
{/if}
|
||||
</article>
|
||||
</section>
|
||||
@@ -1,11 +0,0 @@
|
||||
<script>
|
||||
import Views from "./Views.svelte";
|
||||
import {WorkingHoursViewsRepository} from "../components/Repositories.svelte";
|
||||
export let params
|
||||
params = {
|
||||
title: 'Wochenansicht',
|
||||
promise: WorkingHoursViewsRepository.weekly()
|
||||
}
|
||||
</script>
|
||||
|
||||
<Views {params} />
|
||||
@@ -1,33 +0,0 @@
|
||||
<script>
|
||||
import List from "./WorkingHours/List.svelte";
|
||||
import Formular from "./WorkingHours/Formular.svelte";
|
||||
export const params = {};
|
||||
|
||||
let TITLE = "Bearbeitung Einträge"
|
||||
let activeRecord = null;
|
||||
let currentPage = 1
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{TITLE}</title>
|
||||
</svelte:head>
|
||||
|
||||
{#if activeRecord === null}
|
||||
<section id="list-records">
|
||||
<header>
|
||||
<h1>{TITLE}</h1>
|
||||
</header>
|
||||
<article>
|
||||
<List bind:activeRecord={activeRecord} bind:currentPage/>
|
||||
</article>
|
||||
</section>
|
||||
{:else}
|
||||
<section id="edit-record">
|
||||
<header>
|
||||
<h1>{TITLE}</h1>
|
||||
</header>
|
||||
<article>
|
||||
<Formular bind:activeRecord={activeRecord}/>
|
||||
</article>
|
||||
</section>
|
||||
{/if}
|
||||
@@ -1,11 +0,0 @@
|
||||
<script>
|
||||
import Views from "./Views.svelte";
|
||||
import {WorkingHoursViewsRepository} from "../components/Repositories.svelte";
|
||||
export let params
|
||||
params = {
|
||||
title: 'Jahresansicht',
|
||||
promise: WorkingHoursViewsRepository.yearly()
|
||||
}
|
||||
</script>
|
||||
|
||||
<Views {params} />
|
||||
@@ -0,0 +1,9 @@
|
||||
import {env} from '$env/dynamic/private';
|
||||
import {WorkingHoursViewsRepository} from "$lib/Repositories.svelte";
|
||||
|
||||
export function load() {
|
||||
return {
|
||||
title: 'Monatsansicht',
|
||||
promise: WorkingHoursViewsRepository.monthly(env.API_URL)
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import Views from "$lib/Views.svelte";
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Views params={data}/>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import {env} from '$env/dynamic/private';
|
||||
import {WorkingHoursViewsRepository} from "$lib/Repositories.svelte";
|
||||
|
||||
export function load() {
|
||||
return {
|
||||
title: 'Wochenansicht',
|
||||
promise: WorkingHoursViewsRepository.weekly(env.API_URL)
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import Views from "$lib/Views.svelte";
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Views params={data}/>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import {env} from '$env/dynamic/private';
|
||||
import {WorkingHoursViewsRepository} from "$lib/Repositories.svelte";
|
||||
|
||||
export function load() {
|
||||
return {
|
||||
title: 'Jahresansicht',
|
||||
promise: WorkingHoursViewsRepository.yearly(env.API_URL)
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import Views from "$lib/Views.svelte";
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Views params={data}/>
|
||||
|
||||
Reference in New Issue
Block a user