← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15846: tei profile dashboard - editing of attributes

 

------------------------------------------------------------
revno: 15846
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Wed 2014-06-25 14:08:50 +0200
message:
  tei profile dashboard - editing of attributes
modified:
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2014-06-20 15:17:00 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2014-06-25 12:08:50 +0000
@@ -65,8 +65,7 @@
                             <button type="button" class="btn btn-default" ng-click="createEvent()">{{'create'| translate}}</button>
                         </div>                        
                     </div>
-                </form>
-                <hr>
+                </form>                
             </div>
         </div>        
         <div ng-show="currentEvent">

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js	2014-06-19 15:27:17 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js	2014-06-25 12:08:50 +0000
@@ -3,6 +3,7 @@
                 CurrentSelection,
                 TEService,
                 TEIService,
+                DateUtils,
                 AttributesFactory,
                 TranslationService) {
 
@@ -39,36 +40,44 @@
         angular.forEach($scope.selectedEntity.attributes, function(att){
             if(att.type === 'number' && !isNaN(parseInt(att.value))){
                 att.value = parseInt(att.value);
-            }
+            }            
         });        
         
         if($scope.selectedProgram){
             //show only those attributes in selected program            
             AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
-                for(var i=0; i<$scope.selectedEntity.attributes.length; i++){
-                    $scope.selectedEntity.attributes[i].show = false;
+                
+                for(var i=0; i<atts.length; i++){
                     var processed = false;
-                    for(var j=0; j<atts.length && !processed; j++){
-                        if($scope.selectedEntity.attributes[i].attribute === atts[j].id){
+                    for(var j=0; j<$scope.selectedEntity.attributes.length && !processed; j++){
+                        if(atts[i].id === $scope.selectedEntity.attributes[j].attribute){
                             processed = true;
-                            $scope.selectedEntity.attributes[i].show = true;
+                            $scope.selectedEntity.attributes[j].show = true;
                         }
-                    }                                   
+                    }
+
+                    if(!processed){//attribute was empty, so a chance to put some value
+                        $scope.selectedEntity.attributes.push({show: true, attribute: atts[i].id, displayName: atts[i].name, type: atts[i].valueType, value: ''});
+                    }                   
                 }
             }); 
         }
         else{
             //show attributes in no program
             AttributesFactory.getWithoutProgram().then(function(atts){
-                for(var i=0; i<$scope.selectedEntity.attributes.length; i++){
-                    $scope.selectedEntity.attributes[i].show = false;
+                
+                for(var i=0; i<atts.length; i++){
                     var processed = false;
-                    for(var j=0; j<atts.length && !processed; j++){
-                        if($scope.selectedEntity.attributes[i].attribute === atts[j].id){
+                    for(var j=0; j<$scope.selectedEntity.attributes.length && !processed; j++){
+                        if(atts[i].id === $scope.selectedEntity.attributes[j].attribute){
                             processed = true;
-                            $scope.selectedEntity.attributes[i].show = true;
+                            $scope.selectedEntity.attributes[j].show = true;
                         }
-                    }                                   
+                    }
+
+                    if(!processed){//attribute was empty, so a chance to put some value
+                        $scope.selectedEntity.attributes.push({show: true, attribute: atts[i].id, displayName: atts[i].name, type: atts[i].valueType, value: ''});
+                    }                   
                 }
             });
         }