From 2d18c663b6ae7a79e00e489fd4e6e6ab9c5df81e Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 10 Nov 2015 21:24:06 +0000 Subject: [PATCH] Update daywise caches when an event changes days --- calendar/js/et2_widget_event.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 3d12a6146b..1b67a923ee 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -125,20 +125,27 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM], if(this._parent && this._parent.instanceOf(et2_calendar_daycol) && this.options.value.date && event.date != this.options.value.date) { - // Date changed, reparent - var new_parent = this._parent._parent.getWidgetById(event.date); - if(new_parent) + // Delete all old actions + this._actionObject.clear(); + this._actionObject.unregisterActions(); + this._actionObject = null; + + // Update daywise caches + var new_cache_id = app.classes.calendar._daywise_cache_id(event.date,this.options.owner); + var old_cache_id = app.classes.calendar._daywise_cache_id(this.options.value.date,this.options.owner); + var new_daywise = egw.dataGetUIDdata(new_cache_id); + var old_daywise = egw.dataGetUIDdata(old_cache_id); + new_daywise = new_daywise ? new_daywise.data : []; + old_daywise = old_daywise ? old_daywise.data : []; + if (new_daywise.indexOf(event.id) < 0) { - new_parent.addChild(this); - } - else - { - // Could not find the right date - this._parent.removeChild(this); - this.destroy(); - return; + new_daywise.push(event.id); } + old_daywise.splice(old_daywise.indexOf(this.options.value.id),1); + egw.dataStoreUID(old_cache_id,old_daywise); + egw.dataStoreUID(new_cache_id,new_daywise); } + // Copy to avoid changes, which may cause nm problems this.options.value = jQuery.extend({},event);