← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21538: tracker-capture: display orgunit name in tei list; make sure those teis from the data capture org...

 

------------------------------------------------------------
revno: 21538
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-12-28 21:34:02 +0100
message:
  tracker-capture: display orgunit name in tei list; make sure those teis from the data capture orgunit are displayed on top of the list
modified:
  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/views/home.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.html


--
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/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-12-24 10:18:52 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2015-12-28 20:34:02 +0000
@@ -1586,79 +1586,81 @@
     };    
 })
 
-.service('TEIGridService', function(OuService, OptionSetService, CurrentSelection, DateUtils, $translate){
+.service('TEIGridService', function(OptionSetService, CurrentSelection, DateUtils, $translate, $filter, SessionStorageService){
     
     return {
         format: function(grid, map, optionSets, invalidTeis){
             
+            var ou = SessionStorageService.get('SELECTED_OU');
+            
             invalidTeis = !invalidTeis ? [] : invalidTeis;
             if(!grid || !grid.rows){
                 return;
             }            
             
-            //grid.headers[0-5] = Instance, Created, Last updated, Org unit, Tracked entity, Inactive
-            //grid.headers[6..] = Attribute, Attribute,.... 
+            //grid.headers[0-6] = Instance, Created, Last updated, OU ID, Ou Name, Tracked entity, Inactive
+            //grid.headers[7..] = Attribute, Attribute,.... 
             var attributes = [];
             for(var i=6; i<grid.headers.length; i++){
                 attributes.push({id: grid.headers[i].name, name: grid.headers[i].column, type: grid.headers[i].type});
             }
 
-            var entityList = [];
+            var entityList = {own: [], other: []};
             
             var attributes = CurrentSelection.getAttributesById();
             
-            OuService.open().then(function(){            
-                angular.forEach(grid.rows, function(row){
-                    if(invalidTeis.indexOf(row[0]) === -1 ){
-                        var entity = {};
-                        var isEmpty = true;
-
-                        entity.id = row[0];
-                        entity.created = DateUtils.formatFromApiToUser( row[1] );
-
-                        entity.orgUnit = row[3];                              
-                        entity.type = row[4];
-                        entity.inactive = row[5] !== "" ? row[5] : false;
-
-                        OuService.get(row[3]).then(function(ou){
-                            if(ou && ou.n){
-                                entity.orgUnitName = ou.n;
-                            }                                                       
-                        });
-
-                        for(var i=6; i<row.length; i++){
-                            if(row[i] && row[i] !== ''){
-                                isEmpty = false;
-                                var val = row[i];
-
-                                if(attributes[grid.headers[i].name] && 
-                                        attributes[grid.headers[i].name].optionSetValue && 
-                                        optionSets &&    
-                                        attributes[grid.headers[i].name].optionSet &&
-                                        optionSets[attributes[grid.headers[i].name].optionSet.id] ){
-                                    val = OptionSetService.getName(optionSets[attributes[grid.headers[i].name].optionSet.id].options, val);
-                                }
-                                if(attributes[grid.headers[i].name] && attributes[grid.headers[i].name].valueType === 'date'){                                    
-                                    val = DateUtils.formatFromApiToUser( val );
-                                }
-
-                                entity[grid.headers[i].name] = val;
-                            }
-                        }
-
-                        if(!isEmpty){
-                            if(map){
-                                entityList[entity.id] = entity;
+            
+            angular.forEach(grid.rows, function(row){
+                if(invalidTeis.indexOf(row[0]) === -1 ){
+                    var entity = {};
+                    var isEmpty = true;
+
+                    entity.id = row[0];
+                    entity.created = DateUtils.formatFromApiToUser( row[1] );
+
+                    entity.orgUnit = row[3];
+                    entity.orgUnitName = row[4];
+                    entity.type = row[5];
+                    entity.inactive = row[6] !== "" ? row[6] : false;
+
+                    for(var i=7; i<row.length; i++){
+                        if(row[i] && row[i] !== ''){
+                            isEmpty = false;
+                            var val = row[i];
+
+                            if(attributes[grid.headers[i].name] && 
+                                    attributes[grid.headers[i].name].optionSetValue && 
+                                    optionSets &&    
+                                    attributes[grid.headers[i].name].optionSet &&
+                                    optionSets[attributes[grid.headers[i].name].optionSet.id] ){
+                                val = OptionSetService.getName(optionSets[attributes[grid.headers[i].name].optionSet.id].options, val);
+                            }
+                            if(attributes[grid.headers[i].name] && attributes[grid.headers[i].name].valueType === 'date'){                                    
+                                val = DateUtils.formatFromApiToUser( val );
+                            }
+
+                            entity[grid.headers[i].name] = val;
+                        }
+                    }
+
+                    if(!isEmpty){
+                        if(map){
+                            entityList[entity.id] = entity;
+                        }
+                        else{
+                            if(entity.orgUnit === ou.id){
+                                entityList.own.push(entity);
                             }
                             else{
-                                entityList.push(entity);
+                                entityList.other.push(entity);
                             }
                         }
                     }
-                });
+                }
             });
             
-            return {headers: attributes, rows: entityList, pager: grid.metaData.pager};
+            var len = entityList.own.length + entityList.other.length;
+            return {headers: attributes, rows: entityList, pager: grid.metaData.pager, length: len};
             
         },
         generateGridColumns: function(attributes, ouMode){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html	2015-12-24 11:47:36 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html	2015-12-28 20:34:02 +0000
@@ -58,15 +58,7 @@
         <input type="text" selected-org-unit ng-model="selectedOrgUnit.name" ng-hide=true>
         <!--- selected org unit ends  -->
 
-        <!--- search and registration menu begins -->
-        <!--<div class="row small-vertical-spacing not-for-screen hideInPrint">
-            <div class="col-sm-6 col-md-4">
-                <h4>{{orgUnitLabel}}</h4>
-            </div>
-            <div class="col-sm-6 col-md-4">
-                <input type="text" class="form-control" ng-disabled='true' value="{{selectedOrgUnit.name}}">
-            </div>
-        </div>-->
+        <!--- search and registration menu begins -->        
         <div class="row">
             
             <!-- program selection begins -->
@@ -150,7 +142,7 @@
                     </span>
                 </span>
                 
-                <div class="pull-right hideInPrint" ng-if="trackedEntityList.rows.length > 0 && !showRegistrationDiv">
+                <div class="pull-right hideInPrint" ng-if="trackedEntityList.length > 0 && !showRegistrationDiv">
                     <button class="btn btn-info"
                             type="button"                             
                             ng-click="showHideColumns()">

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.html	2015-10-05 13:56:43 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.html	2015-12-28 20:34:02 +0000
@@ -1,76 +1,100 @@
-<div ng-if="trackedEntityList.rows">
-    <div ng-switch="trackedEntityList.rows.length">                    
-        <div ng-switch-when="undefined">
-            <div class="alert alert-warning vertical-spacing">
-                {{'no'| translate}} {{selectedProgram.trackedEntity.name|| 'records' | translate}} {{'found'| translate}}                        
-            </div>
-        </div>
-        <div ng-switch-when="0">  
-            <div class="alert alert-warning vertical-spacing">
-                {{'no'| translate}} {{selectedProgram.trackedEntity.name|| 'records' | translate}} {{'found'| translate}}                        
-            </div>
-        </div>    
-        <div ng-switch-default> 
-
-            <!-- entity begins -->
-            <div class="vertical-spacing">
-                <table class="table table-striped dhis2-table-hover table-bordered">               
-                    <thead>                        
-                        <tr>
-                            <th ng-repeat="gridColumn in gridColumns| filter:{show: true}" class='mouse-pointer' ng-click="sortGrid(gridColumn)">                            
-                                <!-- sort icon begins -->                                
-                                <span ng-hide="gridColumn.showFilter" class="bold pointer" title="{{'sort'| translate}}">
-                                    <span ng-class="{true: 'red'} [sortColumn.id === gridColumn.id]"><i class="fa fa-sort"></i></span>
-                                    {{gridColumn.name}}
-                                </span>
-                                <!-- sort icon ends -->                            
-                            </th>                              
-                        </tr>                        
-                    </thead>
-                    <tbody id="list">
-                        <tr ng-if="!addingTeiAssociate"
-                            ng-repeat="trackedEntity in trackedEntityList.rows | orderBy:d2Sort:reverse" 
-                            ng-click="mainTei.trackedEntityInstance ? assignRelationship(trackedEntity) : showDashboard(trackedEntity)"
-                            ng-class="{true: 'inactive-tei'} [trackedEntity.inactive]"
-                            title="{{mainTei.trackedEntityInstance ? 'select' : 'go_to_dashboard'| translate}}">
-                            <td ng-repeat="gridColumn in gridColumns| filter:{show: true}">
-                                <span ng-switch="gridColumn.valueType">
-                                    <span ng-switch-when="bool">
-                                        <span ng-if="trackedEntity[gridColumn.id] === 'true'">{{'yes'| translate}}</span>
-                                        <span ng-if="trackedEntity[gridColumn.id] === 'false'">{{ 'no' | translate}}</span>
-                                    </span>
-                                    <span ng-switch-when="trueOnly">
-                                        <span ng-if="trackedEntity[gridColumn.id] === 'true'"><i class="fa fa-check"></i></span>
-                                    </span>
-                                    <span ng-switch-default>{{trackedEntity[gridColumn.id]}}</span>
-                                </span>
-                            </td>
-                        </tr>
-                        
-                        <tr ng-if="addingTeiAssociate"
-                            ng-repeat="trackedEntity in trackedEntityList.rows | orderBy:d2Sort:reverse" 
-                            ng-click="assignRelationship(trackedEntity)"
-                            ng-class="{true: 'inactive-tei'} [trackedEntity.inactive]"
-                            title="{{'select' | translate}}">
-                            <td ng-repeat="gridColumn in gridColumns| filter:{show: true}">
-                                <span ng-switch="gridColumn.valueType">
-                                    <span ng-switch-when="bool">
-                                        <span ng-if="trackedEntity[gridColumn.id] === 'true'">{{'yes'| translate}}</span>
-                                        <span ng-if="trackedEntity[gridColumn.id] === 'false'">{{ 'no' | translate}}</span>
-                                    </span>
-                                    <span ng-switch-when="trueOnly">
-                                        <span ng-if="trackedEntity[gridColumn.id] === 'true'"><i class="fa fa-check"></i></span>
-                                    </span>
-                                    <span ng-switch-default>{{trackedEntity[gridColumn.id]}}</span>
-                                </span>
-                            </td>
-                        </tr>
-                    </tbody>        
-                </table>
-            </div>
-            <!-- entity ends -->  
-            <serverside-paginator></serverside-paginator>
-
-        </div>
-    </div> 
+<div ng-if="teiFetched">
+    <div class="alert alert-warning vertical-spacing" ng-if="trackedEntityList.length === 0 || !trackedEntityList.length">
+        {{'no'| translate}} {{selectedProgram.trackedEntity.name|| 'records' | translate}} {{'found'| translate}}                        
+    </div>
+
+    <div class="vertical-spacing" ng-if="trackedEntityList.length > 0">
+        <table class="table table-striped dhis2-table-hover table-bordered">               
+            <thead>                        
+                <tr>
+                    <th ng-repeat="gridColumn in gridColumns| filter:{show: true}" class='mouse-pointer' ng-click="sortGrid(gridColumn)">                            
+                        <!-- sort icon begins -->                                
+                        <span ng-hide="gridColumn.showFilter" class="bold pointer" title="{{'sort'| translate}}">
+                            <span ng-class="{true: 'red'} [sortColumn.id === gridColumn.id]"><i class="fa fa-sort"></i></span>
+                            {{gridColumn.name}}
+                        </span>
+                        <!-- sort icon ends -->                            
+                    </th>                              
+                </tr>                        
+            </thead>
+            <tbody id="list">
+                <tr ng-if="!addingTeiAssociate"
+                    ng-repeat="trackedEntity in trackedEntityList.rows.own| orderBy:d2Sort:reverse" 
+                    ng-click="mainTei.trackedEntityInstance ? assignRelationship(trackedEntity) : showDashboard(trackedEntity)"
+                    ng-class="{true: 'inactive - tei'} [trackedEntity.inactive]"
+                    title="{{mainTei.trackedEntityInstance ? 'select' : 'go_to_dashboard'| translate}}">
+                    <td ng-repeat="gridColumn in gridColumns| filter:{show: true}">
+                        <span ng-switch="gridColumn.valueType">
+                            <span ng-switch-when="bool">
+                                <span ng-if="trackedEntity[gridColumn.id] === 'true'">{{'yes'| translate}}</span>
+                                <span ng-if="trackedEntity[gridColumn.id] === 'false'">{{ 'no' | translate}}</span>
+                            </span>
+                            <span ng-switch-when="trueOnly">
+                                <span ng-if="trackedEntity[gridColumn.id] === 'true'"><i class="fa fa-check"></i></span>
+                            </span>
+                            <span ng-switch-default>{{trackedEntity[gridColumn.id]}}</span>
+                        </span>
+                    </td>
+                </tr>
+                <tr ng-if="!addingTeiAssociate"
+                    ng-repeat="trackedEntity in trackedEntityList.rows.other| orderBy:d2Sort:reverse" 
+                    ng-click="mainTei.trackedEntityInstance ? assignRelationship(trackedEntity) : showDashboard(trackedEntity)"
+                    ng-class="{true: 'inactive - tei'} [trackedEntity.inactive]"
+                    title="{{mainTei.trackedEntityInstance ? 'select' : 'go_to_dashboard'| translate}}">
+                    <td ng-repeat="gridColumn in gridColumns| filter:{show: true}">
+                        <span ng-switch="gridColumn.valueType">
+                            <span ng-switch-when="bool">
+                                <span ng-if="trackedEntity[gridColumn.id] === 'true'">{{'yes'| translate}}</span>
+                                <span ng-if="trackedEntity[gridColumn.id] === 'false'">{{ 'no' | translate}}</span>
+                            </span>
+                            <span ng-switch-when="trueOnly">
+                                <span ng-if="trackedEntity[gridColumn.id] === 'true'"><i class="fa fa-check"></i></span>
+                            </span>
+                            <span ng-switch-default>{{trackedEntity[gridColumn.id]}}</span>
+                        </span>
+                    </td>
+                </tr>
+
+                <tr ng-if="addingTeiAssociate"
+                    ng-repeat="trackedEntity in trackedEntityList.rows.own| orderBy:d2Sort:reverse" 
+                    ng-click="assignRelationship(trackedEntity)"
+                    ng-class="{true: 'inactive - tei'} [trackedEntity.inactive]"
+                    title="{{'select'| translate}}">
+                    <td ng-repeat="gridColumn in gridColumns| filter:{show: true}">
+                        <span ng-switch="gridColumn.valueType">
+                            <span ng-switch-when="bool">
+                                <span ng-if="trackedEntity[gridColumn.id] === 'true'">{{'yes'| translate}}</span>
+                                <span ng-if="trackedEntity[gridColumn.id] === 'false'">{{ 'no' | translate}}</span>
+                            </span>
+                            <span ng-switch-when="trueOnly">
+                                <span ng-if="trackedEntity[gridColumn.id] === 'true'"><i class="fa fa-check"></i></span>
+                            </span>
+                            <span ng-switch-default>{{trackedEntity[gridColumn.id]}}</span>
+                        </span>
+                    </td>
+                </tr>
+                <tr ng-if="addingTeiAssociate"
+                    ng-repeat="trackedEntity in trackedEntityList.rows.other| orderBy:d2Sort:reverse" 
+                    ng-click="assignRelationship(trackedEntity)"
+                    ng-class="{true: 'inactive - tei'} [trackedEntity.inactive]"
+                    title="{{'select'| translate}}">
+                    <td ng-repeat="gridColumn in gridColumns| filter:{show: true}">
+                        <span ng-switch="gridColumn.valueType">
+                            <span ng-switch-when="bool">
+                                <span ng-if="trackedEntity[gridColumn.id] === 'true'">{{'yes'| translate}}</span>
+                                <span ng-if="trackedEntity[gridColumn.id] === 'false'">{{ 'no' | translate}}</span>
+                            </span>
+                            <span ng-switch-when="trueOnly">
+                                <span ng-if="trackedEntity[gridColumn.id] === 'true'"><i class="fa fa-check"></i></span>
+                            </span>
+                            <span ng-switch-default>{{trackedEntity[gridColumn.id]}}</span>
+                        </span>
+                    </td>
+                </tr>
+            </tbody>        
+        </table>
+        <serverside-paginator></serverside-paginator>
+    </div>   
 </div>
+
+