← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18387: tracker-capture: short-cut in relationship-widget for enrolling in related program

 

------------------------------------------------------------
revno: 18387
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-02-24 14:10:51 +0100
message:
  tracker-capture: short-cut in relationship-widget for enrolling in related program
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/add-relationship.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.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/relationship/add-relationship.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/add-relationship.html	2015-02-24 11:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/add-relationship.html	2015-02-24 13:10:51 +0000
@@ -6,7 +6,8 @@
         <div class='col-md-12'>
             <select ng-model="relationship.selected"
                     class="form-control"
-                    ng-options="rel as rel.name for rel in relationshipTypes | orderBy: 'name'">
+                    ng-options="rel as rel.name for rel in relationshipTypes | orderBy: 'name'"
+                    ng-disabled="relatedProgramRelationship">
                 <option value="">{{'please_select_a_relationship'| translate}}</option>
             </select>
         </div>
@@ -14,89 +15,87 @@
 
     <div class="row" ng-show="relationship.selected">
         <hr>
-        <div class="row col-md-12">
-            <div class="col-md-5">
-                <select name="foo" 
-                        ng-model="selectedRelationship.aIsToB" 
-                        class="form-control" 
-                        ng-change="setRelationshipSides('A')"
-                        ng-disabled="selectedProgramForRelative && selectedProgram.relatedProgram">
-                    <option>{{relationship.selected.aIsToB}}</option>
-                    <option>{{relationship.selected.bIsToA}}</option>
-                </select>
-                <div class='relationship-container'>
-                    <table class="table table-striped table-compact table-borderless">
-                        <tr ng-repeat="attribute in selectedTeiForDisplay.attributes">
-                            <td>
-                                {{attribute.displayName}}
-                            </td>
-                            <td>
-                                {{attribute.value}}                                                                                                  
-                            </td>
-                        </tr>           
-                    </table>
-                </div>
-            </div>
-            <div class="col-md-7">
-                <select name="foo" 
-                        ng-model="selectedRelationship.bIsToA" 
-                        class="form-control" 
-                        ng-change="setRelationshipSides('B')"
-                        ng-disabled="selectedProgramForRelative && selectedProgram.relatedProgram">    
-                    <option>{{relationship.selected.aIsToB}}</option>
-                    <option>{{relationship.selected.bIsToA}}</option>
-                </select>
-                <div class='relationship-container' ng-show="teiForRelationship">
-                    <table class="table table-striped table-compact table-borderless">
-                        <tr ng-repeat="gridColumn in gridColumns">
-                            <td>
-                                {{gridColumn.name}}
-                            </td>
-                            <td >                                                
-                                {{teiForRelationship[gridColumn.id]}}                                                
-                            </td> 
-                        </tr>
-                    </table>
-                </div>
-                <div class='relationship-container' ng-show="!teiForRelationship">
-                    <select ng-model="selectedRelationshipSource.value"
-                            class="form-control"
-                            ng-options="relationshipSource | translate for relationshipSource in relationshipSources">
-                        <option value="">{{'please_select_source'| translate}}</option>
-                    </select>
-                    <div class="input-group vertical-spacing" ng-if="selectedRelationshipSource.value === 'search_from_existing'">
-                        <input type="text" placeholder="{{'type_your_search_criteria_here'| translate}}" ng-model="searchText.value" d2-enter="search(searchMode.freeText)" class="form-control expanded" ng-class="{true: 'invalid - input'} [!searchText && emptySearchText]" ng-focus="showHideSearch(true)">
-                        <div class="input-group-btn">
-                            <button class="btn btn-default without-border-radius trim" type="button" title="{{'advanced_search'| translate}}" ng-click="showHideSearch(false)"><i class="fa fa-caret-down"></i></button>
-                            <button class="btn btn-primary trim" type="button" title="{{'search'| translate}}" ng-click="search(searchMode.freeText)"><i class="fa fa-search"></i></button>                            
-                        </div>                
-                    </div>
-                    <div ng-if="showSearchDiv && selectedRelationshipSource.value === 'search_from_existing'">
-                        <div ng-include="'components/relationship/search.html'"></div>     
-                        <span>&nbsp;</span>
-                    </div>
-                    <!-- entity grid begins -->
-                    <div class="row" ng-if="showTrackedEntityDiv">
-                        <img class="col-md-12" src="../images/ajax-loader-bar.gif" ng-if="!teiFetched"/>
-                        <div class="col-md-12" ng-include="'components/relationship/tei.html'"></div>                        
-                    </div>
-                    <!-- entity grid ends -->
-
-                    <!--- Error display for search begins -->
-                    <div class="row" ng-if="emptySearchAttribute || !searchText.value && emptySearchText">
-                        <div class="col-md-12 vertical-spacing">
-                            <div class="alert alert-danger">{{'search_input_required'| translate}}</div>         
-                        </div>
-                    </div>
-                    <!--- Error display for search ends -->
-                    
-                    <div ng-show="selectedRelationshipSource.value === 'register_new'">
-                        <div ng-include="'components/relationship/registration.html'"></div>
-                        <span>&nbsp;</span>
-                    </div>
-                </div>
+        <div class="col-md-4">
+            <select name="foo" 
+                    ng-model="selectedRelationship.aIsToB" 
+                    class="form-control" 
+                    ng-change="setRelationshipSides('A')"
+                    ng-disabled="selectedProgramForRelative && selectedProgram.relatedProgram && relatedProgramRelationship">
+                <option>{{relationship.selected.aIsToB}}</option>
+                <option>{{relationship.selected.bIsToA}}</option>
+            </select>
+            <div class='relationship-container'>
+                <table class="table table-striped table-compact table-borderless">
+                    <tr ng-repeat="attribute in selectedTeiForDisplay.attributes">
+                        <td>
+                            {{attribute.displayName}}
+                        </td>
+                        <td>
+                            {{attribute.value}}                                                                                                  
+                        </td>
+                    </tr>           
+                </table>
             </div>
         </div>
+        <div class="col-md-8 pull-right">
+            <select name="foo" 
+                    ng-model="selectedRelationship.bIsToA" 
+                    class="form-control" 
+                    ng-change="setRelationshipSides('B')"
+                    ng-disabled="selectedProgramForRelative && selectedProgram.relatedProgram && relatedProgramRelationship">    
+                <option>{{relationship.selected.aIsToB}}</option>
+                <option>{{relationship.selected.bIsToA}}</option>
+            </select>
+            <div class='relationship-container' ng-show="teiForRelationship">
+                <table class="table table-striped table-compact table-borderless">
+                    <tr ng-repeat="gridColumn in gridColumns">
+                        <td>
+                            {{gridColumn.name}}
+                        </td>
+                        <td >                                                
+                            {{teiForRelationship[gridColumn.id]}}                                                
+                        </td> 
+                    </tr>
+                </table>
+            </div>
+            <div class='relationship-container' ng-show="!teiForRelationship">
+                <select ng-model="selectedRelationshipSource.value"
+                        class="form-control"
+                        ng-options="relationshipSource | translate for relationshipSource in relationshipSources">
+                    <option value="">{{'please_select_source'| translate}}</option>
+                </select>
+                <div class="input-group vertical-spacing" ng-if="selectedRelationshipSource.value === 'search_from_existing'">
+                    <input type="text" placeholder="{{'type_your_search_criteria_here'| translate}}" ng-model="searchText.value" d2-enter="search(searchMode.freeText)" class="form-control expanded" ng-class="{true: 'invalid - input'} [!searchText && emptySearchText]" ng-focus="showHideSearch(true)">
+                    <div class="input-group-btn">
+                        <button class="btn btn-default without-border-radius trim" type="button" title="{{'advanced_search'| translate}}" ng-click="showHideSearch(false)"><i class="fa fa-caret-down"></i></button>
+                        <button class="btn btn-primary trim" type="button" title="{{'search'| translate}}" ng-click="search(searchMode.freeText)"><i class="fa fa-search"></i></button>                            
+                    </div>                
+                </div>
+                <div ng-if="showSearchDiv && selectedRelationshipSource.value === 'search_from_existing'">
+                    <div ng-include="'components/relationship/search.html'"></div>     
+                    <span>&nbsp;</span>
+                </div>
+                <!-- entity grid begins -->
+                <div class="row" ng-if="showTrackedEntityDiv">
+                    <img class="col-md-12" src="../images/ajax-loader-bar.gif" ng-if="!teiFetched"/>
+                    <div class="col-md-12" ng-include="'components/relationship/tei.html'"></div>                        
+                </div>
+                <!-- entity grid ends -->
+
+                <!--- Error display for search begins -->
+                <div class="row" ng-if="emptySearchAttribute || !searchText.value && emptySearchText">
+                    <div class="col-md-12 vertical-spacing">
+                        <div class="alert alert-danger">{{'search_input_required'| translate}}</div>         
+                    </div>
+                </div>
+                <!--- Error display for search ends -->
+
+                <div ng-show="selectedRelationshipSource.value === 'register_new'">
+                    <div ng-include="'components/relationship/registration.html'"></div>
+                    <span>&nbsp;</span>
+                </div>
+            </div>
+        </div>        
     </div>
 </div>
 <div class="modal-footer">        

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html	2015-02-24 11:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html	2015-02-24 13:10:51 +0000
@@ -5,7 +5,7 @@
 
         <select ng-model="selectedProgramForRelative"
                 class="form-control"
-                ng-disabled="programs.length < 1 || (selectedProgramForRelative && selectedProgram.relatedProgram)"
+                ng-disabled="programs.length < 1 || (selectedProgramForRelative && selectedProgram.relatedProgram && relatedProgramRelationship)"
                 ng-options="program as program.name for program in programs | orderBy: 'name'">
             <option value="">{{'please_select_a_program'| translate}}</option>
         </select>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js	2015-02-24 11:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js	2015-02-24 13:10:51 +0000
@@ -3,12 +3,10 @@
                 $rootScope,
                 $modal,                
                 $location,
-                $translate,
                 CurrentSelection,
-                TEIService,
                 RelationshipFactory) {
     $rootScope.showAddRelationshipDiv = false;    
-    $scope.addRelationshipLabel = $translate('add');
+    $scope.relatedProgramRelationship = false;
     
     //listen for the selected entity       
     $scope.$on('dashboardWidgets', function(event, args) { 
@@ -25,13 +23,6 @@
         $scope.selectedProgram = $scope.selections.pr;
         $scope.programs = $scope.selections.pr;
         
-        if($scope.selectedProgram && $scope.selectedProgram.relationshipText){
-            $scope.addRelationshipLabel = $scope.selectedProgram.relationshipText;
-        }
-        else{
-            $scope.addRelationshipLabel = $translate('add');
-        }
-        
         RelationshipFactory.getAll().then(function(rels){
             $scope.relationshipTypes = rels;    
             angular.forEach(rels, function(rel){
@@ -42,7 +33,8 @@
         });
     });
     
-    $scope.showAddRelationship = function() {
+    $scope.showAddRelationship = function(related) {
+        $scope.relatedProgramRelationship = related;
         $rootScope.showAddRelationshipDiv = !$rootScope.showAddRelationshipDiv;
        
         if($rootScope.showAddRelationshipDiv){
@@ -62,6 +54,9 @@
                     },
                     selectedProgram: function(){
                         return $scope.selectedProgram;
+                    },
+                    relatedProgramRelationship: function(){
+                        return $scope.relatedProgramRelationship;
                     }
                 }
             });
@@ -125,11 +120,13 @@
             $modalInstance, 
             relationshipTypes,
             selectedProgram,
+            relatedProgramRelationship,
             selections,
             selectedTei){
     
     $scope.relationshipTypes = relationshipTypes;
     $scope.selectedProgram = selectedProgram;
+    $scope.relatedProgramRelationship = relatedProgramRelationship;
     $scope.selectedTei = selectedTei;
     $scope.programs = selections.prs;
 
@@ -165,7 +162,7 @@
     } 
     
     if($scope.selectedProgram){
-        if($scope.selectedProgram.relatedProgram){
+        if($scope.selectedProgram.relatedProgram && $scope.relatedProgramRelationship){
             angular.forEach($scope.programs, function(pr){
                 if(pr.id === $scope.selectedProgram.relatedProgram.id){
                     $scope.selectedProgramForRelative = pr;

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship.html	2015-02-18 13:00:15 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship.html	2015-02-24 13:10:51 +0000
@@ -1,10 +1,14 @@
 <div class="panel panel-info" ng-controller="RelationshipController">
     <div class="panel-heading handle bold">
         {{relationshipWidget.title| translate}}
+        <span class="nav-pills" ng-if="selectedTei && selectedProgram.relationshipText">
+            | <a href ng-click="showAddRelationship(true)" title="{{'add_relationship'| translate}}"><span ng-class="{true: 'widget-link-active', false: 'widget-link'} [showAddRelationshipDiv]">{{selectedProgram.relationshipText}}</span></a>
+        </span>        
+        
         <span class="nav-pills" ng-if="selectedTei">
-            | <a href ng-click="showAddRelationship()" title="{{'add_relationship'| translate}}"><span ng-class="{true: 'widget-link-active', false: 'widget-link'} [showAddRelationshipDiv]">{{addRelationshipLabel}}</span></a>
-        </span>        
-
+            | <a href ng-click="showAddRelationship(false)" title="{{'add_relationship'| translate}}"><span ng-class="{true: 'widget-link-active', false: 'widget-link'} [showAddRelationshipDiv]">{{'add' | translate}}</span></a>
+        </span>
+        
         <span class="pull-right widget-link">
             <a class="small-horizonal-spacing" href ng-click="expandCollapse(relationshipWidget)">
                 <span ng-show="relationshipWidget.expand"><i class="fa fa-chevron-up" title="{{'collapse'| translate}}"></i></span>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html	2015-02-24 11:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html	2015-02-24 13:10:51 +0000
@@ -18,7 +18,7 @@
                     <select ng-model="selectedProgramForRelative"
                             class="form-control"
                             ng-options="program as program.name for program in programs | orderBy: 'name'" 
-                            ng-disabled="programs.length < 1 || (selectedProgramForRelative && selectedProgram.relatedProgram)"
+                            ng-disabled="programs.length < 1 || (selectedProgramForRelative && selectedProgram.relatedProgram && relatedProgramRelationship)"
                             ng-change="setAttributesForSearch(selectedProgramForRelative)">
                         <option value="">{{programs.length > 0 ? 'please_select_a_program' : 'no_program_exists' | translate}}</option>
                     </select>