← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4428: Layer window update button behaviour improved.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 4428 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-08-24 17:11:09 +0200
message:
  Layer window update button behaviour improved.
modified:
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.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-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-08-21 15:48:07 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js	2011-08-24 14:59:28 +0000
@@ -2240,8 +2240,9 @@
         width: 570,
         height: 478,
         collapsed: false,
+        isUpdate: false,
+        cmp: {},
         items: choropleth,
-        cmp: {},
         bbar: [
             {
                 xtype: 'button',
@@ -2271,7 +2272,7 @@
                     var node = this.cmp.parent.selectedNode;
                     this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level,
                         this.cmp.level.getValue(), this.cmp.level.getRawValue());
-                    
+                    this.window.isUpdate = true;                    
                     this.loadGeoJson();
                 },
                 listeners: {
@@ -2337,8 +2338,10 @@
         closeAction: 'hide',
         width: 570,
         height: 478,
+        collapsed: false,
+        isUpdate: false,
+        cmp: {},
         items: point,
-        cmp: {},
         bbar: [
             {
                 xtype: 'button',
@@ -2368,7 +2371,7 @@
                     var node = this.cmp.parent.selectedNode;
                     this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level,
                         this.cmp.level.getValue(), this.cmp.level.getRawValue());
-                    
+                    this.window.isUpdate = true;
                     this.loadGeoJson();
                 },
                 listeners: {
@@ -2398,7 +2401,16 @@
                     }
                 }
             }
-        ]
+        ],
+        listeners: {
+            'show': {
+                scope: point,
+                fn: function() {
+                    this.cmp.parent.isLoaded = true;
+                    this.window.isShown = true;
+                }
+            }
+        }
     });    
     point.window.setPagePosition(G.conf.window_x_left,G.conf.window_y_left);
     
@@ -2425,8 +2437,9 @@
         closeAction: 'hide',
         width: 570,
         height: 478,
+        isUpdate: false,
+        cmp: {},
         items: symbol,
-        cmp: {},
         bbar: [
             {
                 xtype: 'button',
@@ -2456,7 +2469,7 @@
                     var node = this.cmp.parent.selectedNode;
                     this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level,
                         this.cmp.level.getValue(), this.cmp.level.getRawValue());
-                    
+                    this.window.isUpdate = true;
                     this.loadGeoJson();
                 },
                 listeners: {
@@ -2513,8 +2526,9 @@
         closeAction: 'hide',
         width: 570,
         height: 478,
+        isUpdate: false,
+        cmp: {},
         items: centroid,
-        cmp: {},
         bbar: [
             {
                 xtype: 'button',
@@ -2544,6 +2558,7 @@
                     var node = this.cmp.parent.selectedNode;
                     this.organisationUnitSelection.setValues(node.attributes.id, node.attributes.text, node.attributes.level,
                         this.cmp.level.getValue(), this.cmp.level.getRawValue());
+                    this.window.isUpdate = true;
                     
                     this.loadGeoJson();
                 },

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2011-08-20 22:11:25 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/core/GeoStat.js	2011-08-24 11:16:18 +0000
@@ -95,9 +95,6 @@
 		this.layer.features = G.util.getTransformedFeatureArray(this.layer.features);
         this.requestSuccess(request);
         
-        if (!G.vars.activeWidget.formValidation.validateForm.call(G.vars.activeWidget)) {
-                G.vars.mask.hide();
-            }
         G.vars.activeWidget.classify();
     },
 

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js	2011-08-23 10:53:11 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Centroid.js	2011-08-24 14:59:28 +0000
@@ -86,6 +86,8 @@
     
     cmp: {},
     
+    requireUpdate: false,
+    
     initComponent: function() {
     
         this.initProperties();
@@ -578,7 +580,9 @@
                 'select': {
                     scope: this,
                     fn: function() {
-                        this.formValidation.validateForm.call(this);                        
+                        this.requireUpdate = true;
+                        this.formValidation.validateForm.call(this);    
+                                            
                         this.window.cmp.reset.enable();
                     }
                 }
@@ -602,22 +606,22 @@
                 expanded: true
             },
             widget: this,
-            isSelected: false,
+            isLoaded: false,
             reset: function() {
                 if (this.getSelectionModel().getSelectedNode()) {
                     this.getSelectionModel().getSelectedNode().unselect();
                 }                
                 this.collapseAll();
                 this.getRootNode().expand();
-                this.isSelected = false;
                 this.widget.window.cmp.apply.disable();
             },
             listeners: {
                 'click': {
                     scope: this,
                     fn: function(n) {
-                        this.cmp.parent.selectedNode = n;
-                        this.cmp.parent.isSelected = true;
+                        var tree = n.getOwnerTree();
+                        tree.selectedNode = n;
+                        this.requireUpdate = true;
                         this.formValidation.validateForm.call(this);
                         
                         this.window.cmp.reset.enable();
@@ -969,8 +973,15 @@
                 return false;
             }
             
-            if (this.cmp.parent.isSelected) {
-                this.window.cmp.apply.enable();
+            if (this.requireUpdate) {
+                if (this.window.isUpdate) {
+                    this.window.cmp.apply.disable();
+                    this.requireUpdate = false;
+                    this.window.isUpdate = false;
+                }
+                else {
+                    this.window.cmp.apply.enable();
+                }
             }
             
             return true;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-08-23 10:53:11 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-08-24 11:16:18 +0000
@@ -86,6 +86,8 @@
     
     cmp: {},
     
+    requireUpdate: false,
+    
     initComponent: function() {
     
         this.initProperties();
@@ -823,6 +825,7 @@
                 'select': {
                     scope: this,
                     fn: function() {
+                        this.requireUpdate = true;
                         this.formValidation.validateForm.call(this);
                         
                         this.window.cmp.reset.enable();
@@ -849,22 +852,21 @@
             },
             widget: this,
             isLoaded: false,
-            isSelected: false,
             reset: function() {
                 if (this.getSelectionModel().getSelectedNode()) {
                     this.getSelectionModel().getSelectedNode().unselect();
                 }                
                 this.collapseAll();
                 this.getRootNode().expand();
-                this.isSelected = false;
                 this.widget.window.cmp.apply.disable();
             },
             listeners: {
                 'click': {
                     scope: this,
                     fn: function(n) {
-                        this.cmp.parent.selectedNode = n;
-                        this.cmp.parent.isSelected = true;
+                        var tree = n.getOwnerTree();
+                        tree.selectedNode = n;
+                        this.requireUpdate = true;
                         this.formValidation.validateForm.call(this);
                         
                         this.window.cmp.reset.enable();
@@ -1386,7 +1388,7 @@
         this.organisationUnitSelection.setValues(this.mapView.parentOrganisationUnitId, this.mapView.parentOrganisationUnitName,
             this.mapView.parentOrganisationUnitLevel, this.mapView.organisationUnitLevel, this.mapView.organisationUnitLevelName);
             
-        //this.cmp.parent.reset();
+        this.cmp.parent.reset();
         
         this.cmp.parent.selectedNode = {attributes: {
             id: this.mapView.parentOrganisationUnitId,
@@ -1439,7 +1441,7 @@
 	},
     
     formValidation: {
-        validateForm: function(exception) {
+        validateForm: function() {
             if (this.cmp.mapValueType.getValue() == G.conf.map_value_type_indicator) {
                 if (!this.cmp.indicator.getValue()) {
                     if (exception) {
@@ -1523,8 +1525,15 @@
                 return false;
             }
             
-            if (this.cmp.parent.isSelected) {
-                this.window.cmp.apply.enable();
+            if (this.requireUpdate) {
+                if (this.window.isUpdate) {
+                    this.window.cmp.apply.disable();
+                    this.requireUpdate = false;
+                    this.window.isUpdate = false;
+                }
+                else {
+                    this.window.cmp.apply.enable();
+                }
             }
             
             return true;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-08-23 10:53:11 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Point.js	2011-08-24 11:16:18 +0000
@@ -86,6 +86,8 @@
     
     cmp: {},
     
+    requireUpdate: false,
+    
     initComponent: function() {
     
         this.initProperties();
@@ -823,6 +825,7 @@
                 'select': {
                     scope: this,
                     fn: function() {
+                        this.requireUpdate = true;
                         this.formValidation.validateForm.call(this);
                         
                         this.window.cmp.reset.enable();
@@ -848,22 +851,22 @@
                 expanded: true
             },
             widget: this,
-            isSelected: false,
+            isLoaded: false,
             reset: function() {
                 if (this.getSelectionModel().getSelectedNode()) {
                     this.getSelectionModel().getSelectedNode().unselect();
                 }                
                 this.collapseAll();
                 this.getRootNode().expand();
-                this.isSelected = false;
                 this.widget.window.cmp.apply.disable();
             },
             listeners: {
                 'click': {
                     scope: this,
                     fn: function(n) {
-                        this.cmp.parent.selectedNode = n;
-                        this.cmp.parent.isSelected = true;
+                        var tree = n.getOwnerTree();
+                        tree.selectedNode = n;
+                        this.requireUpdate = true;
                         this.formValidation.validateForm.call(this);
                         
                         this.window.cmp.reset.enable();
@@ -873,7 +876,7 @@
         });
     },
     
-    addItems: function() {    
+    addItems: function() {
         
         this.items = [
             {
@@ -1386,6 +1389,7 @@
             this.mapView.parentOrganisationUnitLevel, this.mapView.organisationUnitLevel, this.mapView.organisationUnitLevelName);
             
         this.cmp.parent.reset();
+        
         this.cmp.parent.selectedNode = {attributes: {
             id: this.mapView.parentOrganisationUnitId,
             text: this.mapView.parentOrganisationUnitName,
@@ -1437,7 +1441,7 @@
 	},
     
     formValidation: {
-        validateForm: function(exception) {
+        validateForm: function() {
             if (this.cmp.mapValueType.getValue() == G.conf.map_value_type_indicator) {
                 if (!this.cmp.indicator.getValue()) {
                     if (exception) {
@@ -1521,8 +1525,15 @@
                 return false;
             }
             
-            if (this.cmp.parent.isSelected) {
-                this.window.cmp.apply.enable();
+            if (this.requireUpdate) {
+                if (this.window.isUpdate) {
+                    this.window.cmp.apply.disable();
+                    this.requireUpdate = false;
+                    this.window.isUpdate = false;
+                }
+                else {
+                    this.window.cmp.apply.enable();
+                }
             }
             
             return true;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-08-23 10:53:11 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-08-24 14:55:16 +0000
@@ -84,6 +84,8 @@
 
     cmp: {},
     
+    requireUpdate: false,
+    
     initComponent: function() {
         
         this.initProperties();
@@ -318,6 +320,7 @@
                 'select': {
                     scope: this,
                     fn: function() {
+                        this.requireUpdate = true;
                         this.formValidation.validateForm.call(this);
                         
                         this.window.cmp.reset.enable();
@@ -343,22 +346,22 @@
                 expanded: true
             },
             widget: this,
-            isSelected: false,
+            isLoaded: false,
             reset: function() {
                 if (this.getSelectionModel().getSelectedNode()) {
                     this.getSelectionModel().getSelectedNode().unselect();
                 }                
                 this.collapseAll();
                 this.getRootNode().expand();
-                this.isSelected = false;
                 this.widget.window.cmp.apply.disable();
             },
             listeners: {
                 'click': {
                     scope: this,
                     fn: function(n) {
-                        this.cmp.parent.selectedNode = n;
-                        this.cmp.parent.isSelected = true;
+                        var tree = n.getOwnerTree();
+                        tree.selectedNode = n;
+                        this.requireUpdate = true;
                         this.formValidation.validateForm.call(this);
                         
                         this.window.cmp.reset.enable();
@@ -649,8 +652,15 @@
                 return false;
             }
             
-            if (this.cmp.parent.isSelected) {
-                this.window.cmp.apply.enable();
+            if (this.requireUpdate) {
+                if (this.window.isUpdate) {
+                    this.window.cmp.apply.disable();
+                    this.requireUpdate = false;
+                    this.window.isUpdate = false;
+                }
+                else {
+                    this.window.cmp.apply.enable();
+                }
             }
             
             return true;