← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21317: tracker/event-capture: bug fix in longitude validation

 

------------------------------------------------------------
revno: 21317
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-12-04 09:56:52 +0100
message:
  tracker/event-capture: bug fix in longitude validation
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.validations.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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.validations.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.validations.js	2015-10-16 13:14:30 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.validations.js	2015-12-04 08:56:52 +0000
@@ -51,7 +51,7 @@
         require: "ngModel",         
         link: function(scope, element, attrs, ngModel) {
         	
-        	var isRequired = attrs.ngRequired === 'true';
+            var isRequired = attrs.ngRequired === 'true';
         	
             ngModel.$validators.dateValidator = function(value) {
                 if(!value){
@@ -83,30 +83,34 @@
         restrict: "A",         
         require: "ngModel",         
         link: function(scope, element, attrs, ngModel) {
-        	
-        	var isRequired = attrs.ngRequired === 'true';
-        	
-            ngModel.$validators.latitudeValidator = function(value) {
-                if(!value){
-                    return !isRequired;
-                }
-                var isNumber = dhis2.validation.isNumber(value);
-                if(!isNumber){
-                    return isNumber;
-                }
-                return value >= -90 && value <= 90;
-            };
-            
-            ngModel.$validators.longitudeValidator = function(value) {
-                if(!value){
-                    return !isRequired;
-                }
-                var isNumber = dhis2.validation.isNumber(value);
-                if(!isNumber){
-                    return isNumber;
-                }
-                return value >= -180 && value <= 180;
-            };
+            
+            var isRequired = attrs.ngRequired === 'true';
+            
+            if(attrs.name === 'latitude'){
+                ngModel.$validators.latitudeValidator = function(value) {
+                    if(!value){
+                        return !isRequired;
+                    }
+                    var isNumber = dhis2.validation.isNumber(value);
+                    if(!isNumber){
+                        return isNumber;
+                    }
+                    return value >= -90 && value <= 90;
+                };
+            }
+            
+            if(attrs.name === 'longitude'){
+                ngModel.$validators.longitudeValidator = function(value) {
+                    if(!value){
+                        return !isRequired;
+                    }
+                    var isNumber = dhis2.validation.isNumber(value);
+                    if(!isNumber){
+                        return isNumber;
+                    }
+                    return value >= -180 && value <= 180;
+                };
+            }            
         }
     };
 })