← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19870: Fix for optionset datatype and trackedEntityAttributes in rules engine

 

------------------------------------------------------------
revno: 19870
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-08-27 14:56:53 +0200
message:
  Fix for optionset datatype and trackedEntityAttributes in rules engine
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-08-27 11:49:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-08-27 12:56:53 +0000
@@ -402,7 +402,7 @@
                             //check if attribute has optionset
                             if (att.optionSetValue) {
                                 var optionSetId = att.optionSet.id;                                
-                                newInputField = '<ui-select theme="select2" ' + commonInputFieldProperty + '  on-select="teiValueUpdated(selectedTei,\'' + attId + '\')" >' +
+                                newInputField = '<ui-select theme="select2" ' + commonInputFieldProperty + '  on-select="validationAndSkipLogic(selectedTei,\'' + attId + '\')" >' +
                                         '<ui-select-match style="width:100%;" allow-clear="true" placeholder="' + $translate.instant('select_or_search') + '">{{$select.selected.name || $select.selected}}</ui-select-match>' +
                                         '<ui-select-choices ' +
                                         'repeat="option.name as option in optionSets.' + optionSetId + '.options | filter: $select.search | limitTo:30">' +
@@ -415,12 +415,12 @@
                                 if (att.valueType === "number") {
                                     newInputField = '<input type="number" ' +
                                             ' d2-number-validator ' +
-                                            ' ng-blur="teiValueUpdated(selectedTei,\'' + attId + '\')" ' +
+                                            ' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
                                             commonInputFieldProperty + ' >';
                                 }
                                 else if (att.valueType === "bool") {
                                     newInputField = '<select ' +
-                                            ' ng-change="teiValueUpdated(selectedTei,\'' + attId + '\')" ' +
+                                            ' ng-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
                                             commonInputFieldProperty + ' > ' +
                                             ' <option value="">{{\'please_select\'| translate}}</option>' +
                                             ' <option value="false">{{\'no\'| translate}}</option>' +
@@ -432,22 +432,22 @@
                                             ' placeholder="{{dhis2CalendarFormat.keyDateFormat}}" ' +
                                             ' max-date="' + attMaxDate + '"' + '\'' +
                                             ' d2-date' +
-                                            ' blur-or-change="teiValueUpdated(selectedTei,\'' + attId + '\')" ' +
+                                            ' blur-or-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
                                             commonInputFieldProperty + ' >';
                                 }
                                 else if (att.valueType === "trueOnly") {
                                     newInputField = '<input type="checkbox" ' +
-                                            ' ng-change="teiValueUpdated(selectedTei,\'' + attId + '\')" ' +
+                                            ' ng-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
                                             commonInputFieldProperty + ' >';
                                 }
                                 else if (att.valueType === "email") {
                                     newInputField = '<input type="email" ' +
-                                            ' ng-blur="teiValueUpdated(selectedTei,\'' + attId + '\')" ' +
+                                            ' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
                                             commonInputFieldProperty + ' >';
                                 }
                                 else {
                                     newInputField = '<input type="text" ' +
-                                            ' ng-blur="teiValueUpdated(selectedTei,\'' + attId + '\')" ' +
+                                            ' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
                                             commonInputFieldProperty + ' >';
                                 }
                             }
@@ -721,11 +721,16 @@
         variableValue = $filter('trimquotes')(variableValue);
 
         //Append single quotation marks in case the variable is of text or date type:
-        if(variableType === 'string' || variableType === 'date') {
-            variableValue = "'" + variableValue + "'";
+        if(variableType === 'string' || variableType === 'date' || variableType === 'optionSet') {
+            if(variableValue) {
+                variableValue = "'" + variableValue + "'";
+            } else {
+                variableValue = "''";
+            }
+                
         }
         else if(variableType === 'bool' || variableType === 'trueOnly') {
-            if(eval(variableValue)) {
+            if(variableValue && eval(variableValue)) {
                 variableValue = true;
             }
             else {
@@ -733,7 +738,11 @@
             }
         }
         else if(variableType === "int" || variableType === "number") {
-            variableValue = Number(variableValue);
+            if(variableValue) {
+                variableValue = Number(variableValue);
+            } else {
+                variableValue = 0;
+            }  
         }
         else{
             $log.warn("unknown datatype:" + variableType);
@@ -1207,6 +1216,7 @@
                                     location:action.location, 
                                     action:action.programRuleActionType,
                                     dataElement:action.dataElement,
+                                    trackedEntityAttribute:action.trackedEntityAttribute,
                                     content:action.content,
                                     data:action.data,
                                     ineffect:undefined