← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17609: use relationship text from setting; make sure z-index of calendar popup is greater than others; a...

 

------------------------------------------------------------
revno: 17609
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-11-28 15:54:12 +0100
message:
  use relationship text from setting; make sure z-index of calendar popup is greater than others; apply option name/code formatting in relationship UI
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/styles/style.css


--
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	2014-07-04 21:04:49 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/add-relationship.html	2014-11-28 14:54:12 +0000
@@ -19,7 +19,7 @@
                 <div class='align-center bold'>{{relationship.selected.aIsToB}}</div>
                 <div class='relationship-container'>
                     <table class="table table-striped table-compact table-borderless">
-                        <tr ng-repeat="attribute in selectedTei.attributes">
+                        <tr ng-repeat="attribute in selectedTeiForDisplay.attributes">
                             <td>
                                 {{attribute.displayName}}
                             </td>

=== 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	2014-10-13 15:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html	2014-11-28 14:54:12 +0000
@@ -1,4 +1,4 @@
-<div ng-controller="RelativeRegistrationController">    
+<div ng-controller="RelativeRegistrationController" class="modal-dialog">    
     <hr>
     <form name="outerForm" novalidate>
 
@@ -34,7 +34,7 @@
                     <ng-form name="innerForm">     
                         <div ng-switch="attribute.valueType">
                             <div ng-switch-when="date">
-                                <input type="text" name="foo" class="form-control" d2-date ng-model="attribute.value" ng-required="attribute.mandatory" />
+                                <input type="text" placeholder="{{dhis2CalendarFormat.keyDateFormat}}" name="foo" class="form-control" d2-date ng-model="attribute.value" ng-required="attribute.mandatory" />
                                 <span ng-show="outerForm.submitted && innerForm.foo.$invalid" class="error">{{'required'| translate}}</span>
                             </div>
                             <div ng-switch-when="trueOnly">
@@ -48,22 +48,57 @@
                                     <option value="true">{{'yes'| translate}}</option>
                                 </select>
                                 <span ng-show="outerForm.submitted && innerForm.foo.$invalid" class="error">{{'required'| translate}}</span>
-                            </div>
+                            </div>                            
                             <div ng-switch-when="optionSet">
-                                <input type="text"
+                                <div ng-if="!selectedProgramForRelative">
+                                    <input type="text"
                                        name="foo"
                                        class="form-control"
                                        ng-model="attribute.value"                                                 
-                                       typeahead="option.code as option.name for option in attribute.optionSet.options | filter:$viewValue | limitTo:20" 
+                                       typeahead="option.name as option.name for option in optionSets.optionSets[attribute.optionSet.id].options | filter:$viewValue | limitTo:20" 
                                        typeahead-open-on-focus
-                                       ng-required="attribute.mandatory"
-                                       />
+                                       ng-required="attribute.mandatory"/>
+                                </div>
+                                <div ng-if="selectedProgramForRelative">
+                                    <div ng-if="!selectedProgramForRelative.dataEntryMethod || optionSets.optionSets[attribute.optionSet.id].options.length >= 7">
+                                        <input type="text" 
+                                           name="foo"
+                                           class="form-control"
+                                           ng-model="attribute.value"                                                 
+                                           typeahead="option.name as option.name for option in optionSets.optionSets[attribute.optionSet.id].options | filter:$viewValue | limitTo:20" 
+                                           typeahead-open-on-focus
+                                           typeahead-editable=false
+                                           ng-required="attribute.mandatory"/>
+                                    </div>
+                                    <div ng-if="selectedProgramForRelative.dataEntryMethod && optionSets.optionSet[attribute.optionSet.id].options.length < 7">
+                                        <label>                                        
+                                            <input type="radio"
+                                                name={{attribute.id}}
+                                                ng-required="attribute.mandatory"
+                                                ng-model="attribute.value"
+                                                value=""> {{'no_value' | translate}}<br>                                       
+                                        </label><br>
+                                        <span ng-repeat="option in optionSets.optionSets[attribute.optionSet.id].options">
+                                            <label>
+                                                <input type="radio"
+                                                    name={{attribute.id}}
+                                                    ng-required="attribute.mandatory"
+                                                    ng-model="attribute.value" 
+                                                    value={{option.name}}> {{option.name}}
+                                            </label><br>
+                                        </span>                                            
+                                    </div>
+                                </div>                                
                                 <span ng-show="outerForm.submitted && innerForm.foo.$invalid" class="error">{{'required'| translate}}</span>
                             </div>
                             <div ng-switch-when="number">
                                 <input type="number" name="foo" class="form-control" ng-model="attribute.value" ng-required="attribute.mandatory"/>
                                 <span ng-show="outerForm.submitted && innerForm.foo.$invalid" class="error">{{'required'| translate}}</span>
                             </div>
+                            <div ng-switch-when="email">
+                                <input type="email" name="foo" class="form-control" ng-model="attribute.value" ng-required="attribute.mandatory"/>
+                                <span ng-show="outerForm.submitted && innerForm.foo.$invalid" class="error">{{'required'| translate}}</span>
+                            </div>
                             <div ng-switch-default>
                                 <input type="text" name="foo" class="form-control" ng-model="attribute.value" ng-required="attribute.mandatory"/>
                                 <span ng-show="outerForm.submitted && innerForm.foo.$invalid" class="error">{{'required'| translate}}</span>
@@ -83,7 +118,14 @@
                         {{selectedProgramForRelative.dateOfEnrollmentDescription}}
                     </td>
                     <td>
-                        <input type="text" name="dateOfEnrollment" class="form-control" d2-date ng-model="enrollment.incidentDate" ng-required="true"/>
+                        <input type="text" 
+                               name="dateOfEnrollment" 
+                               class="form-control" 
+                               d2-date 
+                               max-date="selectedProgramForRelative.selectEnrollmentDatesInFuture ? '' : 0"
+                               min-date=""
+                               ng-model="enrollment.enrollmentDate" 
+                               ng-required="true"/>
                         <span ng-show="outerForm.submitted && outerForm.dateOfEnrollment.$invalid" class="error">{{'required'| translate}}</span>
                     </td>
                 </tr>     
@@ -92,7 +134,12 @@
                         {{selectedProgramForRelative.dateOfIncidentDescription}}
                     </td>
                     <td>
-                        <input type="text" class="form-control" d2-date ng-model="enrollment.enrollmentDate" />
+                        <input type="text" 
+                               class="form-control" 
+                               d2-date 
+                               max-date="selectedProgramForRelative.selectIncidentDatesInFuture ? '' : 0"
+                               min-date=""
+                               ng-model="enrollment.incidentDate" />
                     </td>
                 </tr>
             </table>

=== 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	2014-10-22 14:22:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js	2014-11-28 14:54:12 +0000
@@ -4,6 +4,7 @@
                 $modal,                
                 $location,
                 $route,
+                $translate,
                 CurrentSelection,
                 RelationshipFactory,
                 TranslationService) {
@@ -13,6 +14,7 @@
     $rootScope.showAddRelationshipDiv = false;
     $scope.relationshipTypes = []; 
     $scope.relationships = [];
+    $scope.addRelationshipLabel = $translate('add');
     RelationshipFactory.getAll().then(function(rels){
         $scope.relationshipTypes = rels;    
         angular.forEach(rels, function(rel){
@@ -23,9 +25,16 @@
     //listen for the selected entity       
     $scope.$on('dashboardWidgets', function(event, args) { 
         $scope.selections = CurrentSelection.get();
-        $scope.selectedTei = angular.copy($scope.selections.tei);
+        $scope.selectedTei = angular.copy($scope.selections.tei);        
         $scope.trackedEntity = $scope.selections.te;
         $scope.selectedEnrollment = $scope.selections.enrollment;
+        $scope.selectedProgram = $scope.selections.pr;
+        if($scope.selectedProgram && $scope.selectedProgram.relationshipText){
+            $scope.addRelationshipLabel = $scope.selectedProgram.relationshipText;
+        }
+        else{
+            $scope.addRelationshipLabel = $translate('add');
+        }
     });
     
     $scope.showAddRelationship = function() {
@@ -86,18 +95,33 @@
             $modalInstance, 
             relationshipTypes,
             selections,
+            DateUtils,
             selectedTei){
     
     $scope.relationshipTypes = relationshipTypes;
-    $scope.selectedTei = selectedTei;
+    $scope.selectedTei = selectedTei;    
+
     $scope.relationshipSources = ['search_from_existing','register_new'];
     $scope.selectedRelationshipSource = {};   
     $scope.relationship = {};
     
     //Selection
     $scope.selectedOrgUnit = storage.get('SELECTED_OU');
-    $scope.selectedTei = selections.tei;
+    $scope.optionSets = selections.optionSets;
     
+    //format tei values
+    $scope.selectedTeiForDisplay = angular.copy($scope.selectedTei);
+    angular.forEach($scope.selectedTeiForDisplay.attributes, function(attribute){
+        if(!angular.isUndefined(attribute.value) && attribute.value !== ''){
+            if(attribute.type === 'date'){   
+                attribute.value = DateUtils.formatFromApiToUser(attribute.value);
+            }
+            if(attribute.type === 'optionSet' && $scope.optionSets.optionNamesByCode[  '"' + attribute.value + '"']){   
+                attribute.value = $scope.optionSets.optionNamesByCode[  '"' + attribute.value + '"'];
+            }
+        }
+    });    
+   
     ProgramFactory.getAll().then(function(programs){
         $scope.programs = [];
         angular.forEach(programs, function(program){                            
@@ -430,9 +454,16 @@
         $scope.valueExists = false;
         var registrationAttributes = [];    
         angular.forEach($scope.attributes, function(attribute){
-            if(!angular.isUndefined(attribute.value)){
-                var att = {attribute: attribute.id, value: attribute.value};
-                registrationAttributes.push(att);
+            var val = attribute.value;
+            if(!angular.isUndefined(val)){
+                
+                if(attribute.valueType === 'date'){
+                    val = DateUtils.formatFromUserToApi(val);
+                }
+                if(attribute.valueType === 'optionSet' && $scope.optionSets.optionCodesByName[  '"' + val + '"']){   
+                    val = $scope.optionSets.optionCodesByName[  '"' + val + '"'];
+                }
+                registrationAttributes.push({attribute: attribute.id, value: val});
                 $scope.valueExists = true;
             } 
         });       

=== 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	2014-09-08 09:08:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship.html	2014-11-28 14:54:12 +0000
@@ -3,7 +3,7 @@
 
         <a href ng-click="showAddRelationship()"><span ng-class="{'light-blue': showAddRelationshipDiv}">{{relationshipWidget.title| translate}}</span></a>
         <span class="nav-pills" ng-if="selectedTei">
-            | <a href ng-click="showAddRelationship()" title="{{'add_relationship'| translate}}"><span ng-class="{'light-blue': !showAddRelationshipDiv}">{{'add'| translate}}</span></a>
+            | <a href ng-click="showAddRelationship()" title="{{'add_relationship'| translate}}"><span ng-class="{'light-blue': !showAddRelationshipDiv}">{{addRelationshipLabel}}</span></a>
         </span>        
         
         <span class="pull-right">

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-10-23 14:40:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-11-28 14:54:12 +0000
@@ -802,7 +802,7 @@
 }
 
 #ui-datepicker-div, .calendars-popup {
-	z-index: 1000; //has to be greater than bootsrap's modal z-index
+	z-index: 2000; //has to be greater than bootsrap's modal z-index
 }
 
 @media print {