✨ Skip weekend days on the timetable
This commit is contained in:
@ -3,13 +3,24 @@ import { selectedDate, selectedDay } from "../store";
|
|||||||
import { dayNames } from "../definitions";
|
import { dayNames } from "../definitions";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import ArrowIcon from "./icons/arrow-icon.vue";
|
import ArrowIcon from "./icons/arrow-icon.vue";
|
||||||
|
|
||||||
|
function nextDay() {
|
||||||
|
var newDate = dayjs(selectedDate.value).add(1, "day");
|
||||||
|
// Skip weekend
|
||||||
|
if (newDate.day() == 6) newDate = newDate.add(2, "day");
|
||||||
|
selectedDate.value = newDate.toDate();
|
||||||
|
}
|
||||||
|
function previousDay() {
|
||||||
|
var newDate = dayjs(selectedDate.value).subtract(1, "day");
|
||||||
|
// Skip weekend
|
||||||
|
if (newDate.day() == 0) newDate = newDate.subtract(2, "day");
|
||||||
|
selectedDate.value = newDate.toDate();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="selector">
|
<div class="selector">
|
||||||
<ArrowIcon
|
<ArrowIcon @click="previousDay" />
|
||||||
@click="selectedDate = dayjs(selectedDate).subtract(1, 'day').toDate()"
|
|
||||||
/>
|
|
||||||
<span
|
<span
|
||||||
class="day"
|
class="day"
|
||||||
@click="selectedDate = new Date(new Date().setUTCHours(0, 0, 0, 0))"
|
@click="selectedDate = new Date(new Date().setUTCHours(0, 0, 0, 0))"
|
||||||
@ -17,10 +28,7 @@ import ArrowIcon from "./icons/arrow-icon.vue";
|
|||||||
{{ dayNames[selectedDay + 1] }},
|
{{ dayNames[selectedDay + 1] }},
|
||||||
{{ dayjs(selectedDate).format("DD.MM.YYYY") }}
|
{{ dayjs(selectedDate).format("DD.MM.YYYY") }}
|
||||||
</span>
|
</span>
|
||||||
<ArrowIcon
|
<ArrowIcon style="transform: rotate(180deg)" @click="nextDay" />
|
||||||
style="transform: rotate(180deg)"
|
|
||||||
@click="selectedDate = dayjs(selectedDate).add(1, 'day').toDate()"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user