Calendar bugs

- Fix 'Today' button went to yesterday if timezone was < GMT
- Fix navigation buttons & scrolling in year planner
- Fix sometimes missing data in year planner if timezone was < GMT
This commit is contained in:
Nathan Gray 2015-08-19 16:17:55 +00:00
parent 4338493d2c
commit 8cb0aade18
4 changed files with 31 additions and 33 deletions

View File

@ -2651,6 +2651,17 @@ jQuery.extend(app.classes.calendar,{
},
scroll: function(delta)
{
var d = new Date(app.calendar.state.date);
// Yearly view, grouped by month - scroll 1 month
if(app.calendar.state.sortby === 'month')
{
d.setUTCMonth(d.getUTCMonth() + delta)
d.setUTCDate(1);
d.setUTCHours(0);
d.setUTCMinutes(0);
return d;
}
// Need to set the day count, or auto date ranging takes over and
// makes things buggy
if(app.calendar.state.first && app.calendar.state.last)
@ -2658,7 +2669,6 @@ jQuery.extend(app.classes.calendar,{
var diff = new Date(app.calendar.state.last) - new Date(app.calendar.state.first);
app.calendar.state.planner_days = Math.round(diff / (1000*3600*24));
}
var d = new Date(app.calendar.state.date);
d.setUTCDate(d.getUTCDate() + (app.calendar.state.planner_days*delta));
if(app.calendar.state.planner_days > 8)
{

View File

@ -181,7 +181,7 @@ var et2_calendar_daycol = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResizea
{
// Need a new date to avoid invalid month/date combinations when setting
// month then day
this._parent.date_helper.set_value(new Date(_date.substring(0,4),_date.substring(4,6)-1,_date.substring(6,8)));
this._parent.date_helper.set_value(new Date(_date.substring(0,4),_date.substring(4,6)-1,_date.substring(6,8),-new Date().getTimezoneOffset()/60,0,0));
}
this.date = new Date(this._parent.date_helper.getValue());

View File

@ -413,14 +413,16 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
d = new Date(d.valueOf() + d.getTimezoneOffset() * 60 * 1000);
for(var i = 0; i < 12; i++)
{
labels.push({id: d.getUTCFullYear() +'-'+d.getUTCMonth(), label:egw.lang(date('F',d))+' '+d.getUTCFullYear()});
d.setUTCMonth(d.getUTCMonth()+1);
// Not using UTC because we corrected for timezone offset
labels.push({id: d.getFullYear() +'-'+d.getMonth(), label:egw.lang(date('F',d))+' '+d.getFullYear()});
d.setMonth(d.getMonth()+1);
}
return labels;
},
group: function(labels, rows,event) {
var start = new Date(event.start);
var key = start.getUTCFullYear() +'-'+start.getUTCMonth();
start = new Date(start.valueOf() + start.getTimezoneOffset() * 60 * 1000);
var key = start.getFullYear() +'-'+start.getMonth();
var label_index = false;
for(var i = 0; i < labels.length; i++)
{
@ -438,11 +440,12 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
// end in a different month?
var end = new Date(event.end);
var end_key = end.getUTCFullYear() +'-'+end.getUTCMonth();
end = new Date(end.valueOf() + end.getTimezoneOffset() * 60 * 1000);
var end_key = end.getFullYear() +'-'+end.getMonth();
while(key !== end_key)
{
var year = start.getUTCFullYear();
var month = start.getUTCMonth();
var year = start.getFullYear();
var month = start.getMonth();
if (++month > 12)
{
++year;
@ -707,34 +710,19 @@ var et2_calendar_planner = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResize
// calculate date for navigation links
var time = new Date(start);
time.setUTCFullYear(time.getUTCFullYear()-1);
var last_year = date('Ymd',time);
var last_year = time.toJSON();
time.setUTCMonth(time.getUTCMonth()+11);
var last_month = date('Ymd',time);
var last_month = time.toJSON();
time.setUTCMonth(time.getUTCMonth()+2);
var next_month = date('Ymd',time);
var next_month = time.toJSON();
time.setUTCMonth(time.getUTCMonth()+11);
var next_year = date('Ymd',time);
var next_year = time.toJSON();
title = last_year + ' ' + last_month + ' ' + title + ' ' +next_month +' ' +next_year;
/*
* TODO: implement these arrows
title = html::a_href(html::image('phpgwapi','first',lang('back one year'),$options=' alt="<<"'),array(
'menuaction' => $this->view_menuaction,
'date' => $last_year,
)) + ' &nbsp; '+
html::a_href(html::image('phpgwapi','left',lang('back one month'),$options=' alt="<"'),array(
'menuaction' => $this->view_menuaction,
'date' => $last_month,
)) + ' &nbsp; '+title;
title += ' &nbsp; '.html::a_href(html::image('phpgwapi','right',lang('forward one month'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => $next_month,
))+ ' &nbsp; '+
html::a_href(html::image('phpgwapi','last',lang('forward one year'),$options=' alt=">>"'),array(
'menuaction' => $this->view_menuaction,
'date' => $next_year,
));
*/
title = this._scroll_button('first',last_year) +
this._scroll_button('left', last_month) +
title +
this._scroll_button('right', next_month) +
this._scroll_button('last', next_year);
content += '<div class="calendar_plannerMonthScale th" style="left: 0; width: 100%;">'+
title+"</div>";

View File

@ -179,7 +179,7 @@ var et2_calendar_timegrid = et2_valueWidget.extend([et2_IDetachedDOM, et2_IResiz
$j(this).resizable
({
distance: 10,
grid: [10000,timegrid.rowHeight],
grid: [10000,10],
autoHide: false,
handles: 's,se',
containment:'parent',