← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19485: event-capture: program indicators are now available during data entry

 

------------------------------------------------------------
revno: 19485
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-06-22 10:45:36 +0200
message:
  event-capture: program indicators are now available during data entry
added:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/buttons-section.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/comments-section.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/indicators-section.html
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties
  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/views/defaultForm.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.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-tracker-capture/components/dataentry/dataentry-controller.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.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/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties	2015-06-15 11:04:20 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties	2015-06-22 08:45:36 +0000
@@ -140,4 +140,5 @@
 unsaved_data_exists_proceed=Unsaved data exists. Do you want to proceed?
 proceed=Proceed
 lacking_required_authority_to_add_update_event=Lacking required authority to add/update event.
-select_or_search=Select or search from the list
\ No newline at end of file
+select_or_search=Select or search from the list
+indicators=Indicators
\ No newline at end of file

=== 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-06-18 10:33:59 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-06-22 08:45:36 +0000
@@ -105,6 +105,7 @@
         $scope.resetOu = false;
         $scope.selectedProgramStage = null;
         $scope.programValidations = [];
+        $scope.programIndicators = [];
         $scope.dhis2Events = [];
         $scope.currentEvent = {};
         $scope.currentEventOriginialValue = {};
@@ -194,7 +195,10 @@
 
                 MetaDataFactory.getByProgram('programValidations', $scope.selectedProgram.id).then(function(pvs){
                     $scope.programValidations = pvs;
-                    $scope.loadEvents();
+                    MetaDataFactory.getByProgram('programIndicators', $scope.selectedProgram.id).then(function(pis){
+                        $scope.programIndicators = pis;
+                        $scope.loadEvents();
+                    });                    
                 });
             });
         }
@@ -945,9 +949,14 @@
     });
     
     $scope.executeRules = function() {
+        $scope.currentEvent.event = !$scope.currentEvent.event ? 'SINGLE_EVENT' : $scope.currentEvent.event;
         $scope.eventsByStage = [];
         $scope.eventsByStage[$scope.selectedProgramStage.id] = [$scope.currentEvent];
-        TrackerRulesExecutionService.executeRules($scope.selectedProgram.id,$scope.currentEvent,$scope.eventsByStage,$scope.prStDes,null);
+        TrackerRulesExecutionService.executeRules($scope.selectedProgram.id,$scope.currentEvent,$scope.eventsByStage,$scope.prStDes,null,false);
+    };
+    
+    $scope.formatNumberResult = function(val){        
+        return dhis2.validation.isNumber(val) ? val : '';
     };
     
     //check if field is hidden

=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/buttons-section.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/buttons-section.html	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/buttons-section.html	2015-06-22 08:45:36 +0000
@@ -0,0 +1,12 @@
+<div style="clear: both;">                        
+    <span ng-if="editingEventInFull">
+        <button type="button" ng-click="updateEvent()" class="button hideInPrint">{{'update'| translate}}</button>
+        <button type="button" ng-click="cancel()" class="button hideInPrint">{{'cancel'| translate}}</button>
+    </span>
+    <span ng-if="eventRegistration">
+        <button type="button" ng-disabled="disableSaveAndAddNew" ng-click="addEvent(true)" class="button hideInPrint">{{'save_and_add_new'| translate}}</button>
+        <button type="button" ng-click="addEvent()" class="button hideInPrint">{{'save_and_back'| translate}}</button>
+        <button type="button" ng-click="cancel()" class="button hideInPrint">{{'cancel'| translate}}</button>
+    </span>
+    <br><span ng-if="isFormInvalid()" class="horizontal-spacing red">{{'form_invalid' | translate}}</span>
+</div>
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/comments-section.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/comments-section.html	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/comments-section.html	2015-06-22 08:45:36 +0000
@@ -0,0 +1,24 @@
+<div class="clear">
+    <div class="vertical-spacing section-label">
+        {{'comments'| translate}}
+    </div>
+    <textarea class="small-vertical-spacing" rows="3" ng-model="note.value" placeholder="{{'add_your_comment_here'| translate}}" style="width:100%;"></textarea>
+    <div ng-if="currentEvent.notes">
+        <table class="listTable dhis2-list-table-striped">
+            <thead>
+                <tr>
+                    <th style="width:100%;">
+                        {{'recorded_comments'| translate}}
+                    </th>
+                </tr>
+            </thead>
+            <tr ng-repeat="note in currentEvent.notes">
+                <td class="over-flow-hidden" style="width:100%;">
+                    <p>{{note.value}}</p>
+                    <p><strong>{{'created_by'| translate}}: </strong>{{note.storedBy}}</p>
+                    <p><strong>{{'date'| translate}}: </strong>{{note.storedDate}}</p>                    
+                </td>
+            </tr>
+        </table>  
+    </div>    
+</div>
\ No newline at end of file

=== 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-06-17 11:50:16 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html	2015-06-22 08:45:36 +0000
@@ -409,42 +409,6 @@
 
 </div>
 
-<!-- comment section starts -->
-<h4>
-    {{'comments'| translate}}
-</h4>
-<textarea rows="3" ng-model="note.value" placeholder="{{'add_your_comment_here'| translate}}" class="form-control"></textarea>
-<div ng-if="currentEvent.notes">    
-    <table class="listTable dhis2-list-table-striped"> 
-        <thead>
-            <tr>
-                <th style="width:100%;">
-                    {{'recorded_comments' | translate}}
-                </th>
-            </tr>
-        </thead>
-        <tr ng-repeat="note in currentEvent.notes">
-            <td class="over-flow-hidden" style="width:100%;">
-                <p>{{note.value}}</p>
-                <p><strong>{{'created_by' | translate}}: </strong>{{note.storedBy}}</p>
-                <p><strong>{{'date' | translate}}: </strong>{{note.storedDate}}</p>                    
-            </td>
-        </tr>
-    </table>
-</div>
-<!-- comment section ends -->
-
-<!-- buttons for event registration / update begins -->
-<div style="clear: both;">                        
-    <span ng-if="editingEventInFull">
-        <button type="button" ng-click="updateEvent()" class="button hideInPrint">{{'update'| translate}}</button>
-        <button type="button" ng-click="cancel()" class="button hideInPrint">{{'cancel'| translate}}</button>
-    </span>
-    <span ng-if="eventRegistration">
-        <button type="button" ng-disabled="disableSaveAndAddNew" ng-click="addEvent(true)" class="button hideInPrint">{{'save_and_add_new'| translate}}</button>
-        <button type="button" ng-click="addEvent()" class="button hideInPrint">{{'save_and_back'| translate}}</button>
-        <button type="button" ng-click="cancel()" class="button hideInPrint">{{'cancel'| translate}}</button>        
-    </span>    
-    <br><span ng-if="isFormInvalid()" class="horizontal-spacing red">{{'form_invalid' | translate}}</span>    
-</div>
-<!-- buttons for event registration / update ends --
+<div ng-if="programIndicators.length > 0" ng-include="'views/indicators-section.html'"></div>
+<div ng-include="'views/comments-section.html'"></div>
+<div ng-include="'views/buttons-section.html'"></div>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html	2015-06-10 11:58:22 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/ec-custom-form.html	2015-06-22 08:45:36 +0000
@@ -59,44 +59,6 @@
     </tr>
 </table>
 <div ng-include="'../dhis-web-commons/angular-forms/custom-form.html'"></div>
-
-<div class="clear">
-    <hr>
-    <h4>
-        {{'comments'| translate}}
-    </h4>
-    <textarea rows="3" ng-model="note.value" placeholder="{{'add_your_comment_here'| translate}}" style="width:50%;"></textarea>
-    <div ng-if="currentEvent.notes">
-        <table class="listTable dhis2-list-table-striped" style='width: 50%;'>
-            <thead>
-                <tr>
-                    <th style="width:100%;">
-                        {{'recorded_comments'| translate}}
-                    </th>
-                </tr>
-            </thead>
-            <tr ng-repeat="note in currentEvent.notes">
-                <td class="over-flow-hidden" style="width:100%;">
-                    <p>{{note.value}}</p>
-                    <p><strong>{{'created_by'| translate}}: </strong>{{note.storedBy}}</p>
-                    <p><strong>{{'date'| translate}}: </strong>{{note.storedDate}}</p>                    
-                </td>
-            </tr>
-        </table>  
-    </div>    
-</div>
-
-<!-- buttons for event registration / update begins -->
-<div style="clear: both;">                        
-    <span ng-if="editingEventInFull">
-        <button type="button" ng-click="updateEvent()" class="button hideInPrint">{{'update'| translate}}</button>
-        <button type="button" ng-click="cancel()" class="button hideInPrint">{{'cancel'| translate}}</button>
-    </span>
-    <span ng-if="eventRegistration">
-        <button type="button" ng-disabled="disableSaveAndAddNew" ng-click="addEvent(true)" class="button hideInPrint">{{'save_and_add_new'| translate}}</button>
-        <button type="button" ng-click="addEvent()" class="button hideInPrint">{{'save_and_back'| translate}}</button>
-        <button type="button" ng-click="cancel()" class="button hideInPrint">{{'cancel'| translate}}</button>
-    </span>
-    <br><span ng-if="isFormInvalid()" class="horizontal-spacing red">{{'form_invalid' | translate}}</span>
-</div>
-<!-- buttons for event registration / update ends -->
\ No newline at end of file
+<div ng-if="programIndicators.length > 0" ng-include="'views/indicators-section.html'"></div>
+<div ng-include="'views/comments-section.html'" style="width: 50%;"></div>
+<div ng-include="'views/buttons-section.html'"></div>
\ No newline at end of file

=== 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-11 11:18:14 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html	2015-06-22 08:45:36 +0000
@@ -88,9 +88,11 @@
                     <span ng-if="eventRegistration">{{'new_event'| translate}}</span>                            
                 </h3>
                 <div class="bordered-div" ng-if="displayCustomForm">
+                    <!--<div ng-if="programIndicators.length > 0" ng-include="'views/indicators.html'"></div>-->
                     <div ng-include="'views/ec-custom-form.html'"></div>  
                 </div>
                 <div class="bordered-div container-default-form" ng-if="!displayCustomForm">
+                    <!--<div ng-if="programIndicators.length > 0" ng-include="'views/indicators.html'"></div>-->
                     <div ng-include="'views/defaultForm.html'"></div>                
                 </div>
             </div>

=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/indicators-section.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/indicators-section.html	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/indicators-section.html	2015-06-22 08:45:36 +0000
@@ -0,0 +1,13 @@
+<div class="section-label">
+    {{'indicators' | translate}}
+</div>
+<table class="dhis2-list-table-striped">
+    <tr ng-repeat="pid in programIndicators">
+        <td>
+            {{pid.name}}
+        </td>
+        <td>
+            <input type="text" class="form-control" value={{formatNumberResult(ruleeffects[currentEvent.event][pid.id].data)}} ng-disabled="true">
+        </td>
+    </tr>
+</table>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-06-21 22:18:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-06-22 08:45:36 +0000
@@ -117,10 +117,10 @@
         //If the events is displayed in a table, it is necessary to run the rules for all visible events.
         if($scope.currentStage.displayEventsInTable) {
            angular.forEach($scope.currentStageEvents, function(event) {
-               TrackerRulesExecutionService.executeRules($scope.selectedProgramId,event,$scope.eventsByStage,$scope.prStDes,$scope.selectedTei,$scope.selectedEnrollment);
+               TrackerRulesExecutionService.executeRules($scope.selectedProgramId,event,$scope.eventsByStage,$scope.prStDes,$scope.selectedTei,$scope.selectedEnrollment,false);
            });
         } else {
-           TrackerRulesExecutionService.executeRules($scope.selectedProgramId,$scope.currentEvent,$scope.eventsByStage,$scope.prStDes,$scope.selectedTei,$scope.selectedEnrollment);
+           TrackerRulesExecutionService.executeRules($scope.selectedProgramId,$scope.currentEvent,$scope.eventsByStage,$scope.prStDes,$scope.selectedTei,$scope.selectedEnrollment,false);
         }
     };
     

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-06-21 22:18:40 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2015-06-22 08:45:36 +0000
@@ -888,8 +888,11 @@
                     //add context variables:
                     //last parameter "valuefound" is always true for event date
                     pushVariable('incident_date', executingEvent.eventDate, 'date', true, 'V' );
-                    pushVariable('enrollment_date', selectedEnrollment.dateOfEnrollment, 'date', true, 'V' );
                     pushVariable('current_date', DateUtils.getToday(), 'date', true, 'V' );
+                    if(selectedEnrollment){
+                        pushVariable('enrollment_date', selectedEnrollment.dateOfEnrollment, 'date', true, 'V' );
+                    }
+                    
                     //pushVariable('value_count', executingEvent.eventDate, 'date', true, 'V' );
                     //pushVariable('zero_pos_value_count', executingEvent.eventDate, 'date', true, 'V' );
 
@@ -910,11 +913,10 @@
 /* service for executing tracker rules and broadcasting results */
 .service('TrackerRulesExecutionService', function(TrackerRulesFactory, MetaDataFactory, VariableService, $rootScope, $log, $q, $filter, orderByFilter){
     return {
-        executeRules: function(programid, executingEvent, allEventsByStage, allDataElements, selectedEntity, selectedEnrollment ) {
+        executeRules: function(programid, executingEvent, allEventsByStage, allDataElements, selectedEntity, selectedEnrollment, verbose ) {
             //When debugging rules, the caller should provide a variable for wether or not the rules is being debugged.
             //hard coding this for now:
             var debug = true;
-            var verbose = true;
             
             var variablesHash = {};
             
@@ -1293,4 +1295,4 @@
             });
         }
     };
-});
+});
\ No newline at end of file