Feature: Schnellere Eingabe der Daten ist möglich

This commit is contained in:
2021-12-16 12:20:37 +01:00
parent ad253a82f5
commit d133cb017b
3 changed files with 27 additions and 4 deletions
+15
View File
@@ -0,0 +1,15 @@
<script context="module">
export class TimekeepingDate extends Date {
getDateString() {
return this.getFullYear() + "-"
+ (this.getMonth() + 1).toString().padStart(2, '0') + "-"
+ this.getDate().toString().padStart(2, '0')
}
getNextDay() {
let nextDay = new TimekeepingDate(this);
nextDay.setDate(this.getDate() + 1)
return nextDay
}
}
</script>
+9 -3
View File
@@ -3,6 +3,7 @@
import IconifyIcon from '@iconify/svelte'
import checkIcon from '@iconify-icons/oi/check'
import xIcon from '@iconify-icons/oi/x'
import {TimekeepingDate} from "../../components/TimekeepingDate.svelte"
export let activeRecord = null
export let newRecord = false
@@ -10,14 +11,19 @@
'saveRecord': () => {
if (newRecord === true) {
WorkingHoursRepository.add(activeRecord).then(() => {
Controller.cancelActiveRecord()
Controller.nextDay()
});
} else {
WorkingHoursRepository.update(activeRecord.workingDay, activeRecord).then(() => {
Controller.cancelActiveRecord()
Controller.nextDay()
});
}
},
'nextDay': () => {
let actDate = new TimekeepingDate(activeRecord.workingDay)
let nextDay = actDate.getNextDay()
activeRecord = {workingTime: '00:00:00', workingDay: nextDay.getDateString()}
},
'cancelActiveRecord': () => {
activeRecord = null;
newRecord = false;
@@ -39,7 +45,7 @@
</div>
</fieldset>
<fieldset name="buttons">
<button on:click={Controller.saveRecord} type="button">Übernehmen
<button on:click={Controller.saveRecord} type="button">Übernehmen und Weiter
<IconifyIcon icon={checkIcon} color="green"/>
</button>
<button on:click={Controller.cancelActiveRecord} type="button" class="sub-button">Abbrechen
+3 -1
View File
@@ -1,5 +1,6 @@
<script>
import {WorkingHoursRepository} from "../../components/Repositories.svelte"
import {TimekeepingDate} from "../../components/TimekeepingDate.svelte"
export let activeRecord = null
export let newRecord = false
@@ -19,7 +20,8 @@
});
},
'newRecord': () => {
activeRecord = {workingTime: '00:00:00'};
const actDate = new TimekeepingDate()
activeRecord = {workingTime: '00:00:00', workingDay: actDate.getDateString()}
newRecord = true;
},
'selectActiveRecord': record => WorkingHoursRepository.read(record.workingDay).then(data => {