Feature: ermögliche den Import von CSV-Daten
This commit is contained in:
@@ -102,9 +102,9 @@
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<form action="/working-hours" name="editRecord">
|
||||
<nav class="menu">
|
||||
<span on:click={MenuController.dailyEdit} on:keypress={() => {}} class:active={period_of_edit === DAILY_EDIT}>Täglich</span>
|
||||
<span on:click={MenuController.weeklyEdit} on:keypress={() => {}} class:active={period_of_edit === WEEKLY_EDIT}>Wöchentlich</span>
|
||||
<span on:click={MenuController.csvImport} on:keypress={() => {}} class:active={period_of_edit === CSV_IMPORT}>Import per CSV</span>
|
||||
<span on:click={MenuController.dailyEdit} class:active={period_of_edit === DAILY_EDIT}>Täglich</span>
|
||||
<span on:click={MenuController.weeklyEdit} class:active={period_of_edit === WEEKLY_EDIT}>Wöchentlich</span>
|
||||
<span on:click={MenuController.csvImport} class:active={period_of_edit === CSV_IMPORT}>Import per CSV</span>
|
||||
</nav>
|
||||
{#if period_of_edit === DAILY_EDIT}
|
||||
<EditByDay bind:activeRecordList bind:activeDate bind:makeTimekeepingList/>
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
<script>
|
||||
import Papa from '../../../papaparse.min'
|
||||
import { paginate, PaginationNav } from 'svelte-paginate'
|
||||
|
||||
export let activeRecordList = []
|
||||
let imported_data = []
|
||||
export let currentPage = 1
|
||||
let pageSize = 15
|
||||
$: paginatedItems = paginate({ items: imported_data, pageSize, currentPage })
|
||||
|
||||
let files = null
|
||||
|
||||
@@ -31,17 +26,20 @@
|
||||
let work_from = new Date(item['Von'])
|
||||
let work_to = new Date(item['Bis'])
|
||||
let actual_day = work_from.toISOString().substring(0, 10)
|
||||
let actual_work_hours = (work_to - work_from) / (1000 * 60 * 60)
|
||||
cash_work_days[actual_day] ??= 0
|
||||
cash_work_days[actual_day] += actual_work_hours
|
||||
let actual_work_hours = (work_to - work_from)/(1000*60*60)
|
||||
if (cash_work_days[actual_day] === undefined) {
|
||||
cash_work_days[actual_day] = actual_work_hours
|
||||
} else {
|
||||
cash_work_days[actual_day] += actual_work_hours
|
||||
}
|
||||
})
|
||||
for (let day in cash_work_days) {
|
||||
let hours = cash_work_days[day]
|
||||
let hours_digits = Math.trunc(hours)
|
||||
let minutes_digits = Math.round((hours - hours_digits) * 60)
|
||||
let working_time = String(hours_digits).padStart(2, '0') + ':'
|
||||
let minutes_digits = Math.round((hours-hours_digits)*60)
|
||||
let working_time = String(hours_digits).padStart(2, '0') + ":"
|
||||
+ String(minutes_digits).padStart(2, '0') + ':00'
|
||||
activeRecordList.push({ workingTime: working_time, workingDay: day })
|
||||
activeRecordList.push({workingTime: working_time, workingDay: day})
|
||||
}
|
||||
imported_data = activeRecordList
|
||||
},
|
||||
@@ -60,37 +58,23 @@
|
||||
</fieldset>
|
||||
<fieldset name="record-data-for-import">
|
||||
<div>
|
||||
{#if imported_data.length < 1}
|
||||
<p>Loading...</p>
|
||||
{:else}
|
||||
<table>
|
||||
<tbody>
|
||||
{#each imported_data as item}
|
||||
<tr>
|
||||
<td>
|
||||
{item.workingDay}
|
||||
</td>
|
||||
<td>
|
||||
{item.workingTime}
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{#if imported_data.length < 1}
|
||||
<p>Loading...</p>
|
||||
{:else}
|
||||
<table>
|
||||
<tbody>
|
||||
{#each imported_data as item}
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<PaginationNav
|
||||
totalItems="{imported_data.length}"
|
||||
pageSize="{pageSize}"
|
||||
currentPage="{currentPage}"
|
||||
limit="{1}"
|
||||
showStepOptions="{true}"
|
||||
on:setPage="{(e) => currentPage = e.detail.page}"
|
||||
/>
|
||||
<td>
|
||||
{item.workingDay}
|
||||
</td>
|
||||
<td>
|
||||
{item.workingTime}
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
{/if}
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
Reference in New Issue
Block a user