← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19831: tracker-capture: program validation criteria

 

------------------------------------------------------------
revno: 19831
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-08-24 11:55:12 +0200
message:
  tracker-capture: program validation criteria
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/validation-message.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js
  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-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/validation-message.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/validation-message.html	2015-08-19 20:13:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/validation-message.html	2015-08-24 09:55:12 +0000
@@ -5,7 +5,7 @@
     <table class="table table-striped table-bordered">  
         <tr ng-repeat="message in validationResult.messages">            
             <td>
-                {{message.name}} {{'is_expected' | translate}} <strong>{{message.expected}}</strong> {{'but_found' | translate}} <strong>{{message.found}}</strong>
+                {{message.name}} {{'is_expected_to_be' | translate}} <strong>{{message.operator}} {{message.expected}}</strong> {{'but_found' | translate}} <strong>{{message.found}}</strong>
             </td>
         </tr>                                    
     </table>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-08-19 20:13:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-08-24 09:55:12 +0000
@@ -345,5 +345,8 @@
 dec=December
 week=Week
 save_layout_as_default=Save dashboard layout as default
-is_expected=is expected
-but_found=but found
\ No newline at end of file
+is_expected_to_be=is expected to be
+but_found=but found
+equals_to=equals to
+less_than=less than
+greater_than=greater than
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-08-19 20:13:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-08-24 09:55:12 +0000
@@ -538,19 +538,27 @@
             if(program && program.validationCriterias){
                 for(var key in program.validationCriterias){
                     angular.forEach(program.validationCriterias[key], function(vc){
-                        if(vc.property && vc.value){                                    
+                        var att = attributesById[key];
+                        var operator = '';
+                        if(vc.property && vc.value && att && att.valueType){
+                            if(att.valueType === 'number' && dhis2.validation.isNumber(vc.value)){
+                                vc.value = parseInt(vc.value);
+                            }
                             if(vc.operator === 0){
-                                enrollmentValidation.valid = vc.value === formTei[key];
+                                enrollmentValidation.valid = formTei[key] === vc.value;
+                                operator = $translate.instant('equals_to');
                             }
                             else if(vc.operator === 1){                                
-                                enrollmentValidation.valid = vc.value > formTei[key];
+                                enrollmentValidation.valid = formTei[key] > vc.value;
+                                operator = $translate.instant('greater_than');
                             }
                             else{
-                                enrollmentValidation.valid = vc.value < formTei[key];
+                                enrollmentValidation.valid = formTei[key] < vc.value;
+                                operator = $translate.instant('less_than');
                             }
 
                             if(!enrollmentValidation.valid){
-                                enrollmentValidation.messages.push({name: attributesById[key].name, expected: vc.value, found: formTei[key] ? formTei[key] : $translate.instant('empty')});                                    
+                                enrollmentValidation.messages.push({name: attributesById[key].name, operator: operator, expected: vc.value, found: formTei[key] ? formTei[key] : $translate.instant('empty')});
                             }                                
                         }
                     });                    

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-08-19 20:13:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-08-24 09:55:12 +0000
@@ -29,7 +29,7 @@
 dhis2.tc.store = new dhis2.storage.Store({
     name: 'dhis2tc',
     adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
-    objectStores: ['programs', 'programStages', 'trackedEntities', 'attributes', 'relationshipTypes', 'optionSets', 'programValidations', 'programIndicators', 'ouLevels', 'programRuleVariables', 'programRules','constants']      
+    objectStores: ['programs', 'programStages', 'trackedEntities', 'attributes', 'attributeGroups','relationshipTypes', 'optionSets', 'programValidations', 'programIndicators', 'ouLevels', 'programRuleVariables', 'programRules','constants']      
 });
 
 (function($) {
@@ -151,6 +151,7 @@
     promise = promise.then( getMetaProgramIndicators );
     promise = promise.then( getProgramIndicators );
     promise = promise.then( getOrgUnitLevels );
+    promise = promise.then( getTrackedEntityAttributeGroups );
     promise.done(function() {        
         //Enable ou selection after meta-data has downloaded
         $( "#orgUnitTree" ).removeClass( "disable-clicks" );        
@@ -555,6 +556,16 @@
     }); 
 }
 
+function getTrackedEntityAttributeGroups()
+{
+    dhis2.tc.store.getKeys( 'attributeGroups').done(function(res){        
+        if(res.length > 0){
+            return;
+        }        
+        return getD2Objects('attributeGroups', 'trackedEntityAttributeGroups', '../api/trackedEntityAttributeGroups.json', 'fields=id,name,trackedEntityAttributes[id]&paging=false', 'idb');        
+    }); 
+}
+
 function getMetaProgramValidations( programs )
 {    
     return getD2MetaObject(programs, 'programValidations', '../api/programValidations.json', 'paging=false&fields=id,program[id]');

=== 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-19 20:13:21 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-08-24 09:55:12 +0000
@@ -413,7 +413,7 @@
                             else {
                                 //check attribute type and generate corresponding angular input field
                                 if (att.valueType === "number") {
-                                    newInputField = '<input type="text" ' +
+                                    newInputField = '<input type="number" ' +
                                             ' d2-number-validator ' +
                                             ' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
                                             commonInputFieldProperty + ' >';