Do not create recurring events that are longer than the interval
authorsstamer <s.stamer@metaways.de>
Wed, 4 Feb 2015 14:37:14 +0000 (15:37 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 5 Feb 2015 13:11:08 +0000 (14:11 +0100)
Change-Id: I9b964a9f46e51788ee1cab091559ee712b044362
Reviewed-on: http://gerrit.tine20.com/customers/1608
Tested-by: sstamer <s.stamer@metaways.de>
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/js/EventEditDialog.js
tine20/Calendar/js/RrulePanel.js

index 1dde516..88f2300 100644 (file)
@@ -345,7 +345,9 @@ Tine.Calendar.EventEditDialog = Ext.extend(Tine.widgets.dialog.EditDialog, {
         
         this.on('render', function() {this.getForm().add(organizerCombo);}, this);
         
         
         this.on('render', function() {this.getForm().add(organizerCombo);}, this);
         
-        this.rrulePanel = new Tine.Calendar.RrulePanel({});
+        this.rrulePanel = new Tine.Calendar.RrulePanel({
+            eventEditDialog : this
+        });
         this.alarmPanel = new Tine.widgets.dialog.AlarmPanel({});
         this.attendeeStore = this.attendeeGridPanel.getStore();
         
         this.alarmPanel = new Tine.widgets.dialog.AlarmPanel({});
         this.attendeeStore = this.attendeeGridPanel.getStore();
         
index a779588..5fa44d5 100644 (file)
@@ -3,7 +3,7 @@
  * 
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
  * @author      Cornelius Weiss <c.weiss@metaways.de>
  * 
  * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
  * @author      Cornelius Weiss <c.weiss@metaways.de>
- * @copyright   Copyright (c) 2007-2008 Metaways Infosystems GmbH (http://www.metaways.de)
+ * @copyright   Copyright (c) 2007-2015 Metaways Infosystems GmbH (http://www.metaways.de)
  */
 
 Ext.ns('Tine.Calendar');
  */
 
 Ext.ns('Tine.Calendar');
@@ -19,6 +19,12 @@ Tine.Calendar.RrulePanel = Ext.extend(Ext.Panel, {
      */    
     activeRuleCard: null,
     
      */    
     activeRuleCard: null,
     
+    /**
+     * the event edit dialog (parent)
+     * @type Tine.Calendar.EventEditDialog
+     */
+    eventEditDialog: null,
+    
     layout: 'form',
     frame: true,
     
     layout: 'form',
     frame: true,
     
@@ -68,7 +74,6 @@ Tine.Calendar.RrulePanel = Ext.extend(Ext.Panel, {
             id: this.idPrefix + 'tglbtn' + 'NONE',
             xtype: 'tbbtnlockedtoggle',
             enableToggle: true,
             id: this.idPrefix + 'tglbtn' + 'NONE',
             xtype: 'tbbtnlockedtoggle',
             enableToggle: true,
-            //pressed: true,
             text: this.app.i18n._('None'),
             handler: this.onFreqChange.createDelegate(this, ['NONE']),
             toggleGroup: this.idPrefix + 'freqtglgroup'
             text: this.app.i18n._('None'),
             handler: this.onFreqChange.createDelegate(this, ['NONE']),
             toggleGroup: this.idPrefix + 'freqtglgroup'
@@ -374,12 +379,33 @@ Tine.Calendar.RrulePanel.AbstractCard = Ext.extend(Ext.Panel, {
     },
     
     isValid: function(record) {
     },
     
     isValid: function(record) {
-        var until = this.until.getValue();
+        var until = this.until.getValue(),
+            freq = this.freq;
+        
         if (Ext.isDate(until) && Ext.isDate(record.get('dtstart'))) {
             if (until.getTime() < record.get('dtstart').getTime()) {
                 this.until.markInvalid(this.app.i18n._('Until has to be after event start'));
                 return false;
             }
         if (Ext.isDate(until) && Ext.isDate(record.get('dtstart'))) {
             if (until.getTime() < record.get('dtstart').getTime()) {
                 this.until.markInvalid(this.app.i18n._('Until has to be after event start'));
                 return false;
             }
+        } 
+        
+        if (Ext.isDate(record.get('dtend')) && Ext.isDate(record.get('dtstart'))) {
+            var dayDifference = (record.get('dtend').getTime() - record.get('dtstart').getTime()) / 1000 / 60 / 60 / 24,
+                dtendField = this.rrulePanel.eventEditDialog.getForm().findField('dtend');
+            
+            if(freq == 'DAILY' && dayDifference >= 1) {
+                dtendField.markInvalid(this.app.i18n._('The event is longer than the recurring interval'));
+                return false;
+            } else if(freq == 'WEEKLY' && dayDifference >= 7) {
+                dtendField.markInvalid(this.app.i18n._('The event is longer than the recurring interval'));
+                return false;
+            } else if(freq == 'MONTHLY' && dayDifference >= 28) {
+                dtendField.markInvalid(this.app.i18n._('The event is longer than the recurring interval'));
+                return false;
+            } else if(freq == 'YEARLY' && dayDifference >= 365) {
+                dtendField.markInvalid(this.app.i18n._('The event is longer than the recurring interval'));
+                return false;
+            }
         }
         
         return true;
         }
         
         return true;