fix change event on reset
authorCornelius Weiß <c.weiss@metaways.de>
Sat, 15 Jul 2017 21:15:56 +0000 (23:15 +0200)
committerCornelius Weiss <c.weiss@metaways.de>
Mon, 17 Jul 2017 14:05:26 +0000 (16:05 +0200)
Change-Id: Icc6bab9bb85bfd7b84dff1986043db1325cd08b4
Reviewed-on: http://gerrit.tine20.com/customers/5214
Reviewed-by: Cornelius Weiss <c.weiss@metaways.de>
Tested-by: Cornelius Weiss <c.weiss@metaways.de>
tine20/Tinebase/js/ux/form/PeriodPicker.js
tine20/Tinebase/js/widgets/form/RecordsPickerCombo.js

index 065cb01..c857f20 100644 (file)
@@ -65,6 +65,7 @@ Ext.ux.form.PeriodPicker = Ext.extend(Ext.form.Field, {
 
         this.value = Ext.ux.form.PeriodPicker.getPeriod(this.value ? this.value.from : this.startDate || new Date(), this.range);
         this.startDate = this.value.from;
+        this.startValue = this.value;
     },
 
     /**
@@ -104,6 +105,15 @@ Ext.ux.form.PeriodPicker = Ext.extend(Ext.form.Field, {
         }
         this.setPeriodText(dateString);
 
+        if (JSON.stringify(this.value) != JSON.stringify(this.startValue)){
+            this.fireEvent('change', this, this.value, this.startValue);
+        }
+    },
+
+    reset : function() {
+        this.originalValue = this.startValue;
+
+        Ext.ux.form.PeriodPicker.superclass.reset.apply(this, arguments);
     },
 
     setStartDate: function(startDate) {
@@ -118,7 +128,6 @@ Ext.ux.form.PeriodPicker = Ext.extend(Ext.form.Field, {
     // private
     onRangeComboChange: function() {
         this.setValue(Ext.ux.form.PeriodPicker.getPeriod(this.startDate, this.getRangeCombo().getValue()));
-        this.fireEvent('change', this, this.value, this.startValue);
     },
 
     // private
@@ -129,10 +138,8 @@ Ext.ux.form.PeriodPicker = Ext.extend(Ext.form.Field, {
 
         if (next) {
             this.setStartDate(this.value.until.add(Date.DAY, 1));
-            this.fireEvent('change', this, this.value, this.startValue);
         } else if (prev) {
             this.setStartDate(this.value.from.add(Date.DAY, -1));
-            this.fireEvent('change', this, this.value, this.startValue);
         } else if (period) {
             this.getDatePickerMenu().show(period);
         }
@@ -176,7 +183,6 @@ Ext.ux.form.PeriodPicker = Ext.extend(Ext.form.Field, {
                 // value: this.range,
                 listeners: {
                     scope: this,
-                    change: this.onRangeComboChange,
                     select: this.onRangeComboChange
                 }
             });
@@ -205,7 +211,6 @@ Ext.ux.form.PeriodPicker = Ext.extend(Ext.form.Field, {
                             me.range = 'month';
                             me.setStartDate(this.activeDate);
                             this.destroy();
-                            me.fireEvent('change', me, me.value, me.startValue);
                             return false;
                         }
                     }
@@ -216,7 +221,6 @@ Ext.ux.form.PeriodPicker = Ext.extend(Ext.form.Field, {
                         this.getRangeCombo().setValue(weekNumber ? 'week' : 'day');
                         this.range = weekNumber ? 'week' : 'day';
                         this.setStartDate(value);
-                        this.fireEvent('change', this, this.value, this.startValue);
                     }
                 }
             });
index 13b855d..efa7db5 100644 (file)
@@ -94,6 +94,12 @@ Tine.Tinebase.widgets.form.RecordsPickerCombo = Ext.extend(Ext.ux.form.LayerComb
         return this;
     },
 
+    reset : function() {
+        this.currentValue = this.originalValue;
+
+        Tine.Tinebase.widgets.form.RecordsPickerCombo.superclass.reset.apply(this, arguments);
+    },
+
     afterRender: function () {
 
         Tine.Tinebase.widgets.form.RecordsPickerCombo.superclass.afterRender.apply(this, arguments);