✨ Add swipe gestures for changing days
This commit is contained in:
29
src/util.js
29
src/util.js
@ -1,4 +1,11 @@
|
||||
import { classFilter } from "./store";
|
||||
import {
|
||||
classFilter,
|
||||
fetchSubstitutions,
|
||||
fetchHistory,
|
||||
loading,
|
||||
selectedDate,
|
||||
} from "./store";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
export function getSubstitutionText(substitution) {
|
||||
const includeClass = !classFilter.value || classFilter.value == "none";
|
||||
@ -22,3 +29,23 @@ export function getSubstitutionColor(substitution) {
|
||||
return "background-color: var(--substitution-background-cancellation);";
|
||||
}
|
||||
}
|
||||
|
||||
export function nextDay() {
|
||||
var newDate = dayjs(selectedDate.value).add(1, "day");
|
||||
// Skip weekend
|
||||
if (newDate.day() == 6) newDate = newDate.add(2, "day");
|
||||
changeDate(newDate);
|
||||
}
|
||||
export function previousDay() {
|
||||
var newDate = dayjs(selectedDate.value).subtract(1, "day");
|
||||
// Skip weekend
|
||||
if (newDate.day() == 0) newDate = newDate.subtract(2, "day");
|
||||
changeDate(newDate);
|
||||
}
|
||||
export async function changeDate(newDate) {
|
||||
selectedDate.value = new Date(newDate.toDate().setUTCHours(0, 0, 0, 0));
|
||||
loading.value = true;
|
||||
await fetchSubstitutions();
|
||||
await fetchHistory();
|
||||
loading.value = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user