Commit 400fb51d authored by Kent Nielsen's avatar Kent Nielsen
Browse files

Day now show correct when resizing. Movement of day and week working

parent 1d5be5e3
......@@ -133,15 +133,26 @@ export default {
}
},
methods: {
daysToAdd (forward){
if(this.schedule.length == 1){
if((this.today.getDay() == 5 && forward) || (this.today.getDay() == 1 && !forward)){
return 3;
} else {
return 1;
}
}
return 7;
},
// Move the date 7 days back
prevWeek(){
this.today = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate() - 7);
prevWeek(){
this.today = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate() - this.daysToAdd(false));
this.changeSchedule();
},
// Move the date 7 days forward
nextWeek(){
this.today = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate() + 7);
this.today = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate() + this.daysToAdd(true));
this.changeSchedule();
},
......@@ -206,18 +217,25 @@ export default {
updateDaysInDisplay(){
if(parseInt(document.getElementById("calendar").clientWidth) < 400){
this.colSpanValue = 5;
this.schedule = this.scheduleDay;
if(this.schedule.length == 5){
this.colSpanValue = 5;
const day =(this.schedule[this.today.getDay() - 1])
console.log(this.schedule);
console.log(day);
console.log(this.scheduleDay);
this.scheduleDay[0] = day;
this.schedule = this.scheduleDay;
}
}else{
this.colSpanValue = 1;
this.schedule=this.scheduleWeek12;
this.changeSchedule();
}
},
initToday(){
const firstDayOfWeek = this.getDateOfISOWeek(this.getWeek(this.today), this.today.getFullYear(),0).getDate();
const lastDayOfWeek = this.getDateOfISOWeek(this.getWeek(this.today), this.today.getFullYear(),4).getDate();
console.log(this.today.getDate())
if(this.today.getDate() > lastDayOfWeek || this.today.getDate() < firstDayOfWeek){
while(this.today.getDate() < lastDayOfWeek){
this.today = new Date(this.today.getFullYear(), this.today.getMonth(), this.today.getDate()-1);
......@@ -226,11 +244,10 @@ export default {
}
},
mounted(){
this.initToday();
this.updateHalfHourSize();
this.updateDaysInDisplay();
this.initToday();
window.addEventListener("resize", this.updateDaysInDisplay)
console.log(this.today.getDay())
// Update en data variable, da alle td også skal have colspan
},
updated(){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment