← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17886: tracker capture - defined sections are now rendered during data entry

 

------------------------------------------------------------
revno: 17886
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-01-05 17:25:01 +0100
message:
  tracker capture - defined sections are now rendered during data entry
modified:
  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/default-form.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.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-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-01-05 11:39:25 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-01-05 16:25:01 +0000
@@ -297,7 +297,11 @@
         $scope.currentEvent.providedElsewhere = [];
         
         $scope.currentStage = $scope.selectedProgramWithStage[$scope.currentEvent.programStage];
-
+        
+        angular.forEach($scope.currentStage.programStageSections, function(section){
+            section.open = true;
+        });
+        
         $scope.prStDes = [];                  
         angular.forEach($scope.currentStage.programStageDataElements, function(prStDe){
             $scope.prStDes[prStDe.dataElement.id] = prStDe; 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html	2015-01-05 10:20:46 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html	2015-01-05 16:25:01 +0000
@@ -1,5 +1,5 @@
 <form name="dataEntryOuterForm" novalidate>                
-    <table class="table-borderless table-striped" ng-if='currentEvent'>
+    <table class="table-borderless table-striped" ng-if='currentEvent && !currentStage.programStageSections.length'>
         <thead>
             <tr class="col-md-12">
                 <th class="col-md-5">
@@ -127,4 +127,142 @@
             </td>
         </tr>
     </table>
+    
+    <div ng-if='currentEvent && currentStage.programStageSections.length'>
+        <accordion close-others='false'>
+            <accordion-group heading="{{section.name}}" is-open="section.open" ng-repeat='section in currentStage.programStageSections'>
+                <table class="dhis2-list-table-striped">                    
+                    <thead>                        
+                        <tr class="col-md-12">
+                            <th class="col-md-5">
+                                {{'data_element'| translate}}
+                            </th>
+                            <th class="col-md-5 align-center">
+                                {{'value'| translate}}
+                            </th>
+                            <th class="col-md-2 align-center" ng-if="allowProvidedElsewhereExists">
+                                {{'provided_elsewhere'| translate}}
+                            </th>
+                        </tr>                        
+                    </thead>
+                    <tbody id="list">       
+                        <tr class="col-md-12" ng-repeat="de in section.programStageDataElements">
+                            <td class="col-md-5">
+                                {{prStDes[de.dataElement.id].dataElement.formName ? prStDes[de.dataElement.id].dataElement.formName : prStDes[de.dataElement.id].dataElement.name}}
+                            </td>
+                            <td class="col-md-5">
+                                <ng-form name="dataEntryInnerForm">
+                                    <div ng-switch="prStDes[de.dataElement.id].dataElement.type">
+                                        <div ng-switch-when="int">
+                                            <input type="number"
+                                                   ng-class='getInputNotifcationClass(prStDes[de.dataElement.id].dataElement.id,false)'
+                                                   ng-model="currentEvent[prStDes[de.dataElement.id].dataElement.id]" 
+                                                   ng-required={{prStDes[de.dataElement.id].compulsory}}
+                                                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
+                                                   ng-blur="saveDatavalue(prStDes[de.dataElement.id])" 
+                                                   name="foo"/>
+                                            <span ng-show="dataEntryOuterForm.submitted && dataEntryInnerForm.foo.$invalid" class="error">{{'number_required'| translate}}</span>
+                                        </div>                        
+                                        <div ng-switch-when="string">                            
+                                            <div ng-if="prStDes[de.dataElement.id].dataElement.optionSet">
+                                                <div ng-if="!selectedProgram.dataEntryMethod || optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options.length >= 7">
+                                                    <input type="text"
+                                                        ng-class='getInputNotifcationClass(prStDes[de.dataElement.id].dataElement.id,false)'
+                                                        ng-model="currentEvent[prStDes[de.dataElement.id].dataElement.id]" 
+                                                        ng-required={{prStDes[de.dataElement.id].compulsory}} 
+                                                        ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
+                                                        typeahead="option.name as option.name for option in optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options | filter:$viewValue | limitTo:20" 
+                                                        typeahead-open-on-focus 
+                                                        typeahead-editable="false"
+                                                        ng-blur="saveDatavalue(prStDes[de.dataElement.id])" 
+                                                        name="foo"/>
+                                                    <span ng-show="dataEntryOuterForm.submitted && dataEntryInnerForm.foo.$invalid || !currentEvent[prStDes[de.dataElement.id].dataElement.id] && currentElement.id === prStDes[de.dataElement.id].dataElement.id" class="error">{{'invalid'| translate}}</span>
+                                                </div>
+                                                <div ng-if="selectedProgram.dataEntryMethod && optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options.length < 7">
+                                                    <label>                                        
+                                                        <input type="radio"
+                                                            ng-class='getInputNotifcationClass(prStDes[de.dataElement.id].dataElement.id,true)'
+                                                            name={{currentEvent[prStDes[de.dataElement.id].dataElement.id]}}
+                                                            ng-required={{prStDes[de.dataElement.id].compulsory}} 
+                                                            ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
+                                                            ng-model="currentEvent[prStDes[de.dataElement.id].dataElement.id]"
+                                                            ng-change="saveDatavalue(prStDes[de.dataElement.id])" 
+                                                            value=""> {{'no_value' | translate}}<br>                                       
+                                                    </label><br>
+                                                    <span ng-repeat="option in optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options">
+                                                        <label>
+                                                            <input type="radio"
+                                                                ng-class='getInputNotifcationClass(prStDes[de.dataElement.id].dataElement.id,true)'
+                                                                name={{currentEvent[prStDes[de.dataElement.id].dataElement.id]}}
+                                                                ng-required={{prStDes[de.dataElement.id].compulsory}} 
+                                                                ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
+                                                                ng-model="currentEvent[prStDes[de.dataElement.id].dataElement.id]"
+                                                                ng-change="saveDatavalue(prStDes[de.dataElement.id])" 
+                                                                value={{option.name}}> {{option.name}}
+                                                        </label><br>
+                                                    </span>
+                                                </div>                                    
+                                            </div>
+                                            <div ng-if="!prStDes[de.dataElement.id].dataElement.optionSet">
+                                                <input type="text"
+                                                    ng-class='getInputNotifcationClass(prStDes[de.dataElement.id].dataElement.id,false)'
+                                                    ng-model="currentEvent[prStDes[de.dataElement.id].dataElement.id]" 
+                                                    ng-required={{prStDes[de.dataElement.id].compulsory}} 
+                                                    ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
+                                                    ng-blur="saveDatavalue(prStDes[de.dataElement.id])" 
+                                                    name="foo"/>
+                                            </div>
+                                        </div>
+                                        <div ng-switch-when="bool">
+                                            <select ng-class='getInputNotifcationClass(prStDes[de.dataElement.id].dataElement.id,false)'
+                                                    ng-model="currentEvent[prStDes[de.dataElement.id].dataElement.id]" 
+                                                    ng-required={{prStDes[de.dataElement.id].compulsory}} 
+                                                    ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
+                                                    ng-change="saveDatavalue(prStDes[de.dataElement.id])" 
+                                                    name="foo">
+                                                <option value="">{{'please_select'| translate}}</option>                        
+                                                <option value="false">{{'no'| translate}}</option>
+                                                <option value="true">{{'yes'| translate}}</option>
+                                            </select>
+
+                                        </div>
+                                        <div ng-switch-when="date">
+                                            <input type="text" 
+                                                   placeholder="{{dhis2CalendarFormat.keyDateFormat}}" 
+                                                   d2-date
+                                                   max-date="prStDes[de.dataElement.id].allowFutureDate ? '' : 0"
+                                                   ng-class='getInputNotifcationClass(prStDes[de.dataElement.id].dataElement.id,false)'
+                                                   ng-model="currentEvent[prStDes[de.dataElement.id].dataElement.id]"
+                                                   ng-required={{prStDes[de.dataElement.id].compulsory}}  
+                                                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
+                                                   blur-or-change="saveDatavalue(prStDes[de.dataElement.id])"
+                                                   name="foo"/>
+                                        </div>
+                                        <div ng-switch-when="trueOnly">
+                                            <input type="checkbox"                         
+                                                   ng-class='getInputNotifcationClass(prStDes[de.dataElement.id].dataElement.id,false)'
+                                                   ng-model="currentEvent[prStDes[de.dataElement.id].dataElement.id]"                                                               
+                                                   ng-required={{prStDes[de.dataElement.id].compulsory}} 
+                                                   ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED'" 
+                                                   ng-change="saveDatavalue(prStDes[de.dataElement.id])" 
+                                                   name="foo"/>
+                                        </div>
+                                    </div>
+                                </ng-form>
+                                <span ng-show="dataEntryOuterForm.submitted && dataEntryInnerForm.foo.$invalid" class="error">{{'required'| translate}}</span>
+                            </td>
+                            <td class="col-md-2" ng-if="allowProvidedElsewhereExists">                
+                                <div class="align-center" ng-show="prStDes[de.dataElement.id].allowProvidedElsewhere">
+                                    <input type="checkbox" 
+                                           ng-model="currentEvent.providedElsewhere[prStDes[de.dataElement.id].dataElement.id]"
+                                           ng-change="saveDatavalueLocation(prStDes[de.dataElement.id])"/>                
+                                </div>
+                            </td>
+                        </tr>
+                    </tbody>
+                </table>
+            </accordion-group> 
+        </accordion>
+    </div>
+    
 </form>

=== 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-12-19 16:52:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-01-05 16:25:01 +0000
@@ -526,7 +526,7 @@
         return $.ajax( {
             url: '../api/programStages.json',
             type: 'GET',
-            data: 'filter=id:eq:' + id +'&fields=id,name,sortOrder,version,dataEntryForm,captureCoordinates,blockEntryForm,autoGenerateEvent,generatedByEnrollmentDate,reportDateDescription,minDaysFromStart,repeatable,programStageDataElements[displayInReports,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,code,name,formName,type,optionSet[id]]]'
+            data: 'filter=id:eq:' + id +'&fields=id,name,sortOrder,version,dataEntryForm,captureCoordinates,blockEntryForm,autoGenerateEvent,generatedByEnrollmentDate,reportDateDescription,minDaysFromStart,repeatable,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,code,name,formName,type,optionSet[id]]]'
         }).done( function( response ){            
             _.each( _.values( response.programStages ), function( programStage ) {
                 dhis2.tc.store.set( 'programStages', programStage );