diff --git a/app/src/components/TimeInputComponent.vue b/app/src/components/TimeInputComponent.vue index ac7b356..3ea7abd 100644 --- a/app/src/components/TimeInputComponent.vue +++ b/app/src/components/TimeInputComponent.vue @@ -101,7 +101,7 @@ const onIncrementClick = (type) => { interval.value = setInterval(() => { incrementValue(type); }, 100); - }, 1000); + }, 500); } const onDecrementClick = (type) => { @@ -110,7 +110,7 @@ const onDecrementClick = (type) => { interval.value = setInterval(() => { decrementValue(type); }, 100); - }, 1000); + }, 500); } diff --git a/app/src/stores/WorkHoursStore.js b/app/src/stores/WorkHoursStore.js index b89ab6b..4346b3c 100644 --- a/app/src/stores/WorkHoursStore.js +++ b/app/src/stores/WorkHoursStore.js @@ -48,6 +48,7 @@ export const useWorkHoursStore = defineStore('workHours', () => { watch( () => workHours.value.map((entry, index) => ({ index, + date: entry.date, enterHour: entry.enterHour, enterMinute: entry.enterMinute, leaveHour: entry.leaveHour, @@ -63,6 +64,7 @@ export const useWorkHoursStore = defineStore('workHours', () => { // Sprawdzamy, czy cokolwiek się zmieniło else if ( + newEntry.date !== oldEntry.date || newEntry.enterHour !== oldEntry.enterHour || newEntry.enterMinute !== oldEntry.enterMinute || newEntry.leaveHour !== oldEntry.leaveHour || @@ -85,14 +87,14 @@ export const useWorkHoursStore = defineStore('workHours', () => { }; const getWeekday = (index) => { - const dayNames = ['NIE', 'PON', 'WTO', 'śRO', 'CZW', 'PIĄ', 'SOB']; + const dayNames = ['NIE', 'PON', 'WTO', 'ŚRO', 'CZW', 'PIĄ', 'SOB']; const weekday = workHours.value[index].date.getDay(); return [weekday, dayNames[weekday]]; - } + }; const clear = () => { workHours.value = []; - } + }; const parseWorkHours = (userInput) => { const lines = userInput.split('\n').map(line => line.trim()).filter(line => line); @@ -120,14 +122,36 @@ export const useWorkHoursStore = defineStore('workHours', () => { }); } } - + result.sort((a, b) => a.date - b.date); workHours.value = result; - } + }; + + const addWorkDay = (date) => { + const newEntry = { + date: date, + enterHour: 7, + enterMinute: 0, + leaveHour: 15, + leaveMinute: 15, + workHours: null, + workMinutes: null + }; + + const index = workHours.value.findIndex((entry) => entry.date > newEntry.date); + + if (index === -1) { + workHours.value.push(newEntry); + } else { + workHours.value.splice(index, 0, newEntry); + } + }; + return { workHours, getDate, getWeekday, clear, - parseWorkHours + parseWorkHours, + addWorkDay, } }) diff --git a/app/src/views/EditView.vue b/app/src/views/EditView.vue index d04a624..7eb99dd 100644 --- a/app/src/views/EditView.vue +++ b/app/src/views/EditView.vue @@ -8,7 +8,8 @@ data-bs-target="#inputModal">WCZYTAJ - + @@ -108,6 +109,29 @@ + + \ No newline at end of file