Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…pusdual into dev
  • Loading branch information
probablyjassin committed Oct 14, 2024
2 parents b54838c + a6171e4 commit f93b54b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions pages/stundenplan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
</p>
<span class="mb-4 flex text-center items-center space-x-4">
<UPagination v-model="page" :total="data.length" />
<UButton
<UButton
v-if="Object.keys(groupedByDay).indexOf(today.toString()) !== -1"
:class="{ 'opacity-0': page == Object.keys(groupedByDay).indexOf(today.toString())+1 }"
class="py-2"
@click="page = Object.keys(groupedByDay).indexOf(today.toString())+1">
Expand All @@ -36,7 +37,17 @@
const schedule = computed(() => Object.values(groupedByDay.value));
watch(groupedByDay.value, (newVal) => {
page.value = Object.keys(newVal).indexOf(today.toString())+1;
const todayIndex = Object.keys(newVal).indexOf(today.toString());
if (todayIndex !== -1) {
page.value = todayIndex + 1;
} else {
const futureDates = Object.keys(newVal).filter(date => Number(date) > today);
if (futureDates.length > 0) {
page.value = Object.keys(newVal).indexOf(futureDates[0]) + 1;
} else {
page.value = 1;
}
}
});
onMounted(async () => {
Expand Down

0 comments on commit f93b54b

Please sign in to comment.