[fix] Issues with freebusy in attendees editor

pull/77/head
Francis Lachapelle 2015-04-01 20:10:52 -04:00
parent 77917780c8
commit e2c3259b16
2 changed files with 8 additions and 8 deletions

View File

@ -119,7 +119,7 @@ Date.prototype.clone = function() {
newDate.setTime(this.getTime());
return newDate;
}
};
Date.prototype.deltaDays = function(otherDate) {
var day1 = this.getTime();
@ -131,7 +131,7 @@ Date.prototype.deltaDays = function(otherDate) {
}
return Math.round((day2 - day1) / 86400000);
}
};
Date.prototype.daysUpTo = function(otherDate) {
var days = new Array();
@ -248,7 +248,7 @@ Date.prototype.beginOfDay = function() {
beginOfDay.setMilliseconds(0);
return beginOfDay;
}
};
Date.prototype.beginOfWeek = function() {
var offset = firstDayOfWeek - this.getDay();

View File

@ -905,7 +905,7 @@ _freeBusyCacheEntry.prototype = {
var adjustedEd = ed.beginOfDay();
var nbrDays = adjustedSd.deltaDays(adjustedEd) + 1;
var offsetEnd = offset + (nbrDays * 96);
if (Math.round(this.entries.length/96) >= nbrDays) {
if (Math.round((this.entries.length - offset)/96) >= nbrDays) {
entries = this.entries.slice(offset, offsetEnd);
}
}
@ -942,7 +942,6 @@ _freeBusyCacheEntry.prototype = {
// Period extends to after current end
if (start.getTime() <= nextDate.getTime()) {
start = nextDate.beginOfDay();
start.addDays(1);
}
fetchDates.push({ start: start, end: end });
}
@ -960,7 +959,7 @@ _freeBusyCacheEntry.prototype = {
if (this.startDate) {
if (start.getTime() < this.startDate) {
days = start.deltaDays(this.startDate);
if (entries.length == (days * 96)) {
if (Math.round(entries.length/96) == days) {
// New period is just before previous period
this.startDate = start;
this.entries = entries.concat(this.entries);
@ -1131,7 +1130,7 @@ function displayFreeBusyForNode(input) {
var rowIndex = input.parentNode.parentNode.sectionRowIndex;
var row = $("freeBusyData").tBodies[0].rows[rowIndex];
var nodes = row.cells;
//log ("displayFreeBusyForNode index " + rowIndex + " (" + nodes.length + " cells)");
//log ("displayFreeBusyForNode index " + rowIndex + " uid " + input.uid + " (" + nodes.length + " cells)");
if (input.uid) {
if (!input.hasfreebusy) {
// log("forcing draw of nodes");
@ -1459,10 +1458,11 @@ function onTimeDateWidgetChange() {
function prepareTableHeaders() {
var startTimeDate = $("startTime_date");
var startDate = startTimeDate.inputAsDate();
startDate.setHours(0, 0);
var endTimeDate = $("endTime_date");
var endDate = endTimeDate.inputAsDate();
endDate.setTime(endDate.getTime());
endDate.setHours(0, 0);
var rows = $("freeBusyHeader").rows;
var days = startDate.daysUpTo(endDate);