← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17244: tracker capture - some fixes to make datepicker play nice with bootstrap dropdown; use of option ...

 

------------------------------------------------------------
revno: 17244
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-23 16:40:31 +0200
message:
  tracker capture - some fixes to make datepicker play nice with bootstrap dropdown; use of option name/code in attributes used for searching
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js
  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/tracker-capture.js
  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/views/home.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/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-10-22 14:22:06 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-10-23 14:40:31 +0000
@@ -159,34 +159,22 @@
 
         if($scope.selectedProgram){
             AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
-                $scope.attributesLighter = [];
-                $scope.attributes = [];
-                
+                $scope.attributes = atts;
                 setTimeout(function () {
                     $scope.$apply(function () {                        
-                        angular.forEach(atts, function(att){
-                            $scope.attributesLighter.push({id: att.id, name: att.name, type: att.valueType, displayInListNoProgram: att.displayInListNoProgram});
-                            $scope.attributes[att.id] = att;
-                        });
-                        $scope.attributesLighter = $scope.generateAttributeFilters($scope.attributesLighter);
-                        $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributesLighter, $scope.selectedOuMode.name);
+                        $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
+                        $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name);
                     });
                 }, 100);
             });           
         }
         else{            
             AttributesFactory.getWithoutProgram().then(function(atts){
-                $scope.attributesLighter = [];
-                $scope.attributes = [];
-                
+                $scope.attributes = atts;
                 setTimeout(function () {
-                    $scope.$apply(function () {
-                        angular.forEach(atts, function(att){
-                            $scope.attributesLighter.push({id: att.id, name: att.name, type: att.valueType, displayInListNoProgram: att.displayInListNoProgram});
-                            $scope.attributes[att.id] = att;
-                        });
-                        $scope.attributesLighter = $scope.generateAttributeFilters($scope.attributesLighter);
-                        $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributesLighter, $scope.selectedOuMode.name);
+                    $scope.$apply(function () {                        
+                        $scope.attributes = $scope.generateAttributeFilters($scope.attributes);
+                        $scope.gridColumns = TEIGridService.generateGridColumns($scope.attributes, $scope.selectedOuMode.name);
                     });
                 }, 100);
             });
@@ -195,7 +183,6 @@
    
     //$scope.searchParam = {bools: []};
     $scope.search = function(mode){
-        
         $scope.teiFetched = false;
         $scope.selectedSearchMode = mode;
         $scope.emptySearchText = false;
@@ -226,14 +213,14 @@
             }       
  
             $scope.queryUrl = 'query=' + $scope.searchText;            
-            $scope.attributesLighter = EntityQueryFactory.resetAttributesQuery($scope.attributesLighter, $scope.enrollment);
+            $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
         }
         
         if( $scope.selectedSearchMode === $scope.searchMode.attributeBased ){
             
             $scope.searchText = '';
             
-            $scope.attributeUrl = EntityQueryFactory.getAttributesQuery($scope.attributesLighter, $scope.enrollment);
+            $scope.attributeUrl = EntityQueryFactory.getAttributesQuery($scope.attributes, $scope.enrollment);
             
             if(!$scope.attributeUrl.hasValue && !$scope.selectedProgram){
                 $scope.emptySearchAttribute = true;
@@ -246,7 +233,7 @@
         if( $scope.selectedSearchMode === $scope.searchMode.listAll ){
             $scope.searchText = '';
             
-            $scope.attributesLighter = EntityQueryFactory.resetAttributesQuery($scope.attributesLighter, $scope.enrollment);
+            $scope.attributes = EntityQueryFactory.resetAttributesQuery($scope.attributes, $scope.enrollment);
         }
         
         $scope.fetchTeis();

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js	2014-10-14 22:43:48 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js	2014-10-23 14:40:31 +0000
@@ -166,13 +166,14 @@
                 calendar: calendar, 
                 renderer: $.calendars.picker.themeRollerRenderer,
                 onSelect: function(date) {
-                    //scope.date = date;
+                    //scope.date = date;                    
                     ctrl.$setViewValue(date);
                     $(this).change();                    
                     scope.$apply();
                 }
             })
-            .change(function() {                
+            .change(function() {
+                
                 var rawDate = this.value;
                 var convertedDate = DateUtils.format(this.value);
 
@@ -188,7 +189,7 @@
                     ctrl.$setValidity('foo', true);                    
                     scope.$apply();     
                 }
-            });    
+            });
         }      
     };   
 })

=== 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	2014-10-22 15:36:30 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-10-23 14:40:31 +0000
@@ -333,16 +333,14 @@
         
         get: function(entityUid) {
             var promise = $http.get(  '../api/trackedEntityInstances/' +  entityUid ).then(function(response){     
-                var tei = response.data;
+                return response.data;
                 
-                angular.forEach(tei.attributes, function(attribute){                   
-                   if(attribute.type && attribute.value){                       
-                       if(attribute.type === 'date'){                           
-                           attribute.value = DateUtils.format(attribute.value);
-                       }
+                /*angular.forEach(tei.attributes, function(attribute){                   
+                   if(attribute.type && attribute.value && attribute.type=== 'date'){                       
+                        attribute.value = DateUtils.format(attribute.value);                        
                    } 
                 });
-                return tei;
+                return tei;*/
             });            
             return promise;
         },        
@@ -663,7 +661,7 @@
     };  
 })
 
-.service('EntityQueryFactory', function(OperatorFactory){  
+.service('EntityQueryFactory', function(OperatorFactory, DateUtils){  
     
     this.getAttributesQuery = function(attributes, enrollment){
 
@@ -671,22 +669,31 @@
         
         angular.forEach(attributes, function(attribute){           
 
-            if(attribute.type === 'date' || attribute.type === 'number'){
+            if(attribute.valueType === 'date' || attribute.valueType === 'number'){
                 var q = '';
                 
                 if(attribute.operator === OperatorFactory.defaultOperators[0]){
                     if(attribute.exactValue && attribute.exactValue !== ''){
-                        query.hasValue = true;    
+                        query.hasValue = true;
+                        if(attribute.valueType === 'date'){
+                            attribute.exactValue = DateUtils.formatFromUserToApi(attribute.exactValue);
+                        }
                         q += 'EQ:' + attribute.exactValue + ':';
                     }
                 }                
                 if(attribute.operator === OperatorFactory.defaultOperators[1]){
                     if(attribute.startValue && attribute.startValue !== ''){
-                        query.hasValue = true;    
+                        query.hasValue = true;
+                        if(attribute.valueType === 'date'){
+                            attribute.startValue = DateUtils.formatFromUserToApi(attribute.startValue);
+                        }
                         q += 'GT:' + attribute.startValue + ':';
                     }
                     if(attribute.endValue && attribute.endValue !== ''){
-                        query.hasValue = true;    
+                        query.hasValue = true;
+                        if(attribute.valueType === 'date'){
+                            attribute.endValue = DateUtils.formatFromUserToApi(attribute.endValue);
+                        }
                         q += 'LT:' + attribute.endValue + ':';
                     }
                 }                
@@ -743,17 +750,17 @@
             if(enrollment.operator === OperatorFactory.defaultOperators[0]){
                 if(enrollment.programExactDate && enrollment.programExactDate !== ''){
                     query.hasValue = true;
-                    q += '&programStartDate=' + enrollment.programExactDate + '&programEndDate=' + enrollment.programExactDate;
+                    q += '&programStartDate=' + DateUtils.formatFromUserToApi(enrollment.programExactDate) + '&programEndDate=' + DateUtils.formatFromUserToApi(enrollment.programExactDate);
                 }
             }
             if(enrollment.operator === OperatorFactory.defaultOperators[1]){
                 if(enrollment.programStartDate && enrollment.programStartDate !== ''){                
                     query.hasValue = true;
-                    q += '&programStartDate=' + enrollment.programStartDate;
+                    q += '&programStartDate=' + DateUtils.formatFromUserToApi(enrollment.programStartDate);
                 }
                 if(enrollment.programEndDate && enrollment.programEndDate !== ''){
                     query.hasValue = true;
-                    q += '&programEndDate=' + enrollment.programEndDate;
+                    q += '&programEndDate=' + DateUtils.formatFromUserToApi(enrollment.programEndDate);
                 }
             }            
             if(q){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2014-10-22 15:02:50 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2014-10-23 14:40:31 +0000
@@ -151,7 +151,10 @@
     
     $('#searchDropDown').on('click', "[data-stop-propagation]", function(e) {
         e.stopPropagation();
-    });   
+    });
+    
+    //stop date picker's event bubling
+    $(document).on('click.dropdown touchstart.dropdown.data-api', '#ui-datepicker-div', function (e) { e.stopPropagation() });
 
 });
 

=== 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-13 14:47:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-10-23 14:40:31 +0000
@@ -801,6 +801,10 @@
     height: inherit;  //this is to make it play nice with bootstrap
 }
 
+#ui-datepicker-div, .calendars-popup {
+	z-index: 1000; //has to be greater than bootsrap's modal z-index
+}
+
 @media print {
     #header, #leftBar, .not-printable {
         display: none;

=== 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	2014-10-22 11:46:33 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html	2014-10-23 14:40:31 +0000
@@ -83,7 +83,7 @@
                     <button class="btn btn-default search-dropdown-button trim" type="button" title="{{'advanced_search'| translate}}" data-toggle="dropdown" ng-click="showHideSearch()" ng-disabled="showRegistrationDiv || showReportDiv"><i class="fa fa-caret-down"></i></button>
                     <button class="btn btn-primary trim" type="button" title="{{'search'| translate}}" ng-disabled="showRegistrationDiv || showReportDiv" ng-click="search(searchMode.freeText)"><i class="fa fa-search"></i></button>
                     <div id="searchDropDown" class="dropdown-menu dropdown-menu-right">
-                        <form ng-submit="search(searchMode.attributeBased)">
+                        <form name="searchForm">
                             <div class="search-container-main">
                                 <div class="search-container">    
                                     <table data-stop-propagation="true" class="table-borderless table-striped">
@@ -105,7 +105,7 @@
                                                         </select>
                                                     </div>
                                                     <div class="filter-value" ng-show="enrollment.operator === defaultOperators[0]">
-                                                        <input type="text" placeholder="{{'exact_date'| translate}}" class="form-control-select2" d2-date ng-model="enrollment.programExactDate"/>
+                                                        <input type="text" placeholder="{{'exact_date'| translate}}" class="form-control-select2" d2-date max-date="0" ng-model="enrollment.programExactDate"/>
                                                     </div>
                                                     <div class="filter-value" ng-show="enrollment.operator === defaultOperators[1]">
                                                         <div class="container-1-2">
@@ -118,12 +118,12 @@
                                                 </div>                
                                             </td>
                                         </tr>
-                                        <tr ng-repeat="attribute in attributesLighter">
+                                        <tr ng-repeat="attribute in attributes">
                                             <td>
                                                 {{attribute.name}}
                                             </td>
                                             <td>
-                                                <div ng-switch="attribute.type">
+                                                <div ng-switch="attribute.valueType">
                                                     <div ng-switch-when="number">
                                                         <div class="dataelement-filter">                                                
                                                             <div class="filter-operator">
@@ -164,7 +164,7 @@
                                                     </div>                        
                                                     <div ng-switch-when="optionSet">
                                                         <select multiple ui-select2  ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
-                                                            <option ng-repeat="option in attributes[attribute.id].optionSet.options | filter:$viewValue | limitTo:100" value="{{option.code}}">{{option.name}}</option>
+                                                            <option ng-repeat="option in optionSets.optionSets[attribute.optionSet.id].options | filter:$viewValue | limitTo:100" value="{{option.code}}">{{option.name}}</option>
                                                         </select>
                                                     </div>
                                                     <div ng-switch-when="bool">
@@ -182,7 +182,7 @@
                                 </div>
 
                                 <div class="horizonal-spacing">
-                                    <button type="submit"
+                                    <button type="button"
                                             class="btn btn-primary"
                                             ng-click="search(searchMode.attributeBased)">
                                         {{'search'| translate}}