← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19968: rules engine is now update for type -> valueType change.

 

------------------------------------------------------------
revno: 19968
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-09-03 16:22:27 +0200
message:
  rules engine is now update for type -> valueType change.
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js
  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.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-apps/src/main/webapp/dhis-web-event-capture/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html	2015-09-03 13:13:08 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html	2015-09-03 14:22:27 +0000
@@ -70,7 +70,7 @@
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
-        <!--<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>-->
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>
         <script type="text/javascript" src="scripts/event-capture.js"></script>
         
@@ -80,12 +80,12 @@
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/select2.js"></script>                
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/ng-infinite-scroll.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js"></script>
-        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.angular.validations.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.angular.filters.js"></script>
+        <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.angular.validations.js"></script>        
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.angular.controllers.js"></script>
         
-        <script type="text/javascript" src="scripts/app.js"></script>        
+        <script type="text/javascript" src="scripts/app.js"></script>
         <script type="text/javascript" src="scripts/services.js"></script>
         <script type="text/javascript" src="scripts/directives.js"></script>        
         <script type="text/javascript" src="scripts/controllers.js"></script>        

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js	2015-08-25 14:54:19 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js	2015-09-03 14:22:27 +0000
@@ -432,7 +432,7 @@
                     var programRuleVariablesArray = [];
                     //Loop through and add the variables belonging to this program
                     angular.forEach(variables, function(variable){
-                       if(variable.program.id == programUid) {
+                       if(variable.program.id === programUid) {
                             programRuleVariablesArray.push(variable);
                        }
                     });

=== 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-09-03 13:13:08 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-09-03 14:22:27 +0000
@@ -359,7 +359,7 @@
                                     ' ng-disabled="isHidden(prStDes.' + fieldId + '.dataElement.id) || selectedEnrollment.status===\'CANCELLED\' || selectedEnrollment.status===\'COMPLETED\' || currentEvent[uid]==\'uid\' || currentEvent.editingNotAllowed"' +
                                     ' ng-required="{{prStDes.' + fieldId + '.compulsory}}" ';
 
-                            if (prStDe && prStDe.dataElement && prStDe.dataElement.type) {
+                            if (prStDe && prStDe.dataElement && prStDe.dataElement.valueType) {
                                 //check if dataelement has optionset								
                                 if (prStDe.dataElement.optionSetValue) {
                                     var optionSetId = prStDe.dataElement.optionSet.id;                 
@@ -373,14 +373,18 @@
                                 }
                                 else {
                                     //check data element type and generate corresponding angular input field
-                                    if (prStDe.dataElement.type === "int") {
+                                    if (prStDe.dataElement.valueType === "NUMBER" || 
+                                    		prStDe.dataElement.valueType === "INTEGER" || 
+                                    		prStDe.dataElement.valueType === "INTEGER_POSITIVE" ||
+                                    		prStDe.dataElement.valueType === "INTEGER_NEGATIVE" ||
+                                    		prStDe.dataElement.valueType === "INTEGER_ZERO_OR_POSITIVE") {
                                         newInputField = '<input type="number" ' +
                                                 ' d2-number-validator ' +
-                                                ' number-type="' + prStDe.dataElement.numberType + '" ' +
+                                                ' number-type="' + prStDe.dataElement.valueType + '" ' +
                                                 ' ng-blur="saveDatavalue(prStDes.' + fieldId + ', outerForm.' + fieldId + ')"' +
                                                 commonInputFieldProperty + ' >';
                                     }
-                                    else if (prStDe.dataElement.type === "bool") {
+                                    else if (prStDe.dataElement.valueType === "BOOLEAN") {
                                         newInputField = '<select ' +
                                                 ' ng-change="saveDatavalue(prStDes.' + fieldId + ', outerForm.' + fieldId + ')" ' +
                                                 commonInputFieldProperty + '>' +
@@ -389,7 +393,7 @@
                                                 '<option value="true">{{\'yes\'| translate}}</option>' +
                                                 '</select> ';
                                     }
-                                    else if (prStDe.dataElement.type === "date") {
+                                    else if (prStDe.dataElement.valueType === "DATE") {
                                         var maxDate = prStDe.allowFutureDate ? '' : 0;
                                         newInputField = '<input type="text" ' +
                                                 ' placeholder="{{dhis2CalendarFormat.keyDateFormat}}" ' +
@@ -399,11 +403,16 @@
                                                 ' blur-or-change="saveDatavalue(prStDes.' + fieldId + ', outerForm.' + fieldId + ')"' +
                                                 commonInputFieldProperty + ' >';
                                     }
-                                    else if (prStDe.dataElement.type === "trueOnly") {
+                                    else if (prStDe.dataElement.valueType === "TRUE_ONLY") {
                                         newInputField = '<input type="checkbox" ' +
                                                 ' ng-change="saveDatavalue(prStDes.' + fieldId + ', outerForm.' + fieldId + ')"' +
                                                 commonInputFieldProperty + ' >';
                                     }
+                                    else if (prStDe.dataElement.valueType === "LONG_TEXT") {
+                                        newInputField = '<textarea row ="3" ' +
+                                                ' ng-blur="saveDatavalue(prStDes.' + fieldId + ', outerForm.' + fieldId + ')"' +
+                                                commonInputFieldProperty + ' >';
+                                    }
                                     else {
                                         newInputField = '<input type="text" ' +
                                                 ' ng-blur="saveDatavalue(prStDes.' + fieldId + ', outerForm.' + fieldId + ')"' +
@@ -793,7 +802,7 @@
         variableValue = $filter('trimquotes')(variableValue);
 
         //Append single quotation marks in case the variable is of text or date type:
-        if(variableType === 'string' || variableType === 'date' || variableType === 'optionSet') {
+        if(variableType === 'TEXT' || variableType === 'DATE' || variableType === 'OPTION_SET') {
             if(variableValue) {
                 variableValue = "'" + variableValue + "'";
             } else {
@@ -801,7 +810,7 @@
             }
                 
         }
-        else if(variableType === 'bool' || variableType === 'trueOnly') {
+        else if(variableType === 'BOOLEAN' || variableType === 'TRUE_ONLY') {
             if(variableValue && eval(variableValue)) {
                 variableValue = true;
             }
@@ -809,7 +818,7 @@
                 variableValue = false;
             }
         }
-        else if(variableType === "int" || variableType === "number") {
+        else if(variableType === "INTEGER" || variableType === "NUMBER" || variableType === "INTEGER_POSITIVE" || variableType === "INTEGER_NEGATIVE" || variableType === "INTEGER_ZERO_OR_POSITIVE") {
             if(variableValue) {
                 variableValue = Number(variableValue);
             } else {
@@ -861,7 +870,7 @@
                             if(angular.isDefined(event[dataElementId])
                                     && event[dataElementId] !== null ){
                                 valueFound = true;
-                                variables = pushVariable(variables, programVariable.name, event[dataElementId], allDes[dataElementId].dataElement.type, valueFound, '#');
+                                variables = pushVariable(variables, programVariable.name, event[dataElementId], allDes[dataElementId].dataElement.valueType, valueFound, '#');
                             }
                         });
                     } else {
@@ -876,7 +885,7 @@
                         if(angular.isDefined(event[dataElementId])
                                 && event[dataElementId] !== null ){
                             valueFound = true;
-                            variables = pushVariable(variables, programVariable.name, event[dataElementId], allDes[dataElementId].dataElement.type, valueFound, '#' );
+                            variables = pushVariable(variables, programVariable.name, event[dataElementId], allDes[dataElementId].dataElement.valueType, valueFound, '#' );
                          }
                     });
                 }
@@ -884,7 +893,7 @@
                     if(angular.isDefined(executingEvent[dataElementId])
                             && executingEvent[dataElementId] !== null ){
                         valueFound = true;
-                        variables = pushVariable(variables, programVariable.name, executingEvent[dataElementId], allDes[dataElementId].dataElement.type, valueFound, '#' );
+                        variables = pushVariable(variables, programVariable.name, executingEvent[dataElementId], allDes[dataElementId].dataElement.valueType, valueFound, '#' );
                     }      
                 }
                 else if(programVariable.programRuleVariableSourceType === "DATAELEMENT_PREVIOUS_EVENT" && evs){
@@ -903,7 +912,7 @@
                             else if(evs.all[i] === executingEvent) {
                                 //We have iterated to the newest event - store the last collected variable value - if any is found:
                                 if(valueFound) {
-                                    variables = pushVariable(variables, programVariable.name, previousvalue, allDes[dataElementId].dataElement.type, valueFound, '#' );
+                                    variables = pushVariable(variables, programVariable.name, previousvalue, allDes[dataElementId].dataElement.valueType, valueFound, '#' );
                                 }
                                 //Set currentEventPassed, ending the iteration:
                                 currentEventPassed = true;
@@ -916,7 +925,7 @@
                         if(!valueFound) {
                             if(attribute.attribute === programVariable.trackedEntityAttribute.id) {
                                 valueFound = true;
-                                variables = pushVariable(variables, programVariable.name, attribute.value, attribute.type, valueFound, 'A' );
+                                variables = pushVariable(variables, programVariable.name, attribute.value, attribute.valueType, valueFound, 'A' );
                             }
                         }
                     });
@@ -947,38 +956,38 @@
                     if(dataElementId && allDes) {
                         var dataElement = allDes[dataElementId];
                         if( dataElement ) {
-                            variables = pushVariable(variables, programVariable.name, "", dataElement.dataElement.type, false, '#' );
+                            variables = pushVariable(variables, programVariable.name, "", dataElement.dataElement.valueType, false, '#' );
                         } 
                         else {
                             $log.warn("Variable #{" + programVariable.name + "} is linked to a dataelement that is not part of the program");
-                            variables = pushVariable(variables, programVariable.name, "", "string",false, '#' );
+                            variables = pushVariable(variables, programVariable.name, "", "TEXT",false, '#' );
                         }
                     }
                     else if (programVariable.trackedEntityAttribute) {
                         //The variable is an attribute, set correct prefix and a blank value
-                        variables = pushVariable(variables, programVariable.name, "", "string",false, 'A' );
+                        variables = pushVariable(variables, programVariable.name, "", "TEXT",false, 'A' );
                     }
                     else {
                         //Fallback for calculated(assigned) values:
-                        variables = pushVariable(variables, programVariable.name, "", "string",false, '#' );
+                        variables = pushVariable(variables, programVariable.name, "", "TEXT",false, '#' );
                     }
                 }
             });
 
             //add context variables:
             //last parameter "valuefound" is always true for event date
-            variables = pushVariable(variables, 'incident_date', executingEvent.eventDate, 'date', true, 'V' );
-            variables = pushVariable(variables, 'current_date', DateUtils.getToday(), 'date', true, 'V' );
+            variables = pushVariable(variables, 'incident_date', executingEvent.eventDate, 'DATE', true, 'V' );
+            variables = pushVariable(variables, 'current_date', DateUtils.getToday(), 'DATE', true, 'V' );
             if(selectedEnrollment){
-                variables = pushVariable(variables, 'enrollment_date', selectedEnrollment.dateOfEnrollment, 'date', true, 'V' );
+                variables = pushVariable(variables, 'enrollment_date', selectedEnrollment.dateOfEnrollment, 'DATE', true, 'V' );
             }
 
-            //variables = pushVariable(variables, 'value_count', executingEvent.eventDate, 'date', true, 'V' );
-            //variables = pushVariable(variables, 'zero_pos_value_count', executingEvent.eventDate, 'date', true, 'V' );
+            //variables = pushVariable(variables, 'value_count', executingEvent.eventDate, 'DATE', true, 'V' );
+            //variables = pushVariable(variables, 'zero_pos_value_count', executingEvent.eventDate, 'DATE', true, 'V' );
 
             //Push all constant values:
             angular.forEach(allProgramRules.constants, function(constant){
-                variables = pushVariable(variables, constant.id, constant.value, 'int', true, 'C' );
+                variables = pushVariable(variables, constant.id, constant.value, 'INTEGER', true, 'C' );
             });
 
             return variables;

=== 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-07-14 18:31:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.validations.js	2015-09-03 14:22:27 +0000
@@ -6,31 +6,31 @@
         link: function (scope, element, attrs, ngModel) {
             
             function setValidity(numberType, isRequired){
-                if(numberType === 'number'){
+                if(numberType === 'NUMBER'){
                     ngModel.$validators.number = function(value) {
                     	value = value === 0 ? value.toString(): value; 
                         return value === 'null' || !value ? !isRequired : dhis2.validation.isNumber(value);
                     };
                 }
-                else if(numberType === 'posInt'){
+                else if(numberType === 'INTEGER_POSITIVE'){
                     ngModel.$validators.posInt = function(value) {
                     	value = value === 0 ? value.toString(): value; 
                         return value === 'null' || !value ? !isRequired : dhis2.validation.isPositiveInt(value);
                     };
                 }
-                else if(numberType === 'negInt'){
+                else if(numberType === 'INTEGER_NEGATIVE'){
                     ngModel.$validators.negInt = function(value) {
                     	value = value === 0 ? value.toString(): value;
                         return value === 'null' || !value ? !isRequired : dhis2.validation.isNegativeInt(value);
                     };
                 }
-                else if(numberType === 'zeroPositiveInt'){
+                else if(numberType === 'INTEGER_ZERO_OR_POSITIVE'){
                     ngModel.$validators.zeroPositiveInt = function(value) {
                     	value = value === 0 ? value.toString(): value; 
                         return value === 'null' || !value ? !isRequired : dhis2.validation.isZeroOrPositiveInt(value);
                     };
                 }
-                else if(numberType === 'int'){
+                else if(numberType === 'INTEGER'){
                     ngModel.$validators.int = function(value) {
                     	value = value === 0 ? value.toString(): value;
                         return value === 'null' || !value ? !isRequired : dhis2.validation.isInt(value);