← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19847: event-capture: some performance improvment

 

------------------------------------------------------------
revno: 19847
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-08-25 16:54:19 +0200
message:
  event-capture: some performance improvment
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/selections.html
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js


--
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-event-capture/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/app.js	2015-07-13 07:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/app.js	2015-08-25 14:54:19 +0000
@@ -17,7 +17,6 @@
                     'd2Services',
                     'd2Controllers',
                     'ui.select',
-                    'infinite-scroll',
                     'angularLocalStorage',
                     'pascalprecht.translate',
                     'd2HeaderBar'])

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-07-17 07:28:57 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-08-25 14:54:19 +0000
@@ -11,6 +11,7 @@
                 $scope,
                 $modal,
                 $timeout,
+                $translate,
                 $anchorScroll,
                 orderByFilter,
                 SessionStorageService,
@@ -73,6 +74,15 @@
     $scope.$watch('selectedOrgUnit', function() {
         
         if(angular.isObject($scope.selectedOrgUnit)){
+            
+            $scope.pleaseSelectLabel = $translate.instant('please_select');
+            $scope.registeringUnitLabel = $translate.instant('registering_unit');
+            $scope.eventCaptureLabel = $translate.instant('event_capture');
+            $scope.programLabel = $translate.instant('program');
+            $scope.searchLabel = $translate.instant('search');
+            $scope.yesLabel = $translate.instant('yes');
+            $scope.noLabel = $translate.instant('no');
+            
             SessionStorageService.set('SELECTED_OU', $scope.selectedOrgUnit);
             
             $scope.userAuthority = AuthorityService.getUserAuthorities(SessionStorageService.get('USER_ROLES'));
@@ -258,7 +268,8 @@
                                         //converting int string value to number for proper sorting.
                                         if($scope.prStDes[dataValue.dataElement].dataElement.type === 'int'){
                                             if( dhis2.validation.isNumber(val)  ){
-                                                val = new Number(val);
+                                                //val = new Number(val);
+                                                val = parseFloat(val, 10);
                                             }                                
                                         }
                                         if($scope.prStDes[dataValue.dataElement].dataElement.optionSetValue){                                            
@@ -272,6 +283,11 @@
                                         if($scope.prStDes[dataValue.dataElement].dataElement.type === 'date'){
                                             val = DateUtils.formatFromApiToUser(val);                                               
                                         }
+                                        
+                                        if($scope.prStDes[dataValue.dataElement].dataElement.type === 'bool'){
+                                            val = val === 'true' ? $scope.yesLabel : $scope.noLabel;                                
+                                        }
+                                        
                                         if( $scope.prStDes[dataValue.dataElement].dataElement.type === 'trueOnly'){
                                             if(val === 'true'){
                                                 val = true;
@@ -301,8 +317,7 @@
                     if(!$scope.sortHeader.id){
                         $scope.sortEventGrid({name: $scope.selectedProgramStage.reportDateDescription ? $scope.selectedProgramStage.reportDateDescription : 'incident_date', id: 'event_date', type: 'date', compulsory: false, showFilter: false, show: true});
                     }
-                }     
-                
+                }
                 
                 $scope.eventFetched = true;
             });
@@ -421,7 +436,8 @@
         }
     };
     
-    $scope.showEventList = function(){
+    $scope.showEventList = function(dhis2Event){        
+        ContextMenuSelectedItem.setSelectedItem(dhis2Event);
         $scope.eventRegistration = false;
         $scope.editingEventInFull = false;
         $scope.editingEventInGrid = false;
@@ -682,7 +698,6 @@
     };
        
     $scope.updateEventDataValue = function(currentEvent, dataElement){
-
         $scope.updateSuccess = false;
         
         //get current element

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js	2015-08-07 16:01:27 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js	2015-08-25 14:54:19 +0000
@@ -123,6 +123,10 @@
             if( program.userRoles.hasOwnProperty( userRoles[i].id ) ){
                 hasRole = true;
             }
+            
+            if(!hasRole && userRoles[i].authorities && userRoles[i].authorities.indexOf('ALL') !== -1){
+                hasRole = true;
+            }
         }        
         return hasRole;        
     };

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html	2015-08-24 10:27:24 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html	2015-08-25 14:54:19 +0000
@@ -151,7 +151,7 @@
                                         input-field-id={{eventGridColumn.id}} 
                                         ng-change="saveDatavalue()" 
                                         class="form-control">
-                                <option value="">{{'please_select'| translate}}</option>                        
+                                <option value="">{{pleaseSelectLabel}}</option>                        
                                 <option value="false">{{'no'| translate}}</option>
                                 <option value="true">{{'yes'| translate}}</option>
                                 </select>
@@ -370,7 +370,7 @@
                                             input-field-id={{de.dataElement.id}} 
                                             ng-change="saveDatavalue()" 
                                             class="form-control">
-                                    <option value="">{{'please_select'| translate}}</option>                        
+                                    <option value="">{{pleaseSelectLabel}}</option>                        
                                     <option value="false">{{'no'| translate}}</option>
                                     <option value="true">{{'yes'| translate}}</option>
                                     </select>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html	2015-08-07 16:54:38 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html	2015-08-25 14:54:19 +0000
@@ -38,10 +38,7 @@
                 <table class="listTable dhis2-table-striped-border dhis2-table-hover">
                     <thead>                        
                         <tr>
-                            <th ng-show="eventGridColumn.show" 
-
-                                ng-repeat="eventGridColumn in eventGridColumns">
-                                
+                            <th ng-repeat="eventGridColumn in eventGridColumns | filter: {show: true}">                                
                                 <span ng-if="eventGridColumn.id !== 'comment'">
                                     
                                     <!-- sort icon begins -->                                
@@ -55,10 +52,10 @@
                                     <!-- filter icon begins -->
                                     <span class='pull-right hideInPrint'>
                                         <span ng-show="eventGridColumn.type !='date' && eventGridColumn.type !='int'">
-                                            <a href ng-click="searchInGrid(eventGridColumn)" title="{{'search'| translate}}"><span ng-class="{true: 'filter-without-content', false: 'filter-with-content'} [filterText[eventGridColumn.id] == undefined || filterText[eventGridColumn.id] == '']"><i class="fa fa-search"></i></span></a>
+                                            <a href ng-click="searchInGrid(eventGridColumn)" title="{{searchLabel}}"><span ng-class="{true: 'filter-without-content', false: 'filter-with-content'} [filterText[eventGridColumn.id] == undefined || filterText[eventGridColumn.id] == '']"><i class="fa fa-search"></i></span></a>
                                         </span>
                                         <span ng-show="eventGridColumn.type ==='date' || eventGridColumn.type ==='int'">
-                                            <a href ng-click="searchInGrid(eventGridColumn)" title="{{'search'| translate}}"><span ng-class="{true: 'filter-without-content', false: 'filter-with-content'} [(filterText[eventGridColumn.id].start == undefined || filterText[eventGridColumn.id].start == '') && (filterText[eventGridColumn.id].end == undefined || filterText[eventGridColumn.id].end == '')]"><i class="fa fa-search"></i></span></a>
+                                            <a href ng-click="searchInGrid(eventGridColumn)" title="{{searchLabel}}"><span ng-class="{true: 'filter-without-content', false: 'filter-with-content'} [(filterText[eventGridColumn.id].start == undefined || filterText[eventGridColumn.id].start == '') && (filterText[eventGridColumn.id].end == undefined || filterText[eventGridColumn.id].end == '')]"><i class="fa fa-search"></i></span></a>
                                         </span>                                                    
                                     </span>
                                     <!-- filter icon ends -->
@@ -94,19 +91,17 @@
                         </tr>                        
                     </thead>
                     <tbody id="list">
-                        <tr title="{{'click_for_action' | translate}}" ng-repeat="dhis2Event in dhis2Events | orderBy:d2Sort:reverse | gridFilter:filterText:filterTypes">
-                           
-                            <td ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.show">
+                        <tr title="{{'click_for_action' | translate}}" ng-repeat="dhis2Event in dhis2Events | orderBy:d2Sort:reverse | gridFilter:filterText:filterTypes">                           
+                            <td ng-repeat="eventGridColumn in eventGridColumns | filter: {show: true}">
                                 
-                                <!-- Visible when event is not under editing -->
+                                <!-- Visible when event is not under editing -->                                
                                 <div d2-context-menu 
-                                    selected-item={{dhis2Event}}
-                                    ng-click="showEventList()"
-                                    ng-show="currentEvent.event !== dhis2Event.event && eventGridColumn.id !== 'comment'">
+                                    ng-click="showEventList(dhis2Event)"
+                                    ng-show="currentEvent.event !== dhis2Event.event && eventGridColumn.id !== 'comment'">                                    
                                     <span ng-switch="eventGridColumn.type">
                                         <span ng-switch-when="bool">
-                                            <span ng-if="dhis2Event[eventGridColumn.id] == 'false'">{{'no'| translate}}</span>
-                                            <span ng-if="dhis2Event[eventGridColumn.id] == 'true'">{{'yes'| translate}}</span>
+                                            <span ng-if="dhis2Event[eventGridColumn.id] == 'false'">{{noLabel}}</span>
+                                            <span ng-if="dhis2Event[eventGridColumn.id] == 'true'">{{yesLabel}}</span>
                                         </span>
                                         <span ng-switch-default>
                                             <span ng-if="dhis2Event[eventGridColumn.id]">
@@ -116,14 +111,14 @@
                                                 &nbsp;
                                             </span>
                                         </span>
-                                    </span>                                
+                                    </span>
                                 </div>
                                 <!-- Visible when event is not under editing -->
                                 
                                 
                                 <!-- Visible when event is under editing in grid -->
                                 <div style="cursor:default;"
-                                    ng-if="(currentEvent.event == dhis2Event.event) && eventGridColumn.show && eventGridColumn.id !== 'comment'">
+                                    ng-if="(currentEvent.event == dhis2Event.event) && eventGridColumn.id !== 'comment'">
                                     <ng-form name="innerFormGrid">
                                         <div ng-if="eventGridColumn.id === 'uid'">
                                             <input type="text"
@@ -195,6 +190,7 @@
                                                         <textarea rows="3"
                                                             ng-model="currentEvent[eventGridColumn.id]"                                        
                                                             ng-required={{eventGridColumn.compulsory}}
+                                                            ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
                                                             name="foo" 
                                                             input-field-id={{eventGridColumn.id}} 
                                                             ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
@@ -206,8 +202,9 @@
                                                         <input type="text"
                                                                ng-model="currentEvent[eventGridColumn.id]" 
                                                                ng-required={{eventGridColumn.compulsory}}
+                                                               ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
                                                                name="foo" 
-                                                               class="form-control"/>                                                    
+                                                               class="form-control"/>
                                                     </div>                                                    
                                                 </div>                                        
                                                 <div ng-switch-when="bool">
@@ -219,9 +216,9 @@
                                                             style="width:98%;"
                                                             ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
                                                             ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]">
-                                                        <option value="">{{'please_select'| translate}}</option>                        
-                                                        <option value="false">{{'no'| translate}}</option>
-                                                        <option value="true">{{'yes'| translate}}</option>
+                                                        <option value="">{{pleaseSelectLabel}}</option>                        
+                                                        <option value="false">{{noLabel}}</option>
+                                                        <option value="true">{{yesLabel}}</option>
                                                     </select>
                                                 </div>
                                                 <div ng-switch-when="date">

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html	2015-06-22 08:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html	2015-08-25 14:54:19 +0000
@@ -22,17 +22,17 @@
     <div ng-show="selectedOrgUnit && userAuthority.canAddOrUpdateEvent">
         
         <h3>
-            {{'event_capture'| translate}}
+            {{eventCaptureLabel}}
         </h3>
         
         <!-- selection begins-->
         <table>
             <tr>
-                <td><label>{{'registering_unit'| translate}}</label></td>
-                <td><input type="text" class="fixed-width-text" selected-org-unit ng-model="selectedOrgUnit.name" value="{{selectedOrgUnit.name|| 'please_select'| translate}}" disabled="" style="height:14px"></td>                        	                            
+                <td><label>{{registeringUnitLabel}}</label></td>
+                <td><input type="text" class="fixed-width-text" selected-org-unit ng-model="selectedOrgUnit.name" value="{{selectedOrgUnit.name|| pleaseSelectLabel}}" disabled="" style="height:14px"></td>                        	                            
             </tr>
             <tr>
-                <td><label>{{'program'| translate}}</label></td>
+                <td><label>{{programLabel}}</label></td>
                 <td>
                     <select id="programId" 
                             class="fixed-width-select"
@@ -41,7 +41,7 @@
                             ng-options="program as program.name for program in programs | orderBy: 'name'" 
                             ng-change="getProgramDetails()"
                             ng-disabled="eventRegistration || editingEventInFull || editingEventInGrid">
-                        <option value="">{{'please_select'| translate}}</option>
+                        <option value="">{{pleaseSelectLabel}}</option>
                     </select>      
                 </td>
                 <td style='padding-left: 10px;'>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/selections.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/selections.html	2014-06-13 06:12:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/selections.html	2015-08-25 14:54:19 +0000
@@ -1,7 +1,7 @@
 <table>
     <tr>
         <td><label>{{'registering_unit'| translate}}</label></td>
-        <td><input type="text" class="fixed-width-text" selected-org-unit ng-model="selectedOrgUnit.name" value="{{selectedOrgUnit.name|| 'please_select'| translate}}" disabled="" style="height:14px"></td>                        	                            
+        <td><input type="text" class="fixed-width-text" selected-org-unit ng-model="selectedOrgUnit.name" value="{{selectedOrgUnit.name|| pleaseSelectLabel}}" disabled="" style="height:14px"></td>                        	                            
     </tr>
     <tr>
         <td><label>{{'program'| translate}}</label></td>
@@ -13,7 +13,7 @@
                     ng-options="program as program.name for program in programs | orderBy: 'name'" 
                     ng-change="loadEvents()"
                     ng-disabled="eventRegistration || editingEventInFull || editingEventInGrid">
-                <option value="">{{'please_select'| translate}}</option>
+                <option value="">{{pleaseSelectLabel}}</option>
             </select>      
         </td>
         <td style='padding-left: 10px;'>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js	2015-06-02 12:23:22 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js	2015-08-25 14:54:19 +0000
@@ -506,10 +506,7 @@
         link: function (scope, element, attrs) {
             var contextMenu = $("#contextMenu");
 
-            element.click(function (e) {
-                var selectedItem = $.parseJSON(attrs.selectedItem);
-                ContextMenuSelectedItem.setSelectedItem(selectedItem);
-
+            element.click(function (e) {                
                 var menuHeight = contextMenu.height();
                 var menuWidth = contextMenu.width();
                 var winHeight = $(window).height();