← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16610: DV GIS ER EV future periods.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 16610 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-09-02 13:10:54 +0200
message:
  DV GIS ER EV future periods.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2014-09-01 22:20:49 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2014-09-02 10:52:02 +0000
@@ -4319,10 +4319,11 @@
 			}
 		});
 
-        onPeriodTypeSelect = function(value) {
-            var periodType = value,
+        onPeriodTypeSelect = function() {
+            var type = periodType.getValue(),
+                periodOffset = periodType.periodOffset,
                 generator = ns.core.init.periodGenerator,
-                periods = generator.filterFuturePeriodsExceptCurrent(generator.generateReversedPeriods(periodType, this.periodOffset));
+                periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);
 
             for (var i = 0; i < periods.length; i++) {
                 periods[i].id = periods[i].iso;
@@ -4346,7 +4347,8 @@
             periodOffset: 0,
             listeners: {
                 select: function(cmp) {
-                    onPeriodTypeSelect(cmp.getValue());
+                    periodType.periodOffset = 0;
+                    onPeriodTypeSelect();
                 }
             }
         });
@@ -4358,7 +4360,7 @@
             handler: function() {
                 if (periodType.getValue()) {
                     periodType.periodOffset--;
-                    onPeriodTypeSelect(periodType.getValue());
+                    onPeriodTypeSelect();
                 }
             }
         });
@@ -4370,7 +4372,7 @@
             handler: function() {
                 if (periodType.getValue()) {
                     periodType.periodOffset++;
-                    onPeriodTypeSelect(periodType.getValue());
+                    onPeriodTypeSelect();
                 }
             }
         });

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js	2014-09-01 22:20:49 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-visualizer/scripts/app.js	2014-09-02 11:00:54 +0000
@@ -3954,14 +3954,15 @@
 			}
 		});
 
-        onPeriodTypeSelect = function(value) {
-            var ptype = new PeriodType(),
+        onPeriodTypeSelect = function() {
+            var type = periodType.getValue(),
+                periodOffset = periodType.periodOffset,
+                generator = ns.core.init.periodGenerator,
+                periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);
 
-                periods = ptype.get(value).generatePeriods({
-                    offset: periodType.periodOffset,
-                    filterFuturePeriods: true,
-                    reversePeriods: true
-                });
+            for (var i = 0; i < periods.length; i++) {
+                periods[i].id = periods[i].iso;
+            }
 
             fixedPeriodAvailableStore.setIndex(periods);
             fixedPeriodAvailableStore.loadData(periods);
@@ -3981,7 +3982,8 @@
             periodOffset: 0,
             listeners: {
                 select: function(cmp) {
-                    onPeriodTypeSelect(cmp.getValue());
+                    periodType.periodOffset = 0;
+                    onPeriodTypeSelect();
                 }
             }
         });
@@ -3993,7 +3995,7 @@
             handler: function() {
                 if (periodType.getValue()) {
                     periodType.periodOffset--;
-                    onPeriodTypeSelect(periodType.getValue());
+                    onPeriodTypeSelect();
                 }
             }
         });
@@ -4005,7 +4007,7 @@
             handler: function() {
                 if (periodType.getValue()) {
                     periodType.periodOffset++;
-                    onPeriodTypeSelect(periodType.getValue());
+                    onPeriodTypeSelect();
                 }
             }
         });

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2014-09-02 06:29:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-mapping/scripts/app.js	2014-09-02 10:43:33 +0000
@@ -6749,6 +6749,7 @@
 			dataElementDetailLevel,
 			dataElementPanel,
 			dataSet,
+            onPeriodTypeSelect,
 			periodType,
 			period,
 			periodPrev,
@@ -7270,6 +7271,33 @@
 			store: dataSetStore
 		});
 
+        onPeriodTypeSelect = function() {
+            var type = periodType.getValue(),
+                periodOffset = periodType.periodOffset,
+                generator = gis.init.periodGenerator,
+                periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);
+                
+            if (type === 'relativePeriods') {
+                periodsByTypeStore.loadData(gis.conf.period.relativePeriods);
+
+                periodPrev.disable();
+                periodNext.disable();
+            }
+            else {
+                for (var i = 0; i < periods.length; i++) {
+                    periods[i].id = periods[i].iso;
+                }
+
+                periodsByTypeStore.setIndex(periods);
+                periodsByTypeStore.loadData(periods);
+                
+                periodPrev.enable();
+                periodNext.enable();
+            }
+
+            period.selectFirst();
+        };            
+
 		periodType = Ext.create('Ext.form.field.ComboBox', {
 			cls: 'gis-combo',
 			editable: false,
@@ -7280,36 +7308,10 @@
 			width: 142,
 			store: gis.store.periodTypes,
 			periodOffset: 0,
-			selectHandler: function() {
-                var periodType = this.getValue(),
-                    generator = gis.init.periodGenerator,
-                    periods;
-
-				if (periodType === 'relativePeriods') {
-					periodsByTypeStore.loadData(gis.conf.period.relativePeriods);
-
-					periodPrev.disable();
-					periodNext.disable();
-				}
-				else {
-                    periods = generator.filterFuturePeriodsExceptCurrent(generator.generateReversedPeriods(periodType, this.periodOffset));
-
-                    for (var i = 0; i < periods.length; i++) {
-                        periods[i].id = periods[i].iso;
-                    }
-
-					periodsByTypeStore.setIndex(periods);
-					periodsByTypeStore.loadData(periods);
-
-					periodPrev.enable();
-					periodNext.enable();
-				}
-
-				period.selectFirst();
-			},
 			listeners: {
 				select: function() {
-					this.selectHandler();
+                    periodType.periodOffset = 0;
+                    onPeriodTypeSelect();
 				}
 			}
 		});
@@ -7337,10 +7339,10 @@
             height: 24,
 			style: 'margin-left: 1px',
 			handler: function() {
-				if (periodType.getValue()) {
-					periodType.periodOffset--;
-					periodType.fireEvent('select');
-				}
+                if (periodType.getValue()) {
+                    periodType.periodOffset--;
+                    onPeriodTypeSelect();
+                }
 			}
 		});
 
@@ -7352,11 +7354,11 @@
 			style: 'margin-left: 1px',
 			scope: this,
 			handler: function() {
-				if (periodType.getValue() && periodType.periodOffset < 0) {
-					periodType.periodOffset++;
-					periodType.fireEvent('select');
-				}
-			}
+                if (periodType.getValue()) {
+                    periodType.periodOffset++;
+                    onPeriodTypeSelect();
+                }
+            }
 		});
 
 		periodTypePanel = Ext.create('Ext.panel.Panel', {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js	2014-09-02 06:29:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-pivot/scripts/app.js	2014-09-02 10:52:02 +0000
@@ -4203,7 +4203,7 @@
             var type = periodType.getValue(),
                 periodOffset = periodType.periodOffset,
                 generator = ns.core.init.periodGenerator,
-                periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);           
+                periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);
 
             for (var i = 0; i < periods.length; i++) {
                 periods[i].id = periods[i].iso;
@@ -4212,7 +4212,7 @@
             fixedPeriodAvailableStore.setIndex(periods);
             fixedPeriodAvailableStore.loadData(periods);
             ns.core.web.multiSelect.filterAvailable(fixedPeriodAvailable, fixedPeriodSelected);
-        };            
+        };
 
         periodType = Ext.create('Ext.form.field.ComboBox', {
             cls: 'ns-combo',

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js	2014-09-01 19:20:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-visualizer/scripts/app.js	2014-09-02 10:12:35 +0000
@@ -2370,6 +2370,8 @@
             relativePeriod,
             fixedPeriodAvailable,
             fixedPeriodSelected,
+            onPeriodTypeSelect,
+            periodType,
             period,
             treePanel,
             userOrganisationUnit,
@@ -4170,6 +4172,40 @@
 			}
 		});
 
+        onPeriodTypeSelect = function() {
+            var type = periodType.getValue(),
+                periodOffset = periodType.periodOffset,
+                generator = ns.core.init.periodGenerator,
+                periods = generator.generateReversedPeriods(type, type === 'Yearly' ? periodOffset - 5 : periodOffset);           
+
+            for (var i = 0; i < periods.length; i++) {
+                periods[i].id = periods[i].iso;
+            }
+
+            fixedPeriodAvailableStore.setIndex(periods);
+            fixedPeriodAvailableStore.loadData(periods);
+            ns.core.web.multiSelect.filterAvailable(fixedPeriodAvailable, fixedPeriodSelected);
+        };            
+
+        periodType = Ext.create('Ext.form.field.ComboBox', {
+            cls: 'ns-combo',
+            style: 'margin-bottom:1px',
+            width: ns.core.conf.layout.west_fieldset_width - ns.core.conf.layout.west_width_padding - 62 - 62 - 2,
+            valueField: 'id',
+            displayField: 'name',
+            emptyText: NS.i18n.select_period_type,
+            editable: false,
+            queryMode: 'remote',
+            store: periodTypeStore,
+            periodOffset: 0,
+            listeners: {
+                select: function() {
+                    periodType.periodOffset = 0;
+                    onPeriodTypeSelect();
+                }
+            }
+        });
+
 		period = {
 			xtype: 'panel',
 			title: '<div class="ns-panel-title-period">Periods</div>',
@@ -4231,44 +4267,16 @@
 					bodyStyle: 'border-style:none',
 					style: 'margin-top:0px',
 					items: [
-						{
-							xtype: 'combobox',
-							cls: 'ns-combo',
-							style: 'margin-bottom:1px',
-							width: ns.core.conf.layout.west_fieldset_width - ns.core.conf.layout.west_width_padding - 62 - 62 - 2,
-							valueField: 'id',
-							displayField: 'name',
-							emptyText: NS.i18n.select_period_type,
-							editable: false,
-							queryMode: 'remote',
-							store: periodTypeStore,
-							periodOffset: 0,
-							listeners: {
-								select: function() {
-                                    var periodType = this.getValue(),
-                                        generator = ns.core.init.periodGenerator,
-                                        periods = generator.filterFuturePeriodsExceptCurrent(generator.generateReversedPeriods(periodType, this.periodOffset));
-
-                                    for (var i = 0; i < periods.length; i++) {
-                                        periods[i].id = periods[i].iso;
-                                    }
-
-									fixedPeriodAvailableStore.setIndex(periods);
-									fixedPeriodAvailableStore.loadData(periods);
-									ns.core.web.multiSelect.filterAvailable(fixedPeriodAvailable, fixedPeriodSelected);
-								}
-							}
-						},
+                        periodType,
 						{
 							xtype: 'button',
 							text: NS.i18n.prev_year,
 							style: 'margin-left:1px; border-radius:2px',
 							height: 24,
 							handler: function() {
-								var cb = this.up('panel').down('combobox');
-								if (cb.getValue()) {
-									cb.periodOffset--;
-									cb.fireEvent('select');
+								if (periodType.getValue()) {
+									periodType.periodOffset--;
+                                    onPeriodTypeSelect();
 								}
 							}
 						},
@@ -4278,10 +4286,9 @@
 							style: 'margin-left:1px; border-radius:2px',
 							height: 24,
 							handler: function() {
-								var cb = this.up('panel').down('combobox');
-								if (cb.getValue() && cb.periodOffset < 0) {
-									cb.periodOffset++;
-									cb.fireEvent('select');
+								if (periodType.getValue()) {
+									periodType.periodOffset++;
+                                    onPeriodTypeSelect();
 								}
 							}
 						}
@@ -4290,7 +4297,7 @@
 				{
 					xtype: 'panel',
 					layout: 'column',
-					bodyStyle: 'border-style:none; padding-bottom:1px',
+					bodyStyle: 'border-style:none; padding-bottom:2px',
 					items: [
 						fixedPeriodAvailable,
 						fixedPeriodSelected