← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16943: tracker capture - registration/enrollment forms respect radio type input modes assigned for program

 

------------------------------------------------------------
revno: 16943
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-10-03 10:25:10 +0200
message:
  tracker capture - registration/enrollment forms respect radio type input modes assigned for program
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json
  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/report-types.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/components/enrollment/enrollment-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js	2014-10-01 09:56:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js	2014-10-03 08:25:10 +0000
@@ -10,6 +10,7 @@
                 AttributesFactory,
                 CurrentSelection,
                 TEIService,
+                TEFormService,
                 EnrollmentService,
                 TranslationService,
                 ModalService,
@@ -122,7 +123,22 @@
            $scope.broadCastSelections('mainDashboard');
         }
         $scope.showEnrollmentDiv = !$scope.showEnrollmentDiv;
-    };    
+        
+        if($scope.showEnrollmentDiv){
+            
+            $scope.selectedProgram.hasCustomForm = false;
+            $scope.registrationForm = '';
+            TEFormService.getByProgram($scope.selectedProgram.id).then(function(teForm){
+                if(angular.isObject(teForm)){
+                    $scope.selectedProgram.hasCustomForm = true;
+                    $scope.registrationForm = teForm;
+                }                
+                $scope.selectedProgram.displayCustomForm = $scope.selectedProgram.hasCustomForm ? true:false;
+                
+                console.log('The program is:  ', $scope.selectedProgram);
+            });
+        }
+    };
        
     $scope.showReScheduling = function(){        
         $scope.showReSchedulingDiv = !$scope.showReSchedulingDiv;

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html	2014-10-01 09:56:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html	2014-10-03 08:25:10 +0000
@@ -107,54 +107,75 @@
                     </tr>
                 </table>
                 <hr ng-if='attributesForEnrollment'>
+                
                 <table class="table-borderless table-striped">
                     <tr class="col-md-12" ng-repeat="attribute in attributesForEnrollment">
                         <td class="col-md-6">
                             {{attribute.name}}
                         </td>
                         <td class="col-md-6">
-                    <ng-form name="innerForm">
-                        <div ng-switch="attribute.valueType">
-                            <div ng-switch-when="date">
-                                <input type="text" placeholder="yyyy-mm-dd" class="form-control" name="foo" ng-date ng-model="attribute.value" ng-required="attribute.mandatory"/>
-                                <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
-                            </div>
-                            <div ng-switch-when="trueOnly">
-                                <input type="checkbox" class="form-control" name="foo" ng-model="attribute.value" ng-required="attribute.mandatory"/>
-                                <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
-                            </div>
-                            <div ng-switch-when="bool">
-                                <select ng-model="attribute.value" name="foo" class="form-control" ng-required="attribute.mandatory">
-                                    <option value="">{{'please_select'| translate}}</option>                        
-                                    <option value="0">{{'no'| translate}}</option>
-                                    <option value="1">{{'yes'| translate}}</option>
-                                </select>
-                                <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
-                            </div>
-                            <div ng-switch-when="optionSet">
-                                <input type="text" 
-                                       name="foo"
-                                       class="form-control"
-                                       ng-model="attribute.value"                                                 
-                                       typeahead="option for option in attribute.optionSet.options | filter:$viewValue | limitTo:20" 
-                                       typeahead-open-on-focus
-                                       ng-required="attribute.mandatory"
-                                       />
-                                <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
-                            </div>
-                            <div ng-switch-when="number">
-                                <input type="number" class="form-control" name="foo" ng-model="attribute.value" ng-required="attribute.mandatory"/>
-                                <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
-                            </div>
-                            <div ng-switch-default>
-                                <input type="text" class="form-control" name="foo" ng-model="attribute.value" ng-required="attribute.mandatory"/>
-                                <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
-                            </div>
-                        </div>
-                    </ng-form>
-                    </td>
+                            <ng-form name="innerForm">
+                                <div ng-switch="attribute.valueType">
+                                    <div ng-switch-when="date">
+                                        <input type="text" placeholder="yyyy-mm-dd" class="form-control" name="foo" ng-date ng-model="attribute.value" ng-required="attribute.mandatory"/>
+                                        <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+                                    </div>
+                                    <div ng-switch-when="trueOnly">
+                                        <input type="checkbox" class="form-control" name="foo" ng-model="attribute.value" ng-required="attribute.mandatory"/>
+                                        <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+                                    </div>
+                                    <div ng-switch-when="bool">
+                                        <select ng-model="attribute.value" name="foo" class="form-control" ng-required="attribute.mandatory">
+                                            <option value="">{{'please_select'| translate}}</option>                        
+                                            <option value="false">{{'no'| translate}}</option>
+                                            <option value="true">{{'yes'| translate}}</option>
+                                        </select>
+                                        <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+                                    </div>
+                                    <div ng-switch-when="optionSet">
+                                        <div ng-if="!selectedProgram.dataEntryMethod || attribute.optionSet.options.length >= 7">
+                                            <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-open-on-focus
+                                               ng-required="attribute.mandatory"/>
+                                        </div>
+                                        <div ng-if="selectedProgram.dataEntryMethod && attribute.optionSet.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  attribute.optionSet.options">
+                                                <label>
+                                                    <input type="radio"
+                                                        name={{attribute.id}}
+                                                        ng-required="attribute.mandatory"
+                                                        ng-model="attribute.value" 
+                                                        value={{option.code}}> {{option.name}}
+                                                </label><br>
+                                            </span>                                            
+                                        </div>
+                                        <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+                                    </div>
+                                    <div ng-switch-when="number">
+                                        <input type="number" class="form-control" name="foo" ng-model="attribute.value" ng-required="attribute.mandatory"/>
+                                        <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+                                    </div>
+                                    <div ng-switch-default>
+                                        <input type="text" class="form-control" name="foo" ng-model="attribute.value" ng-required="attribute.mandatory"/>
+                                        <span ng-show="outerForm.submitted && innerForm.foo.$invalid" style="color:red;font-size:12px">{{'required'| translate}}</span>
+                                    </div>
+                                </div>
+                            </ng-form>
+                        </td>
                     </tr>                        
                 </table>
+                
                 <div class="vertical-spacing col-md-12">            
                     <button type="button" 
                             class="btn btn-primary"

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html	2014-09-08 09:08:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html	2014-10-03 08:25:10 +0000
@@ -36,8 +36,8 @@
                                 <div ng-switch-when="bool">
                                     <select name="foo" ng-model="attribute.value" class="form-control" ng-disabled="!editProfile" ng-required="attribute.mandatory">
                                         <option value="">{{'please_select'| translate}}</option>                        
-                                        <option value="0">{{'no'| translate}}</option>
-                                        <option value="1">{{'yes'| translate}}</option>
+                                        <option value="false">{{'no'| translate}}</option>
+                                        <option value="true">{{'yes'| translate}}</option>
                                     </select>
                                     <span ng-show="outerForm.submitted && innerForm.foo.$invalid" class="error">{{'required'| translate}} - {{attribute.type}}</span>
                                 </div>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html	2014-09-18 14:07:34 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html	2014-10-03 08:25:10 +0000
@@ -41,16 +41,46 @@
                                     <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="!selectedProgram">
+                                    <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-open-on-focus
-                                       ng-required="attribute.mandatory"
-                                       />
+                                       ng-required="attribute.mandatory"/>
+                                </div>
+                                <div ng-if="selectedProgram">
+                                    <div ng-if="!selectedProgram.dataEntryMethod || attribute.optionSet.options.length >= 7">
+                                        <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-open-on-focus
+                                           ng-required="attribute.mandatory"/>
+                                    </div>
+                                    <div ng-if="selectedProgram.dataEntryMethod && attribute.optionSet.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  attribute.optionSet.options">
+                                            <label>
+                                                <input type="radio"
+                                                    name={{attribute.id}}
+                                                    ng-required="attribute.mandatory"
+                                                    ng-model="attribute.value" 
+                                                    value={{option.code}}> {{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">

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-10-02 10:25:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-10-03 08:25:10 +0000
@@ -121,13 +121,13 @@
     "registration_and_data_entry": "Registration and Data Entry",
     "program_summary_report": "Program Summary Report",
     "program_summary": "Program Summary",
-    "program_summary_description": "Generate a summary report for a particular program, organisation unit and time frame. The report presents a list of tracked entity instances and the services they got from the selected program.",
+    "program_summary_description": "Generate a summary report for a particular program, organisation unit and time frame. The report presents a list of tracked entity instances with the option to drilldown and see actual values",
     "program_statistics": "Program Statistics",
-    "program_statistics_description": "Generate a statistics report for a particular program. The report provides for example an overview of dropouts or completions in a given time fram at a particular organisatoin unit.",
+    "program_statistics_description": "Generate a statistics report for a particular program. The report provides for example an overview of dropouts or completion rates in a given time frame at a particular organisation unit.",
     "upcoming_events": "Upcoming Events",
-    "upcoming_events_description": "Generate a report that lists tracked entity instances and their upcoming events that require attention. The events displayed are those that are scheduled in due time.",
+    "upcoming_events_description": "Generate a tabular report showing tracked entity instances and their upcoming events for a selected program and time. Searching, sorting and show/hide operations are possible on the columns.",
     "overdue_events": "Overdue Events",
-    "overdue_events_description": "Generate a report of overdue events for a selected program and organisation unit. The report displays list of tracked entity instances and their events that are not conducted on scheduled due dates.",
+    "overdue_events_description": "Generate a list of events for a selected program. The report displays list of tracked entity instances and their events that are not conducted on time. Filtering and searching is also possible.",
     "upcoming_event": "Upcoming event",
     "legend": "Legend",
     "event_color_legend": "What do the colors mean?",

=== 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-01 11:13:12 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-10-03 08:25:10 +0000
@@ -9,7 +9,7 @@
     var store = new dhis2.storage.Store({
         name: "dhis2tc",
         adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
-        objectStores: ['trackerCapturePrograms', 'programStages', 'trackedEntities','attributes','optionSets']
+        objectStores: ['trackerCapturePrograms', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes','optionSets']
     });
     return{
         currentStore: store
@@ -251,7 +251,7 @@
     };   
 })
 
-/* Service for getting tracked entity instances */
+/* Service for getting tracked entity */
 .factory('TEService', function(StorageService, $q, $rootScope) {
 
     return {
@@ -283,6 +283,25 @@
     };
 })
 
+/* Service for getting tracked entity Form */
+.factory('TEFormService', function(StorageService, $q, $rootScope) {
+
+    return {
+        getByProgram: function(programUid){            
+            var def = $q.defer();
+            
+            StorageService.currentStore.open().done(function(){
+                StorageService.currentStore.get('trackedEntityForms', programUid).done(function(te){                    
+                    $rootScope.$apply(function(){
+                        def.resolve(te);
+                    });
+                });
+            });                        
+            return def.promise;            
+        }
+    };
+})
+
 /* Service for getting tracked entity instances */
 .factory('TEIService', function($http, $q, AttributesFactory, DateUtils) {
 

=== 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-02 10:25:39 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2014-10-03 08:25:10 +0000
@@ -23,7 +23,7 @@
 dhis2.tc.store = new dhis2.storage.Store({
     name: TC_STORE_NAME,
     adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
-    objectStores: ['trackerCapturePrograms', 'programStages', 'trackedEntities', 'attributes', 'relationshipTypes', 'optionSets']
+    objectStores: ['trackerCapturePrograms', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes', 'relationshipTypes', 'optionSets']
 });
 
 (function($) {
@@ -66,7 +66,9 @@
         promise = promise.then( getMetaPrograms );     
         promise = promise.then( getPrograms );     
         promise = promise.then( getProgramStages );    
-        promise = promise.then( getOptionSetsForPrograms );    
+        promise = promise.then( getOptionSetsForPrograms );
+        promise = promise.then( getMetaTrackedEntityForms );
+        promise = promise.then( getTrackedEntityForms );        
         promise.done(function() {
             selection.responseReceived();
         });
@@ -525,6 +527,102 @@
     };
 }
 
+
+function getMetaTrackedEntityForms()
+{
+    var def = $.Deferred();
+
+    $.ajax({
+        url: '../api/trackedEntityForms.json',
+        type: 'GET',
+        data:'paging=false&fields=id,program[id]'
+    }).done( function(response) {          
+        var trackedEntityForms = [];
+        _.each( _.values( response.trackedEntityForms ), function ( trackedEntityForm ) { 
+            if( trackedEntityForm &&
+                trackedEntityForm.id &&
+                trackedEntityForm.program &&
+                trackedEntityForm.program.id ) {
+            
+                trackedEntityForms.push( trackedEntityForm );
+            }  
+            
+        });
+        
+        def.resolve( trackedEntityForms );
+    });
+    
+    return def.promise(); 
+    
+}
+
+function getTrackedEntityForms( trackedEntityForms )
+{
+    if( !trackedEntityForms ){
+        return;
+    }
+    
+    var mainDef = $.Deferred();
+    var mainPromise = mainDef.promise();
+
+    var def = $.Deferred();
+    var promise = def.promise();
+
+    var builder = $.Deferred();
+    var build = builder.promise();
+
+    _.each( _.values( trackedEntityForms ), function ( trackedEntityForm ) {
+        build = build.then(function() {
+            var d = $.Deferred();
+            var p = d.promise();
+            dhis2.tc.store.get('trackedEntityForms', trackedEntityForm.program.id).done(function(obj) {
+                if(!obj) {
+                    promise = promise.then( getTrackedEntityForm( trackedEntityForm.id ) );
+                }
+                d.resolve();
+            });
+
+            return p;
+        });
+    });
+
+    build.done(function() {
+        def.resolve();
+
+        promise = promise.done( function () {
+            mainDef.resolve();
+        } );
+    });
+
+    builder.resolve();
+
+    return mainPromise;
+}
+
+function getTrackedEntityForm( id )
+{
+    return function() {
+        return $.ajax( {
+            url: '../api/trackedEntityForms.json',
+            type: 'GET',
+            data: 'paging=false&filter=id:eq:' + id +'&fields=id,program[id,name],dataEntryForm[name,htmlCode]'
+        }).done( function( response ){
+            
+            _.each( _.values( response.trackedEntityForms ), function ( trackedEntityForm ) { 
+                
+                if( trackedEntityForm &&
+                    trackedEntityForm.id &&
+                    trackedEntityForm.program &&
+                    trackedEntityForm.program.id ) {
+
+                    trackedEntityForm.id = trackedEntityForm.program.id;
+                    dhis2.tc.store.set( 'trackedEntityForms', trackedEntityForm );
+                }
+            });
+        });
+    };
+}
+
 function uploadLocalData()
 {
     if (!dhis2.tc.storageManager.hasLocalData())

=== 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-01 11:13:12 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-10-03 08:25:10 +0000
@@ -784,7 +784,7 @@
 }
 
 .report-type-container{    
-    padding: 10px;
+    padding: 20px;
 }
 
 .validation-error {

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/report-types.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/report-types.html	2014-09-01 13:04:19 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/report-types.html	2014-10-03 08:25:10 +0000
@@ -8,7 +8,7 @@
 </div>
 <div id="mainPage">
     <h1>{{'tracker_reports'| translate}}</h1>
-    <div class="row col-sm-10">        
+    <div style="width: 90%;" class="row col-sm-12">        
         <div class="col-sm-6 report-type-container" ng-click="programSummary()">
             <h2><small><i class="fa fa-list-alt fa-2x black"></i></small><span class="horizonal-spacing">{{'program_summary'| translate}}</span></h2>
             {{'program_summary_description'| translate}}