feature-ui/eintrag-per-woche #23

Merged
TorstenHettstedt merged 20 commits from feature-ui/eintrag-per-woche into master 2022-02-28 16:04:31 +01:00
2 changed files with 109 additions and 23 deletions
Showing only changes of commit 06128f72fc - Show all commits
+23
View File
@@ -91,6 +91,29 @@ main {
form { form {
@formLabelWidth: 10rem; @formLabelWidth: 10rem;
@formItemWidth: 40rem; @formItemWidth: 40rem;
nav.menu {
width: @formItemWidth + @formLabelWidth + 4rem;
border-color: @mainColor;
border-bottom-style: solid;
margin: 1rem auto;
span {
border-color: @mainColor;
border-style: solid solid none;
padding: 0.5rem;
display: inline-block;
font-weight: bolder;
margin-right: 1rem;
&:first-child {
margin-left: 1.5rem;
}
&:hover {
background-color: darken(@mainColorLight,10%,relativ);
}
&.active {
background-color: darken(@mainColorLight,20%,relativ);
}
}
}
fieldset { fieldset {
width: @formItemWidth + @formLabelWidth + 2rem; width: @formItemWidth + @formLabelWidth + 2rem;
margin: 1rem auto; margin: 1rem auto;
+86 -23
View File
@@ -3,39 +3,102 @@
import IconifyIcon from '@iconify/svelte' import IconifyIcon from '@iconify/svelte'
import checkIcon from '@iconify-icons/oi/check' import checkIcon from '@iconify-icons/oi/check'
import xIcon from '@iconify-icons/oi/x' import xIcon from '@iconify-icons/oi/x'
import {TimekeepingDate} from "../../components/TimekeepingDate.svelte" import EditByDay from "./Formular/EditByDay.svelte";
import EditByWeek from "./Formular/EditByWeek.svelte";
import {TimekeepingDate} from "../../components/TimekeepingDate.svelte";
const DAILY_EDIT = 0
const WEEKLY_EDIT = 1
export let activeRecord = null
const Controller = { const Controller = {
'saveRecord': () => { 'saveRecord': () => {
WorkingHoursRepository.addOrUpdate(activeRecord.workingDay, activeRecord).then(() => { activeRecordList.forEach((actualRecord) => {
Controller.nextDay() if (actualRecord.workingTime === '00:00:00') {
}); return
}, }
'nextDay': async () => { WorkingHoursRepository.addOrUpdate(actualRecord.workingDay, actualRecord);
let actDate = new TimekeepingDate(activeRecord.workingDay) })
let nextDay = actDate.getNextDay() activeDate = nextDate
activeRecord = await WorkingHoursRepository.readOrNew(nextDay.getDateString()) makeTimekeepingList()
}, },
'cancelActiveRecord': () => { 'cancelActiveRecord': () => {
activeRecord = null; activeRecordList = []
activeRecord = null
} }
} }
const WeekController = {
'makeTimekeepingList': () => {
let actualDay = WeekController.getMondayFromWeek(
activeDate === null ? new TimekeepingDate() : new TimekeepingDate(activeDate)
)
activeRecordList = []
activeDate = actualDay.getDateString()
for (const daysDiff in [0, 1, 2, 3, 4, 5, 6]) {
activeRecordList.push({workingTime: '00:00:00', workingDay: actualDay.getDateString()})
actualDay = actualDay.getNextDay()
}
nextDate = actualDay.getDateString()
WorkingHoursRepository.browse(activeRecordList[0].workingDay, activeRecordList[6].workingDay).then(data => {
data.forEach(item => {
let actualDay = new TimekeepingDate(item.workingDay)
activeRecordList[actualDay.getDay()-1].workingTime = item.workingTime
})
})
},
'getMondayFromWeek': actualDayObject => {
if (actualDayObject.getDate() === 0) {
actualDayObject.setDate(actualDayObject.getDate() - 7)
}
if (actualDayObject.getDate() !== 1) {
actualDayObject.setDate(actualDayObject.getDate() - (actualDayObject.getDay() - 1))
}
return actualDayObject
}
}
const DayController = {
'makeTimekeepingList': () => {
let actualDay = activeDate === null ? new TimekeepingDate() : new TimekeepingDate(activeDate)
WorkingHoursRepository.readOrNew(actualDay.getDateString()).then(data => {
activeRecordList = [ data ]
activeDate = actualDay.getDateString()
nextDate = actualDay.getNextDay().getDateString()
})
}
}
const MenuController = {
'dailyEdit': () => {
period_of_edit = DAILY_EDIT
makeTimekeepingList = DayController.makeTimekeepingList
makeTimekeepingList()
},
'weeklyEdit': () => {
period_of_edit = WEEKLY_EDIT
makeTimekeepingList = WeekController.makeTimekeepingList
makeTimekeepingList()
}
}
let activeDate = null
let nextDate = null
let activeRecordList = []
export let activeRecord = null
let period_of_edit
let makeTimekeepingList
MenuController.dailyEdit()
</script> </script>
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<form action="/working-hours" name="editRecord"> <form action="/working-hours" name="editRecord">
<fieldset name="record-data"> <nav class="menu">
<div> <span on:click={MenuController.dailyEdit} class:active={period_of_edit === DAILY_EDIT}>Täglich</span>
<label for="workingDay">Arbeitstag</label> <span on:click={MenuController.weeklyEdit} class:active={period_of_edit === WEEKLY_EDIT}>Wöchentlich</span>
<input bind:value={activeRecord.workingDay} type="date" </nav>
id="workingDay" required pattern="\d\{4}-[0-1]\d-[0-3]\d\"> {#if period_of_edit === DAILY_EDIT}
</div> <EditByDay bind:activeRecordList bind:activeDate bind:makeTimekeepingList/>
<div> {/if}
<label for="workingTime">Arbeitszeit</label> {#if period_of_edit === WEEKLY_EDIT}
<input bind:value={activeRecord.workingTime} placeholder="Arbeitszeit" type="time" <EditByWeek bind:activeRecordList bind:activeDate bind:makeTimekeepingList/>
id="workingTime" required pattern="[0-5]\d:[0-5]\d:[0-5]\d"> {/if}
</div>
</fieldset>
<fieldset name="buttons"> <fieldset name="buttons">
<button on:click={Controller.saveRecord} type="button">Übernehmen und Weiter <button on:click={Controller.saveRecord} type="button">Übernehmen und Weiter
<IconifyIcon icon={checkIcon} color="green"/> <IconifyIcon icon={checkIcon} color="green"/>