Feature: nutze für Tabellen eine Pagination
This commit is contained in:
+2
-1
@@ -25,6 +25,7 @@
|
|||||||
"rollup-plugin-svelte": "^6.0.0",
|
"rollup-plugin-svelte": "^6.0.0",
|
||||||
"rollup-plugin-terser": "^7.0.0",
|
"rollup-plugin-terser": "^7.0.0",
|
||||||
"sirv-cli": "^1.0.8",
|
"sirv-cli": "^1.0.8",
|
||||||
"svelte": "^3.4.4"
|
"svelte": "^3.4.4",
|
||||||
|
"svelte-paginate": "^0.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-12
@@ -1,16 +1,21 @@
|
|||||||
<script>
|
<script>
|
||||||
export let params = {};
|
import { paginate, PaginationNav } from 'svelte-paginate'
|
||||||
|
|
||||||
|
export let params = {}
|
||||||
let records = []
|
let records = []
|
||||||
let isLoading = true
|
let isLoading = true
|
||||||
console.log(params)
|
console.log(params)
|
||||||
|
let currentPage = 1
|
||||||
|
let pageSize = 15
|
||||||
|
$: paginatedItems = paginate({ items: records, pageSize, currentPage })
|
||||||
if (!String.prototype.startsWith) {
|
if (!String.prototype.startsWith) {
|
||||||
String.prototype.startsWith = function(searchString, position) {
|
String.prototype.startsWith = function (searchString, position) {
|
||||||
position = position || 0;
|
position = position || 0
|
||||||
return this.indexOf(searchString, position) === position;
|
return this.indexOf(searchString, position) === position
|
||||||
};
|
|
||||||
}
|
}
|
||||||
$: isNegative = time => time.startsWith('-') ? 'absence-time' : '';
|
}
|
||||||
$: cutMinusChar = time => time.startsWith('-') ? time.substr(1) : time;
|
$: isNegative = time => time.startsWith('-') ? 'absence-time' : ''
|
||||||
|
$: cutMinusChar = time => time.startsWith('-') ? time.substr(1) : time
|
||||||
|
|
||||||
const init = async () => await params.promise.then(data => {
|
const init = async () => await params.promise.then(data => {
|
||||||
records = data
|
records = data
|
||||||
@@ -33,10 +38,10 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<table>
|
<table>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col />
|
<col/>
|
||||||
<col />
|
<col/>
|
||||||
<col />
|
<col/>
|
||||||
<col />
|
<col/>
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -47,7 +52,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each records as record}
|
{#each paginatedItems as record}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{record.period}</td>
|
<td>{record.period}</td>
|
||||||
<td>{record.workingDays}</td>
|
<td>{record.workingDays}</td>
|
||||||
@@ -56,6 +61,20 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</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>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
let TITLE = "Bearbeitung Einträge"
|
let TITLE = "Bearbeitung Einträge"
|
||||||
let activeRecord = null;
|
let activeRecord = null;
|
||||||
|
let currentPage = 1
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
<h1>{TITLE}</h1>
|
<h1>{TITLE}</h1>
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
<List bind:activeRecord={activeRecord}/>
|
<List bind:activeRecord={activeRecord} bind:currentPage/>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
{:else}
|
{:else}
|
||||||
@@ -26,7 +27,7 @@
|
|||||||
<h1>{TITLE}</h1>
|
<h1>{TITLE}</h1>
|
||||||
</header>
|
</header>
|
||||||
<article>
|
<article>
|
||||||
<Formular bind:activeRecord={activeRecord}/>
|
<Formular bind:activeRecord={activeRecord} bind:currentPage/>
|
||||||
</article>
|
</article>
|
||||||
</section>
|
</section>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -82,6 +82,7 @@
|
|||||||
let nextDate = null
|
let nextDate = null
|
||||||
let activeRecordList = []
|
let activeRecordList = []
|
||||||
export let activeRecord = null
|
export let activeRecord = null
|
||||||
|
export let currentPage = 1
|
||||||
let period_of_edit
|
let period_of_edit
|
||||||
let makeTimekeepingList
|
let makeTimekeepingList
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,26 @@
|
|||||||
<script>
|
<script>
|
||||||
import {WorkingHoursRepository} from "../../components/Repositories.svelte"
|
import { WorkingHoursRepository } from '../../components/Repositories.svelte'
|
||||||
import {TimekeepingDate} from "../../components/TimekeepingDate.svelte"
|
import { TimekeepingDate } from '../../components/TimekeepingDate.svelte'
|
||||||
|
import { paginate, PaginationNav } from 'svelte-paginate'
|
||||||
export let activeRecord = null
|
|
||||||
let isLoading = true
|
|
||||||
let records = []
|
|
||||||
import IconifyIcon from '@iconify/svelte'
|
import IconifyIcon from '@iconify/svelte'
|
||||||
import wrenchIcon from '@iconify-icons/oi/wrench'
|
import wrenchIcon from '@iconify-icons/oi/wrench'
|
||||||
import documentIcon from '@iconify-icons/oi/document'
|
import documentIcon from '@iconify-icons/oi/document'
|
||||||
|
|
||||||
|
export let activeRecord = null
|
||||||
|
let isLoading = true
|
||||||
|
let records = []
|
||||||
|
export let currentPage = 1
|
||||||
|
let pageSize = 15
|
||||||
|
$: paginatedItems = paginate({ items: records, pageSize, currentPage })
|
||||||
|
|
||||||
const Controller = {
|
const Controller = {
|
||||||
'listRecords': () => {
|
'listRecords': () => {
|
||||||
Controller.cancelActiveRecord();
|
Controller.cancelActiveRecord()
|
||||||
WorkingHoursRepository.browse().then(data => {
|
WorkingHoursRepository.browse().then(data => {
|
||||||
Controller.cancelActiveRecord()
|
Controller.cancelActiveRecord()
|
||||||
records = data
|
records = data
|
||||||
isLoading = false
|
isLoading = false
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
'newRecord': async () => {
|
'newRecord': async () => {
|
||||||
const actDate = new TimekeepingDate()
|
const actDate = new TimekeepingDate()
|
||||||
@@ -27,11 +31,11 @@
|
|||||||
Controller.listRecords()
|
Controller.listRecords()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
activeRecord = data;
|
activeRecord = data
|
||||||
}),
|
}),
|
||||||
'cancelActiveRecord': () => {
|
'cancelActiveRecord': () => {
|
||||||
activeRecord = null;
|
activeRecord = null
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
Controller.listRecords()
|
Controller.listRecords()
|
||||||
</script>
|
</script>
|
||||||
@@ -61,7 +65,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each records as record}
|
{#each paginatedItems as record}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{record.workingDay}</td>
|
<td>{record.workingDay}</td>
|
||||||
<td>{record.workingTime}</td>
|
<td>{record.workingTime}</td>
|
||||||
@@ -73,5 +77,19 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{/each}
|
{/each}
|
||||||
</tbody>
|
</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>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
Reference in New Issue
Block a user