mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
fix(Calendar Weeks View): updates the number of weeks in the weeks View when going to the next or previous year
This commit is contained in:
@@ -9,11 +9,11 @@ export default {
|
||||
'focusDate'
|
||||
],
|
||||
data() {
|
||||
return {
|
||||
weeks: [...Array(this.focusDate.numWeeks).keys()].map(i => i+1)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
weeks(){
|
||||
return [...Array(this.focusDate.numWeeks).keys()].map(i => i + 1);
|
||||
},
|
||||
title() {
|
||||
return this.focusDate.format({year: 'numeric'});
|
||||
}
|
||||
@@ -23,11 +23,19 @@ export default {
|
||||
// TODO(chris): test is there a week jump on year select? => yes there is if the same month/day are in different weeks ... should we prevent that?
|
||||
this.focusDate.w = week;
|
||||
this.$emit('updateMode', 'week');
|
||||
}
|
||||
},
|
||||
prev(){
|
||||
this.focusDate.y--;
|
||||
this.focusDate._clean();
|
||||
},
|
||||
next() {
|
||||
this.focusDate.y++;
|
||||
this.focusDate._clean();
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<div class="fhc-calendar-weeks">
|
||||
<calendar-header :title="title" @prev="focusDate.y--" @next="focusDate.y++" @click="$emit('updateMode', 'years')" @updateMode="$emit('updateMode', $event)" />
|
||||
<calendar-header :title="title" @prev="prev" @next="next" @click="$emit('updateMode', 'years')" @updateMode="$emit('updateMode', $event)" />
|
||||
<div class="d-flex flex-wrap">
|
||||
<div v-for="(week, key) in weeks" :key="key" class="d-grid col-2">
|
||||
<button @click="setWeek(week)" class="btn btn-outline-secondary" :class="{'border-0': week != focusDate.w}">
|
||||
|
||||
@@ -128,7 +128,9 @@ class CalendarDate {
|
||||
get numWeeks() {
|
||||
// if the week starts with Monday we have to go 3 days in the past from the start of the next year to get the correct numWeek of the current year
|
||||
// this is because for example 30.12.2024 - 05.01.2025 is the first calendarWeek of 2025
|
||||
return (new CalendarDate(this.y+1,0,this.weekStart == 1 ? -3 : 0)).w;
|
||||
let lastCalendarWeek = new CalendarDate(this.y + 1, 0, this.weekStart == 1 ? -3 : 0);
|
||||
lastCalendarWeek.weekStart = this.weekStart;
|
||||
return lastCalendarWeek.w;
|
||||
}
|
||||
set(y,m,d,noClean) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user