Calendar: Clean up next/previous for yearly planner to always jump by 1 month

This commit is contained in:
nathangray 2021-01-11 10:23:07 -07:00
parent 0ff219fab9
commit b911da6eb8
2 changed files with 9 additions and 5 deletions

View File

@ -335,11 +335,12 @@ var planner = /** @class */ (function (_super_1) {
return (check.indexOf(egw.preference('planner_show_empty_rows', 'calendar') + '') === -1); return (check.indexOf(egw.preference('planner_show_empty_rows', 'calendar') + '') === -1);
}; };
planner.scroll = function (delta) { planner.scroll = function (delta) {
if (app.calendar.state.planner_view) { if (app.calendar.state.planner_view && !isNaN(delta) && app.calendar.state.sortby !== "month") {
return app.classes.calendar.views[app.calendar.state.planner_view].scroll(delta); return app.classes.calendar.views[app.calendar.state.planner_view].scroll(delta);
} }
var d = new Date(app.calendar.state.date); var d = new Date(app.calendar.state.date);
var days = 1; var days = 1;
delta = parseInt(delta) || 0;
// Yearly view, grouped by month - scroll 1 month // Yearly view, grouped by month - scroll 1 month
if (app.calendar.state.sortby === 'month') { if (app.calendar.state.sortby === 'month') {
d.setUTCMonth(d.getUTCMonth() + delta); d.setUTCMonth(d.getUTCMonth() + delta);
@ -351,6 +352,7 @@ var planner = /** @class */ (function (_super_1) {
// Need to set the day count, or auto date ranging takes over and // Need to set the day count, or auto date ranging takes over and
// makes things buggy // makes things buggy
if (app.calendar.state.first && app.calendar.state.last) { if (app.calendar.state.first && app.calendar.state.last) {
//@ts-ignore
var diff = new Date(app.calendar.state.last) - new Date(app.calendar.state.first); var diff = new Date(app.calendar.state.last) - new Date(app.calendar.state.first);
days = Math.round(diff / (1000 * 3600 * 24)); days = Math.round(diff / (1000 * 3600 * 24));
} }

View File

@ -380,12 +380,13 @@ export class planner extends View
static scroll(delta) static scroll(delta)
{ {
if(app.calendar.state.planner_view) if(app.calendar.state.planner_view && !isNaN(delta) && app.calendar.state.sortby !== "month")
{ {
return app.classes.calendar.views[app.calendar.state.planner_view].scroll(delta); return app.classes.calendar.views[app.calendar.state.planner_view].scroll(delta);
} }
var d = new Date(app.calendar.state.date); let d = new Date(app.calendar.state.date);
var days = 1; let days = 1;
delta = parseInt(delta) || 0;
// Yearly view, grouped by month - scroll 1 month // Yearly view, grouped by month - scroll 1 month
if(app.calendar.state.sortby === 'month') if(app.calendar.state.sortby === 'month')
@ -400,7 +401,8 @@ export class planner extends View
// makes things buggy // makes things buggy
if(app.calendar.state.first && app.calendar.state.last) if(app.calendar.state.first && app.calendar.state.last)
{ {
var diff = new Date(app.calendar.state.last) - new Date(app.calendar.state.first); //@ts-ignore
let diff = new Date(app.calendar.state.last) - new Date(app.calendar.state.first);
days = Math.round(diff / (1000 * 3600 * 24)); days = Math.round(diff / (1000 * 3600 * 24));
} }
d.setUTCDate(d.getUTCDate() + (days * delta)); d.setUTCDate(d.getUTCDate() + (days * delta));