← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20320: tracker-capture: registering tracker-associate - WIP

 

------------------------------------------------------------
revno: 20320
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-09-23 17:04:50 +0200
message:
  tracker-capture: registering tracker-associate - WIP
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/teiadd/tei-add-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/teiadd/tei-add.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/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/components/registration/default-registration-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html	2015-09-23 14:06:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/default-registration-form.html	2015-09-23 15:04:50 +0000
@@ -90,11 +90,14 @@
                                ng-model="selectedTei[attribute.id]" 
                                ng-disabled="true" 
                                ng-blur="teiValueUpdated(selectedTei, attribute.id)"
-                               style="width:85%;"
+                               style="width:75%;"
                                ng-required="attribute.mandatory || attribute.unique"/>
                         <a href ng-class="{true: 'disable-clicks', false: ''} [editingDisabled]" ng-click="getTrackerAssociate(attribute)" title="{{'add'| translate}} {{attribute.name}}">
                             <i class="fa fa-external-link fa-2x vertical-center"></i>
                         </a>
+                        <a href ng-if="selectedTei[attribute.id]" ng-class="{true: 'disable-clicks', false: ''} [editingDisabled]" ng-click="selectedTei[attribute.id] = null" title="{{'add'| translate}} {{attribute.name}}">
+                            <i class="fa fa-trash-o fa-2x vertical-center"></i>
+                        </a>
                     </span>
                     <span ng-switch-default>
                         <input type="text" 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-09-23 14:06:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-09-23 15:04:50 +0000
@@ -408,7 +408,9 @@
         });
 
         modalInstance.result.then(function (res) {
-            console.log('the result:  ', res);
+            if(res && res.id){
+                $scope.selectedTei[selectedAttribute.id] = res.id;
+            }
         });
     };    
 });

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/teiadd/tei-add-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/teiadd/tei-add-controller.js	2015-09-23 14:06:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/teiadd/tei-add-controller.js	2015-09-23 15:04:50 +0000
@@ -33,12 +33,14 @@
     $scope.selectedTei = selectedTei;
     $scope.programs = selections.prs;
     $scope.attributesById = CurrentSelection.getAttributesById();
+    $scope.addingTeiAssociate = false;
     
     if($scope.addingRelationship){
         $scope.teiAddLabel = $translate.instant('add_relationship');
     }
     else{        
         $scope.teiAddLabel = $scope.selectedAttribute && $scope.selectedAttribute.name ? $scope.selectedAttribute.name : $translate.instant('tracker_associate');
+        $scope.addingTeiAssociate = true;
     }
     
     $scope.searchOuTree = false;
@@ -366,46 +368,70 @@
     };
     
     $scope.addRelationship = function(){
-        if($scope.selectedTei && $scope.teiForRelationship && $scope.relationship.selected){            
-            var tei = angular.copy($scope.selectedTei);
-            var relationship = {};
-            relationship.relationship = $scope.relationship.selected.id;
-            relationship.displayName = $scope.relationship.selected.name;
-            relationship.relative = {};
-            
-            
-            relationship.trackedEntityInstanceA = $scope.selectedRelationship.aIsToB === $scope.relationship.selected.aIsToB ? $scope.selectedTei.trackedEntityInstance : $scope.teiForRelationship.id;
-            relationship.trackedEntityInstanceB = $scope.selectedRelationship.bIsToA === $scope.relationship.selected.bIsToA ? $scope.teiForRelationship.id : $scope.selectedTei.trackedEntityInstance;
-            
-            tei.relationships = [];
-            angular.forEach($scope.selectedTei.relationships, function(rel){
-                tei.relationships.push({relationship: rel.relationship, displayName: rel.displayName, trackedEntityInstanceA: rel.trackedEntityInstanceA, trackedEntityInstanceB: rel.trackedEntityInstanceB});
-            });
-            tei.relationships.push(relationship);
-            
-            TEIService.update(tei, $scope.optionSets, $scope.attributesById).then(function(response){
-                if(response.response && response.response.status !== 'SUCCESS'){//update has failed
-                    var dialogOptions = {
-                            headerText: 'relationship_error',
-                            bodyText: response.message
-                        };
-                    DialogService.showDialog({}, dialogOptions);
-                    return;
-                }
-                
-                relationship.relative.processed = true;
-                relationship.relative.attributes = $scope.teiForRelationship;
-                
-                if($scope.selectedTei.relationships){
-                    $scope.selectedTei.relationships.push(relationship);
-                }
-                else{
-                    $scope.selectedTei.relationships = [relationship];
-                }
-                
-                $modalInstance.close($scope.selectedTei.relationships);                
-            });
-        }        
+        if($scope.addingRelationship){
+            if($scope.selectedTei && $scope.teiForRelationship && $scope.relationship.selected){            
+                var tei = angular.copy($scope.selectedTei);
+                var relationship = {};
+                relationship.relationship = $scope.relationship.selected.id;
+                relationship.displayName = $scope.relationship.selected.name;
+                relationship.relative = {};
+
+
+                relationship.trackedEntityInstanceA = $scope.selectedRelationship.aIsToB === $scope.relationship.selected.aIsToB ? $scope.selectedTei.trackedEntityInstance : $scope.teiForRelationship.id;
+                relationship.trackedEntityInstanceB = $scope.selectedRelationship.bIsToA === $scope.relationship.selected.bIsToA ? $scope.teiForRelationship.id : $scope.selectedTei.trackedEntityInstance;
+
+                tei.relationships = [];
+                angular.forEach($scope.selectedTei.relationships, function(rel){
+                    tei.relationships.push({relationship: rel.relationship, displayName: rel.displayName, trackedEntityInstanceA: rel.trackedEntityInstanceA, trackedEntityInstanceB: rel.trackedEntityInstanceB});
+                });
+                tei.relationships.push(relationship);
+
+                TEIService.update(tei, $scope.optionSets, $scope.attributesById).then(function(response){
+                    if(response.response && response.response.status !== 'SUCCESS'){//update has failed
+                        var dialogOptions = {
+                                headerText: 'relationship_error',
+                                bodyText: response.message
+                            };
+                        DialogService.showDialog({}, dialogOptions);
+                        return;
+                    }
+
+                    relationship.relative.processed = true;
+                    relationship.relative.attributes = $scope.teiForRelationship;
+
+                    if($scope.selectedTei.relationships){
+                        $scope.selectedTei.relationships.push(relationship);
+                    }
+                    else{
+                        $scope.selectedTei.relationships = [relationship];
+                    }
+
+                    $modalInstance.close($scope.selectedTei.relationships);
+                });
+            }
+            else{
+                var dialogOptions = {
+                        headerText: 'relationship_error',
+                        bodyText: $translate.instant('selected_tei_is_invalid')
+                    };
+                DialogService.showDialog({}, dialogOptions);
+                return;
+            }
+        }
+        else{
+            if($scope.teiForRelationship && $scope.teiForRelationship.id){
+                $modalInstance.close($scope.teiForRelationship);
+            }
+            else{
+                var dialogOptions = {
+                        headerText: 'tracker_associate_error',
+                        bodyText: $translate.instant('selected_tei_is_invalid')
+                    };
+                DialogService.showDialog({}, dialogOptions);
+                return;
+            }
+                
+        }                
     };
     
     //Get orgunits for the logged in user

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/teiadd/tei-add.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/teiadd/tei-add.html	2015-09-23 14:06:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/teiadd/tei-add.html	2015-09-23 15:04:50 +0000
@@ -116,6 +116,6 @@
     </div>
 </div>
 <div class="modal-footer">        
-    <button class="btn btn-primary trim" data-ng-click="addRelationship()" ng-disabled='!teiForRelationship'>{{'save'| translate}}</button>
+    <button class="btn btn-primary trim" data-ng-click="addRelationship()" ng-disabled='!teiForRelationship'>{{addingRelationship ? 'save' : 'select' | translate}}</button>
     <button class="btn btn-default" data-ng-click="close()">{{'close'| translate}}</button>    
 </div> 
\ No newline at end of file

=== 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-09-23 14:06:13 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-09-23 15:04:50 +0000
@@ -32,6 +32,7 @@
 list_all=List all
 list=List
 invalid=Invalid
+selected_tei_is_invalid=Selected tracked entity instance is invalid.
 required=Required
 number_required=Number required
 date_required=Date required
@@ -270,6 +271,7 @@
 update_error=Error in update
 event_creation_error=Error in event creation
 relationship_error=Error in relationship assignment
+tracker_associate_error=Error in tracker associate assignment
 error=Error
 success=Success
 validation_error=Validation Error

=== 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-09-17 15:26:24 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/tei.html	2015-09-23 15:04:50 +0000
@@ -28,7 +28,8 @@
                         </tr>                        
                     </thead>
                     <tbody id="list">
-                        <tr ng-repeat="trackedEntity in trackedEntityList.rows | orderBy:d2Sort:reverse" 
+                        <tr ng-if="!addingTeiAssociate"
+                            ng-repeat="trackedEntity in trackedEntityList.rows | orderBy:d2Sort:reverse" 
                             ng-click="selectedTei.trackedEntityInstance ? assignRelationship(trackedEntity) : showDashboard(trackedEntity)"
                             ng-class="{true: 'inactive-tei'} [trackedEntity.inactive]"
                             title="{{selectedTei.trackedEntityInstance ? 'select' : 'go_to_dashboard'| translate}}">
@@ -45,6 +46,25 @@
                                 </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>