Feature: füge Pagination zum CSV-Import hinzu
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
<script>
|
<script>
|
||||||
import Papa from '../../../papaparse.min'
|
import Papa from '../../../papaparse.min'
|
||||||
|
import { paginate, PaginationNav } from 'svelte-paginate'
|
||||||
|
|
||||||
export let activeRecordList = []
|
export let activeRecordList = []
|
||||||
let imported_data = []
|
let imported_data = []
|
||||||
|
export let currentPage = 1
|
||||||
|
let pageSize = 15
|
||||||
|
$: paginatedItems = paginate({ items: imported_data, pageSize, currentPage })
|
||||||
|
|
||||||
let files = null
|
let files = null
|
||||||
|
|
||||||
@@ -26,17 +31,17 @@
|
|||||||
let work_from = new Date(item['Von'])
|
let work_from = new Date(item['Von'])
|
||||||
let work_to = new Date(item['Bis'])
|
let work_to = new Date(item['Bis'])
|
||||||
let actual_day = work_from.toISOString().substring(0, 10)
|
let actual_day = work_from.toISOString().substring(0, 10)
|
||||||
let actual_work_hours = (work_to - work_from)/(1000*60*60)
|
let actual_work_hours = (work_to - work_from) / (1000 * 60 * 60)
|
||||||
cash_work_days[actual_day] ??= 0
|
cash_work_days[actual_day] ??= 0
|
||||||
cash_work_days[actual_day] += actual_work_hours
|
cash_work_days[actual_day] += actual_work_hours
|
||||||
})
|
})
|
||||||
for (let day in cash_work_days) {
|
for (let day in cash_work_days) {
|
||||||
let hours = cash_work_days[day]
|
let hours = cash_work_days[day]
|
||||||
let hours_digits = Math.trunc(hours)
|
let hours_digits = Math.trunc(hours)
|
||||||
let minutes_digits = Math.round((hours-hours_digits)*60)
|
let minutes_digits = Math.round((hours - hours_digits) * 60)
|
||||||
let working_time = String(hours_digits).padStart(2, '0') + ":"
|
let working_time = String(hours_digits).padStart(2, '0') + ':'
|
||||||
+ String(minutes_digits).padStart(2, '0') + ':00'
|
+ String(minutes_digits).padStart(2, '0') + ':00'
|
||||||
activeRecordList.push({workingTime: working_time, workingDay: day})
|
activeRecordList.push({ workingTime: working_time, workingDay: day })
|
||||||
}
|
}
|
||||||
imported_data = activeRecordList
|
imported_data = activeRecordList
|
||||||
},
|
},
|
||||||
@@ -55,23 +60,37 @@
|
|||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset name="record-data-for-import">
|
<fieldset name="record-data-for-import">
|
||||||
<div>
|
<div>
|
||||||
{#if imported_data.length < 1}
|
{#if imported_data.length < 1}
|
||||||
<p>Loading...</p>
|
<p>Loading...</p>
|
||||||
{:else}
|
{:else}
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
{#each imported_data as item}
|
{#each imported_data as item}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{item.workingDay}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{item.workingTime}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td colspan="4">
|
||||||
{item.workingDay}
|
<PaginationNav
|
||||||
</td>
|
totalItems="{imported_data.length}"
|
||||||
<td>
|
pageSize="{pageSize}"
|
||||||
{item.workingTime}
|
currentPage="{currentPage}"
|
||||||
|
limit="{1}"
|
||||||
|
showStepOptions="{true}"
|
||||||
|
on:setPage="{(e) => currentPage = e.detail.page}"
|
||||||
|
/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/each}
|
</tfoot>
|
||||||
</tbody>
|
</table>
|
||||||
</table>
|
{/if}
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user