[IMP] Web, web_calendar: push_state rendering logic

When a new state is rendered, it is now first appended to a
documentFragment, and then appended to the DOM when ready. Doing so,
there is no more a intermediate step where two widgets are in the DOM,
the new one being appended below.

This required a web_calendar fix:
Not exactly fixed per-se, apparently when fullcalendar is rendered
hidden/out of document it doesn't generate correct range dates, and
calls the events callback with invalid dates. The code would blindly
take those invalid date, get bits out of them (NaN), generate a
timestamp full of NaNs and blindly search() the table with that.

Just skip the events callback entirely if the start or end date of the
current period is invalid (~isNaN(date.valueOf())).
This commit is contained in:
Xavier Morel
2015-03-20 16:34:42 +01:00
committed by Aaron Bohy
parent 258673fb31
commit 4b0a8d4096
2 changed files with 13 additions and 2 deletions
+7 -2
View File
@@ -203,8 +203,13 @@ var ActionManager = Widget.extend({
this.inner_action = new_action;
this.inner_widget = widget;
// Append the inner_widget and hide the old one
return $.when(this.inner_widget.appendTo(this.$el)).done(function () {
// render the inner_widget in a fragment, and append it to the
// document only when it's ready
var new_widget_fragment = document.createDocumentFragment();
return $.when(this.inner_widget.appendTo(new_widget_fragment)).done(function() {
self.$el.append(new_widget_fragment);
// Hide the old_widget as it will be removed from the DOM when it
// is destroyed
if (old_widget) {
old_widget.$el.hide();
}
@@ -688,6 +688,12 @@ var CalendarView = View.extend({
}
this.event_source = {
events: function(start, end, callback) {
// catch invalid dates (start/end dates not parseable yet)
// => ignore request
if (isNaN(start) || isNaN(end)) {
return;
}
var current_event_source = self.event_source;
self.dataset.read_slice(_.keys(self.fields), {
offset: 0,