← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20721: hasValue support

 

------------------------------------------------------------
revno: 20721
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-10-15 16:05:49 +0200
message:
  hasValue support
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.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.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-10-09 15:14:42 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-10-15 14:05:49 +0000
@@ -1180,7 +1180,8 @@
                                 {name:"d2:countIfZeroPos",parameters:1},
                                 {name:"d2:countIfValue",parameters:2},
                                 {name:"d2:ceil",parameters:1},
-                                {name:"d2:round",parameters:1}];
+                                {name:"d2:round",parameters:1},
+                                {name:"d2:hasValue",parameters:1}];
             var continueLooping = true;
             //Safety harness on 10 loops, in case of unanticipated syntax causing unintencontinued looping
             for(var i = 0; i < 10 && continueLooping; i++ ) { 
@@ -1393,6 +1394,25 @@
                             expression = expression.replace(callToThisFunction, rounded);
                             successfulExecution = true;
                         }
+                        else if(dhisFunction.name === "d2:hasValue") {
+                            var variableName = parameters[0];
+                            var variableObject = variablesHash[variableName];
+                            var valueFound = false;
+                            if(variableObject)
+                            {
+                                if(variableObject.hasValue){
+                                    valueFound = true;
+                                }
+                            }
+                            else
+                            {
+                                $log.warn("could not find variable to check if has value: " + variableName);
+                            }
+
+                            //Replace the end evaluation of the dhis function:
+                            expression = expression.replace(callToThisFunction, valueFound);
+                            successfulExecution = true;
+                        }
                     });
                 });