0012348: daysView calendar refresh removed currently editing event
authorCornelius Weiß <c.weiss@metaways.de>
Wed, 23 Nov 2016 12:56:45 +0000 (13:56 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 25 Nov 2016 09:53:07 +0000 (10:53 +0100)
- skip refresh when editing

Change-Id: Iecb5ccb5d034e94c68cb6e864e921f7ab48371ae
Reviewed-on: http://gerrit.tine20.com/customers/3864
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/js/CalendarPanelSplitPlugin.js
tine20/Calendar/js/DaysView.js
tine20/Calendar/js/MainScreenCenterPanel.js
tine20/Calendar/js/MonthView.js
tine20/Calendar/js/YearView.js

index 9203b79..43f828e 100644 (file)
@@ -111,9 +111,12 @@ Tine.Calendar.CalendarPanelSplitPlugin.prototype = {
     },
     
     onMainStoreBeforeLoad: function(store, options) {
+        var ret = true;
         this.attendeeViews.each(function(attendeeView) {
-            attendeeView.store.fireEvent('beforeload', store, options);
+            ret = ret && attendeeView.store.fireEvent('beforeload', store, options);
         }, this);
+
+        return ret;
     },
     
     onMainStoreLoad: function(store, options) {
index ea403fb..314c9c9 100644 (file)
@@ -157,18 +157,13 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
      * @type Number
      */
     scrollBuffer: 200,
-    
     /**
-     * @property {bool} editing
+     * record currently being edited or false
+     * @property {Record} editing
      * @private
      */
     editing: false,
     /**
-     * currently active event
-     * $type {Tine.Calendar.Model.Event}
-     */
-    activeEvent: null,
-    /**
      * @property {Ext.data.Store}
      * @private
      */
@@ -661,10 +656,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
      * @param {Tine.Calendar.Model.Event} event
      */
     removeEvent: function(event) {
-        if (event == this.activeEvent) {
-            this.activeEvent = null;
-        }
-
         if(this.editing) {
             this.abortCreateEvent(event);
         }
@@ -675,25 +666,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
     },
     
     /**
-     * sets currentlcy active event
-     * 
-     * NOTE: active != selected
-     * @param {Tine.Calendar.Model.Event} event
-     */
-    setActiveEvent: function(event) {
-        this.activeEvent = event || null;
-    },
-    
-    /**
-     * gets currentlcy active event
-     * 
-     * @return {Tine.Calendar.Model.Event} event
-     */
-    getActiveEvent: function() {
-        return this.activeEvent;
-    },
-    
-    /**
      * returns the selectionModel of the active panel
      * @return {}
      */
@@ -721,7 +693,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         var registry = event.get('is_all_day_event') ? this.parallelWholeDayEventsRegistry : this.parallelScrollerEventsRegistry;
         registry.register(event);
         this.insertEvent(event);
-        //this.setActiveEvent(event);
         this.onLayout();
         
         //var eventEls = event.ui.getEls();
@@ -1111,7 +1082,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
             this.insertEvent(parallelEvents[j]);
         }
         
-        this.setActiveEvent(this.getActiveEvent());
         this.onLayout();
     },
 
@@ -1132,8 +1102,6 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
                 this.removeEvent(parallelEvents[j]);
                 this.insertEvent(parallelEvents[j]);
             }
-            
-            //this.setActiveEvent(event);
         }
         
         this.onLayout();
@@ -1158,6 +1126,10 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
     },
     
     onBeforeLoad: function(store, options) {
+        if (options.autoRefresh && this.editing) {
+            Tine.log.debug('Tine.Calendar.DaysView::onBeforeLoad skipping autorefresh as editing is in progress');
+            return false;
+        }
         if (! options.refresh) {
             this.store.each(this.removeEvent, this);
             this.transitionEvents = [];
index 4f54ec2..b01fa6d 100644 (file)
@@ -1616,6 +1616,12 @@ Tine.Calendar.MainScreenCenterPanel = Ext.extend(Ext.Panel, {
             refresh: !!options
         };
         Tine.log.debug('Tine.Calendar.MainScreenCenterPanel::refresh(' + options.refresh + ')');
+
+        // reset autoRefresh it might get lost if request fails
+        if (window.isMainWindow && this.autoRefreshInterval) {
+            this.autoRefreshTask.delay(this.autoRefreshInterval * 2000);
+        }
+
         var panel = this.getCalendarPanel(this.activeView);
         panel.getStore().load(options);
         
@@ -1785,6 +1791,11 @@ Tine.Calendar.MainScreenCenterPanel = Ext.extend(Ext.Panel, {
             this.calendarPanels[which].on('keydown', this.onKeyDown, this);
             
             this.calendarPanels[which].relayEvents(this, ['show', 'beforehide']);
+
+            // rebind store so it's event listeners get called at last.
+            // -> otherwise loading spinner would be active event if the view beforeload cancels the request
+            tbar.unbind(store);
+            tbar.bind(store);
         }
         
         return this.calendarPanels[which];
index 16f4fe2..cff4dad 100644 (file)
@@ -114,11 +114,6 @@ Ext.extend(Tine.Calendar.MonthView, Ext.Container, {
      */
     denyDragOnMissingEditGrant: true,
     /**
-     * @property {Tine.Calendar.Model.Event} activeEvent
-     * @private
-     */
-    activeEvent: null,
-    /**
      * @private {Date} toDay
      */
     toDay: null,
@@ -183,16 +178,7 @@ Ext.extend(Tine.Calendar.MonthView, Ext.Container, {
         
         this.dateMesh = mesh;
     },
-    
-    /**
-     * gets currentlcy active event
-     * 
-     * @return {Tine.Calendar.Model.Event} event
-     */
-    getActiveEvent: function() {
-        return this.activeEvent;
-    },
-    
+
     /**
      * returns index of dateCell given date is in
      * @param {Date} date
@@ -644,8 +630,6 @@ Ext.extend(Tine.Calendar.MonthView, Ext.Container, {
                 this.removeEvent(parallelEvents[j]);
                 this.insertEvent(parallelEvents[j]);
             }
-            
-            this.setActiveEvent(event);
         }
         
         this.layoutDayCells();
@@ -826,7 +810,6 @@ Ext.extend(Tine.Calendar.MonthView, Ext.Container, {
         }
         
         event.commit(true);
-        this.setActiveEvent(this.getActiveEvent());
         this.layoutDayCells();
     },
     
@@ -864,10 +847,6 @@ Ext.extend(Tine.Calendar.MonthView, Ext.Container, {
             return;
         }
         
-        if (event == this.activeEvent) {
-            this.activeEvent = null;
-        }
-        
         if (event.ui) {
             event.ui.remove();
         }
@@ -911,56 +890,6 @@ Ext.extend(Tine.Calendar.MonthView, Ext.Container, {
         this.el.update(m.join(""));
     },
     
-    /**
-     * sets currentlcy active event
-     * 
-     * @param {Tine.Calendar.Model.Event} event
-     *
-    setActiveEvent: function(event) {
-        if (this.activeEvent) {
-            var curEls = this.getEventEls(this.activeEvent);
-            for (var i=0; i<curEls.length; i++) {
-                curEls[i].removeClass('cal-monthview-active');
-                if (this.activeEvent.is_all_day_event) {
-                    curEls[i].setStyle({'background-color': this.activeEvent.bgColor});
-                    curEls[i].setStyle({'color': '#000000'});
-                } else {
-                    curEls[i].setStyle({'background-color': ''});
-                    curEls[i].setStyle({'color': event.color});
-                }
-            }
-        }
-        
-        
-        
-        var els = this.getEventEls(event);
-        if (event && els && els.length > 0) {
-            var els = this.getEventEls(event);
-            for (var i=0; i<els.length; i++) {
-                els[i].addClass('cal-monthview-active');
-                if (event.is_all_day_event) {
-                    els[i].setStyle({'background-color': event.color});
-                    els[i].setStyle({'color': '#FFFFFF'});
-                } else {
-                    els[i].setStyle({'background-color': event.color});
-                    els[i].setStyle({'color': '#FFFFFF'});
-                }
-            }
-            this.activeEvent = event;
-        }
-    },
-    */
-    
-    /**
-     * sets currentlcy active event
-     * 
-     * NOTE: active != selected
-     * @param {Tine.Calendar.Model.Event} event
-     */
-    setActiveEvent: function(event) {
-        this.activeEvent = event || null;
-    },
-    
     updatePeriod: function(period) {
         this.toDay = new Date().clearTime();
         this.startDate = period.from;
index 283dd81..d7cf37b 100644 (file)
@@ -99,11 +99,6 @@ Ext.extend(Tine.Calendar.YearView, Ext.Container, {
      */
     denyDragOnMissingEditGrant: true,
     /**
-     * @property {Tine.Calendar.Model.Event} activeEvent
-     * @private
-     */
-    activeEvent: null,
-    /**
      * @private {Date} toDay
      */
     toDay: null,
@@ -165,16 +160,7 @@ Ext.extend(Tine.Calendar.YearView, Ext.Container, {
         }
         this.dateMesh = mesh;
     },
-    
-    /**
-     * gets currentlcy active event
-     * 
-     * @return {Tine.Calendar.Model.Event} event
-     */
-    getActiveEvent: function() {
-        return this.activeEvent;
-    },
-    
+
     /**
      * returns index of dateCell given date is in
      * @param {Date} date
@@ -589,8 +575,6 @@ Ext.extend(Tine.Calendar.YearView, Ext.Container, {
                 this.removeEvent(parallelEvents[j]);
                 this.insertEvent(parallelEvents[j]);
             }
-            
-            this.setActiveEvent(event);
         }
         
         this.layoutDayCells();
@@ -737,7 +721,6 @@ Ext.extend(Tine.Calendar.YearView, Ext.Container, {
         }
         
         event.commit(true);
-        this.setActiveEvent(this.getActiveEvent());
         this.layoutDayCells();
     },
     
@@ -775,10 +758,6 @@ Ext.extend(Tine.Calendar.YearView, Ext.Container, {
             return;
         }
         
-        if (event == this.activeEvent) {
-            this.activeEvent = null;
-        }
-        
         if (event.ui) {
             event.ui.remove();
         }
@@ -817,17 +796,7 @@ Ext.extend(Tine.Calendar.YearView, Ext.Container, {
                 
         this.el.update(m.join(""));
     },
-       
-    /**
-     * sets currentlcy active event
-     * 
-     * NOTE: active != selected
-     * @param {Tine.Calendar.Model.Event} event
-     */
-    setActiveEvent: function(event) {
-        this.activeEvent = event || null;
-    },
-    
+
     updatePeriod: function(period) {
         this.toDay = new Date().clearTime();
         this.startDate = period.from;