- Simplify grid sizing calculations

- Fix non-consolidated day update
This commit is contained in:
Nathan Gray 2016-01-15 22:43:59 +00:00
parent 2c31029f66
commit 5e5139ae2e
4 changed files with 43 additions and 38 deletions

View File

@ -1987,12 +1987,12 @@ app.classes.calendar = AppJS.extend(
break; break;
case 'day': case 'day':
var end = state.state.last = view.end_date(state.state).toJSON(); var end = state.state.last = view.end_date(state.state).toJSON();
value.push({ value.push({
id: app.classes.calendar._daywise_cache_id(date,state.state.owner), id: app.classes.calendar._daywise_cache_id(date,state.state.owner),
start_date: state.state.first, start_date: state.state.first,
end_date: state.state.last, end_date: state.state.last,
owner: view.owner(state.state) owner: view.owner(state.state)
}); });
break; break;
default: default:
var end = state.state.last = view.end_date(state.state).toJSON(); var end = state.state.last = view.end_date(state.state).toJSON();
@ -2009,7 +2009,25 @@ app.classes.calendar = AppJS.extend(
break; break;
} }
// If we have cached data for the timespan, pass it along // If we have cached data for the timespan, pass it along
this._need_data(value,state.state); // Single day with multiple owners still needs owners split to satisfy
// caching keys, otherwise they'll fetch & cache consolidated
if(state.state.view == 'day' && state.state.owner.length < parseInt(this.egw.preference('day_consolidate','calendar')))
{
day_value = [];
for(var i = 0; i < state.state.owner.length; i++)
{
day_value.push({
start_date: state.state.first,
end_date: state.state.last,
owner: state.state.owner[i]
});
}
this._need_data(day_value,state.state);
}
else
{
this._need_data(value,state.state);
}
var row_index = 0; var row_index = 0;
@ -2083,22 +2101,6 @@ app.classes.calendar = AppJS.extend(
widget.set_value(value[row_index++]); widget.set_value(value[row_index++]);
} }
},this, et2_calendar_view); },this, et2_calendar_view);
// Single day with multiple owners still needs owners split to satisfy
// caching keys, otherwise they'll cache consolidated
if(state.state.view == 'day' && state.state.owner.length < parseInt(this.egw.preference('day_consolidate','calendar')))
{
value = [];
for(var i = 0; i < state.state.owner.length; i++)
{
value.push({
start_date: state.state.first,
end_date: state.state.last,
owner: state.state.owner[i]
});
}
this._need_data(value,state.state);
}
} }
else else
{ {

View File

@ -652,8 +652,8 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
if(event.participants && this._parent.options.owner) if(event.participants && this._parent.options.owner)
{ {
var parent_owner = this._parent.options.owner; var parent_owner = this._parent.options.owner;
var match = false; var owner_match = false;
for(var i = 0; !match && i < this._parent.options.owner.length; i++ ) for(var i = 0; i < this._parent.options.owner.length; i++ )
{ {
if (parseInt(this._parent.options.owner[i]) < 0) if (parseInt(this._parent.options.owner[i]) < 0)
{ {
@ -669,20 +669,20 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
parent_owner.indexOf && parent_owner.indexOf &&
parent_owner.indexOf(id) >= 0) parent_owner.indexOf(id) >= 0)
{ {
match = true; owner_match = true;
break; break;
} }
} }
if(!match) if(!owner_match)
{ {
return(this._parent.options.owner == event.owner || owner_match = (this._parent.options.owner == event.owner ||
parent_owner.indexOf && parent_owner.indexOf &&
parent_owner.indexOf(event.owner) >= 0); parent_owner.indexOf(event.owner) >= 0);
} }
} }
// Simple, same day // Simple, same day
if(this.options.value.date && event.date == this.options.value.date) if(owner_match && this.options.value.date && event.date == this.options.value.date)
{ {
return true; return true;
} }
@ -690,15 +690,18 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM],
// Multi-day non-recurring event spans days - date does not match // Multi-day non-recurring event spans days - date does not match
var event_start = new Date(event.start); var event_start = new Date(event.start);
var event_end = new Date(event.end); var event_end = new Date(event.end);
if(this._parent.date >= event_start && this._parent.date <= event_end) if(owner_match && this._parent.date >= event_start && this._parent.date <= event_end)
{ {
return true; return true;
} }
// Delete all old actions // Delete all old actions
this._actionObject.clear(); if(this._actionObject)
this._actionObject.unregisterActions(); {
this._actionObject = null; this._actionObject.clear();
this._actionObject.unregisterActions();
this._actionObject = null;
}
// Update daywise caches // Update daywise caches
var new_cache_id = app.classes.calendar._daywise_cache_id(event.date,this._parent.options.owner); var new_cache_id = app.classes.calendar._daywise_cache_id(event.date,this._parent.options.owner);

View File

@ -649,7 +649,6 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.scrolling this.scrolling
.css('height', (this.div.innerHeight() - header_height)+'px')
.on('scroll', jQuery.proxy(this._scroll, this)); .on('scroll', jQuery.proxy(this._scroll, this));
// Percent // Percent
@ -684,7 +683,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this._top_time = 0 this._top_time = 0
for(var t = 0,i = 0; t < 1440; t += granularity,++i) for(var t = 0,i = 0; t < 1440; t += granularity,++i)
{ {
html += '<div class="calendar_calTimeRow" style="height: '+this.rowHeight+'px;">'; html += '<div class="calendar_calTimeRow" style="height: '+rowHeight+'%;">';
// show time for full hours, always for 45min interval and at least on every 3 row // show time for full hours, always for 45min interval and at least on every 3 row
var time = jQuery.datepicker.formatTime( var time = jQuery.datepicker.formatTime(
egw.preference("timeformat") === "12" ? "h:mmtt" : "HH:mm", egw.preference("timeformat") === "12" ? "h:mmtt" : "HH:mm",
@ -759,8 +758,6 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
var wd_end = 60*this.options.day_end; var wd_end = 60*this.options.day_end;
var totalDisplayMinutes = wd_end - wd_start; var totalDisplayMinutes = wd_end - wd_start;
var rowsToDisplay = Math.ceil((totalDisplayMinutes+60)/this.options.granularity); var rowsToDisplay = Math.ceil((totalDisplayMinutes+60)/this.options.granularity);
this.scrolling
.css('height', (this.options.height - this.gridHeader.outerHeight(true))+'px');
var new_height = this.scrolling.height() / rowsToDisplay; var new_height = this.scrolling.height() / rowsToDisplay;
this.rowHeight = new_height; this.rowHeight = new_height;
@ -773,7 +770,6 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
'100%' : '100%' :
(this.rowHeight*rows.length)+'px' (this.rowHeight*rows.length)+'px'
); );
$j('.calendar_calAddEvent',this.scrolling).height(this.rowHeight);
// Scroll to start of day // Scroll to start of day
this._top_time = (wd_start * this.rowHeight) / this.options.granularity; this._top_time = (wd_start * this.rowHeight) / this.options.granularity;
@ -1670,7 +1666,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
this.div.css('height', this.options.height); this.div.css('height', this.options.height);
// Re-do time grid // Re-do time grid
this._drawTimes(); if(!this.update_timer) this._drawTimes();
// Just re-did everything, no need to do more // Just re-did everything, no need to do more
return; return;

View File

@ -189,10 +189,14 @@ e.g. the div with class calendar_calTimeGrid is generated by the timeGridWidget
position: relative; position: relative;
bottom: 0px; bottom: 0px;
width: 100%; width: 100%;
height: 100%;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
cursor: default; cursor: default;
} }
.calendar_calTimeGrid .calendar_calTimeLabels {
height: 100%;
}
.calendar_calTimeGrid .loading,.calendar_plannerWidget .loading { .calendar_calTimeGrid .loading,.calendar_plannerWidget .loading {
top: 0px; top: 0px;