Compare commits
5
Commits
6fb8f87c1c
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcce40113d | ||
|
|
0e1244c02f | ||
|
|
b4d30066b9 | ||
|
|
ab9bccf532 | ||
|
|
4acf1275a0 |
@@ -0,0 +1,72 @@
|
||||
<script lang="ts">
|
||||
let {promise_data, actual_records= $bindable(), page_count = 10} = $props();
|
||||
let records: Array<any[]> = $state([])
|
||||
let page_number = $state(0)
|
||||
let max_page_number = $state(0)
|
||||
const setPage = (new_page: number) => {
|
||||
page_number = new_page
|
||||
actual_records = records[page_number - 1]
|
||||
}
|
||||
const init = async () => {
|
||||
let page_records: any[] = []
|
||||
console.log(promise_data, actual_records)
|
||||
for (let index in promise_data) {
|
||||
page_records.push(promise_data[index])
|
||||
if (page_records.length >= page_count) {
|
||||
records.push(page_records.values().toArray())
|
||||
page_records = []
|
||||
}
|
||||
}
|
||||
if (page_records.length > 0) {
|
||||
records.push(page_records.values().toArray())
|
||||
}
|
||||
max_page_number = records.length
|
||||
setPage(1)
|
||||
}
|
||||
init()
|
||||
</script>
|
||||
<style>
|
||||
div.table-pagination {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
div.table-pagination > button {
|
||||
display: inline-block;
|
||||
width: 2rem;
|
||||
}
|
||||
|
||||
div.table-pagination > button[disabled] {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
div.table-pagination > span {
|
||||
display: inline-block;
|
||||
width: 5rem;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="table-pagination">
|
||||
<button
|
||||
type="button"
|
||||
disabled={page_number === 1}
|
||||
onclick={() => setPage(1)}>≪
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={page_number === 1}
|
||||
onclick={() => setPage(page_number - 1)}><
|
||||
</button>
|
||||
<span>{page_number} von {max_page_number}</span>
|
||||
<button
|
||||
type="button"
|
||||
disabled={page_number === max_page_number}
|
||||
onclick={() => setPage(page_number + 1)}>>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={page_number === max_page_number}
|
||||
onclick={() => setPage(max_page_number)}>≫
|
||||
</button>
|
||||
</div>
|
||||
+16
-9
@@ -1,16 +1,16 @@
|
||||
<script>
|
||||
import {PeriodRecord} from './Models.svelte.js'
|
||||
import TablePagination from "$lib/TablePagination.svelte";
|
||||
|
||||
/**
|
||||
* @type {{ promise: Promise<object>; title: string;}}
|
||||
*/
|
||||
let {params} = $props();
|
||||
let { promise, title } = $props();
|
||||
/** @type PeriodRecord[] **/
|
||||
let records = $state([])
|
||||
/** @type PeriodRecord[] **/
|
||||
let actual_records = $state([])
|
||||
let isLoading = $state(true)
|
||||
const init = async () => await params.promise.then(
|
||||
const init = async () => await promise.then(
|
||||
/**
|
||||
* @param {Array<object>} data
|
||||
* @param {Array<{ workingDays: Number; totalHours: any; overtime: string; period: string; homeOfficeDays: Number; }>} data
|
||||
*/
|
||||
data => {
|
||||
records = data.map(row => new PeriodRecord(row))
|
||||
@@ -21,12 +21,12 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{params.title}</title>
|
||||
<title>{title}</title>
|
||||
</svelte:head>
|
||||
|
||||
<section id="list-records">
|
||||
<header>
|
||||
<h1>{params.title}</h1>
|
||||
<h1>{title}</h1>
|
||||
</header>
|
||||
<article>
|
||||
{#if isLoading === true}
|
||||
@@ -49,7 +49,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each records as record}
|
||||
{#each actual_records as record}
|
||||
<tr>
|
||||
<td>{record.period}</td>
|
||||
<td>{record.workingDays}</td>
|
||||
@@ -59,6 +59,13 @@
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<TablePagination promise_data={records} bind:actual_records={actual_records}/>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
{/if}
|
||||
</article>
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Views params={data}/>
|
||||
<Views {...data}/>
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Views params={data}/>
|
||||
<Views {...data}/>
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Views params={data}/>
|
||||
<Views {...data}/>
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
import documentIcon from "@iconify-icons/oi/document.js";
|
||||
import wrenchIcon from "@iconify-icons/oi/wrench.js";
|
||||
import IconifyIcon from "@iconify/svelte";
|
||||
import TablePagination from "$lib/TablePagination.svelte";
|
||||
let { data } = $props();
|
||||
const TITLE = "Bearbeitung Einträge"
|
||||
/** @type {{workingDay: String, workingTime: String, isHomeOffice: Boolean, }[]|null} **/
|
||||
let records = $state([])
|
||||
let records = $state(null)
|
||||
/** @type {{workingDay: String, workingTime: String, isHomeOffice: Boolean, }[]} **/
|
||||
let actual_records = $state([])
|
||||
const init = async () => await data.promise.then(
|
||||
/**
|
||||
* @param {{workingDay: String, workingTime: String, isHomeOffice: Boolean, }[]} data
|
||||
@@ -58,7 +61,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each records as record}
|
||||
{#each actual_records as record}
|
||||
<tr style="{record.isHomeOffice ? 'background: aqua' : ''}">
|
||||
<td>{record.workingDay}</td>
|
||||
<td>{record.workingTime}</td>
|
||||
@@ -71,6 +74,13 @@
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<TablePagination promise_data={records} bind:actual_records={actual_records} page_count={15}/>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
{/if}
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user