dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36003
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18442: tracker-capture: custom form based on attributes not linked to a program
------------------------------------------------------------
revno: 18442
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-02-27 10:37:56 +0100
message:
tracker-capture: custom form based on attributes not linked to a 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-controller.js
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-controller.js
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/scripts/services.js
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/enrollment/enrollment-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2015-02-26 11:22:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2015-02-27 09:37:56 +0000
@@ -88,11 +88,10 @@
if(!$scope.selectedEnrollment.enrollment){//prepare for possible enrollment
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
$scope.attributes = atts;
- $scope.selectedProgram.hasCustomForm = false;
+ $scope.customFormExists = false;
TEFormService.getByProgram($scope.selectedProgram, atts).then(function(teForm){
if(angular.isObject(teForm)){
- $scope.selectedProgram.hasCustomForm = true;
- $scope.selectedProgram.displayCustomForm = $scope.selectedProgram.hasCustomForm ? true:false;
+ $scope.customFormExists = true;
$scope.trackedEntityForm = teForm;
$scope.customForm = CustomFormService.getForTrackedEntity($scope.trackedEntityForm, 'ENROLLMENT');
}
@@ -123,14 +122,14 @@
$scope.loadEnrollmentDetails($scope.selectedEnrollment);
//check custom form for enrollment
- $scope.selectedProgram.hasCustomForm = false;
+ $scope.customFormExists = false;
$scope.registrationForm = '';
TEFormService.getByProgram($scope.selectedProgram, $scope.attributes).then(function(teForm){
if(angular.isObject(teForm)){
- $scope.selectedProgram.hasCustomForm = true;
+ $scope.customFormExists = true;
$scope.registrationForm = teForm;
}
- $scope.selectedProgram.displayCustomForm = $scope.selectedProgram.hasCustomForm ? true:false;
+ $scope.customFormExists = $scope.customFormExists ? true:false;
$scope.broadCastSelections('dashboardWidgets');
});
}
@@ -339,6 +338,6 @@
};
$scope.switchRegistrationForm = function(){
- $scope.selectedProgram.displayCustomForm = !$scope.selectedProgram.displayCustomForm;
+ $scope.customFormExists = !$scope.customFormExists;
};
});
=== 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 2015-02-09 07:55:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html 2015-02-27 09:37:56 +0000
@@ -84,7 +84,7 @@
<!-- new enrollment registration form begins -->
<form name="outerForm" novalidate>
<div ng-if="showEnrollmentDiv">
- <div class="row col-sm-12 vertical-spacing" ng-if="selectedProgram && selectedProgram.displayCustomForm">
+ <div class="row col-sm-12 vertical-spacing" ng-if="selectedProgram && customFormExists">
<div ng-if="!customForm.hasProgramDate">
<table class="dhis2-list-table-striped dhis2-table-hover">
<tr>
@@ -123,7 +123,7 @@
</div>
<div ng-include="'../dhis-web-commons/customform/custom-form.html'"></div>
</div>
- <div class="row col-sm-12 vertical-spacing" ng-if="!selectedProgram.displayCustomForm">
+ <div class="row col-sm-12 vertical-spacing" ng-if="!customFormExists">
<div ng-include="'views/enrollment-dates-form.html'"></div>
<div ng-include="'views/default-registration-form.html'"></div>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2015-02-24 11:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2015-02-27 09:37:56 +0000
@@ -10,7 +10,6 @@
$scope.editingDisabled = true;
$scope.enrollmentEditing = false;
- $scope.widget = 'PROFILE';
//listen for the selected entity
var selections = {};
@@ -35,19 +34,15 @@
delete $scope.selectedTei.attributes;
AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.attributes = atts;
-
- if($scope.selectedProgram && $scope.selectedProgram.id){
- $scope.selectedProgram.hasCustomForm = false;
- TEFormService.getByProgram($scope.selectedProgram, atts).then(function(teForm){
- if(angular.isObject(teForm)){
- $scope.selectedProgram.hasCustomForm = true;
- $scope.selectedProgram.displayCustomForm = $scope.selectedProgram.hasCustomForm ? true:false;
- $scope.trackedEntityForm = teForm;
- $scope.customForm = CustomFormService.getForTrackedEntity($scope.trackedEntityForm, $scope.widget);
- }
- });
- }
+ $scope.attributes = atts;
+ $scope.customFormExists = false;
+ TEFormService.getByProgram($scope.selectedProgram, atts).then(function(teForm){
+ if(angular.isObject(teForm)){
+ $scope.customFormExists = true;
+ $scope.trackedEntityForm = teForm;
+ $scope.customForm = CustomFormService.getForTrackedEntity($scope.trackedEntityForm, 'PROFILE');
+ }
+ });
});
});
@@ -110,6 +105,6 @@
};
$scope.switchRegistrationForm = function(){
- $scope.selectedProgram.displayCustomForm = !$scope.selectedProgram.displayCustomForm;
+ $scope.customFormExists = !$scope.customFormExists;
};
});
\ No newline at end of file
=== 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 2015-02-09 07:55:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html 2015-02-27 09:37:56 +0000
@@ -17,10 +17,10 @@
<div ng-show="profileWidget.expand" class="panel-body dashboard-widget-container">
<form name="outerForm" novalidate>
<div ng-if="!enrollmentEditing">
- <div class="vertical-spacing" ng-if="selectedProgram && selectedProgram.displayCustomForm">
+ <div class="vertical-spacing" ng-if="customFormExists">
<div ng-include="'../dhis-web-commons/customform/custom-form.html'"></div>
</div>
- <div class="vertical-spacing" ng-if="!selectedProgram.displayCustomForm">
+ <div class="vertical-spacing" ng-if="!customFormExists">
<div ng-include="'views/default-registration-form.html'"></div>
</div>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js 2015-02-11 11:52:21 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js 2015-02-27 09:37:56 +0000
@@ -57,25 +57,17 @@
});
$scope.getAttributes = function(){
- if($scope.selectedProgram && $scope.selectedProgram.id){
- AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
- $scope.attributes = atts;
- $scope.selectedProgram.hasCustomForm = false;
- TEFormService.getByProgram($scope.selectedProgram, $scope.attributes).then(function(teForm){
- if(angular.isObject(teForm)){
- $scope.selectedProgram.hasCustomForm = true;
- $scope.selectedProgram.displayCustomForm = $scope.selectedProgram.hasCustomForm ? true:false;
- $scope.trackedEntityForm = teForm;
- $scope.customForm = CustomFormService.getForTrackedEntity($scope.trackedEntityForm, 'ENROLLMENT');
- }
- });
- });
- }
- else{
- AttributesFactory.getWithoutProgram().then(function(atts){
- $scope.attributes = atts;
- });
- }
+ AttributesFactory.getByProgram($scope.selectedProgram).then(function(atts){
+ $scope.attributes = atts;
+ $scope.customFormExists = false;
+ TEFormService.getByProgram($scope.selectedProgram, $scope.attributes).then(function(teForm){
+ if(angular.isObject(teForm)){
+ $scope.customFormExists = true;
+ $scope.trackedEntityForm = teForm;
+ $scope.customForm = CustomFormService.getForTrackedEntity($scope.trackedEntityForm, 'ENROLLMENT');
+ }
+ });
+ });
};
$scope.registerEntity = function(destination){
@@ -229,6 +221,6 @@
};
$scope.switchRegistrationForm = function(){
- $scope.selectedProgram.displayCustomForm = !$scope.selectedProgram.displayCustomForm;
+ $scope.customFormExists = !$scope.customFormExists;
};
});
\ No newline at end of file
=== 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 2015-02-09 07:55:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html 2015-02-27 09:37:56 +0000
@@ -2,9 +2,9 @@
<!--registration form starts -->
<form name="outerForm" novalidate>
- <!--custom registration form begins-->
- <div class="row col-sm-12 vertical-spacing" ng-if="selectedProgram && selectedProgram.displayCustomForm">
- <div ng-if="!customForm.hasProgramDate">
+ <!--custom registration form begins -->
+ <div class="row col-sm-12 vertical-spacing" ng-if="customFormExists">
+ <div ng-if="selectedProgram && !customForm.hasProgramDate">
<table class="dhis2-list-table-striped dhis2-table-hover">
<tr>
<td>
@@ -40,12 +40,26 @@
</tr>
</table>
</div>
+ <div ng-if="!selectedProgram">
+ <table class="table-borderless table-striped">
+ <tr>
+ <td>
+ {{'entity_type'| translate}}
+ </td>
+ <td>
+ <select class="form-control" ng-model="trackedEntities.selected" ng-options="trackedEntity.name for trackedEntity in trackedEntities.available | orderBy: 'name'">
+ </select>
+ </td>
+ </tr>
+ </table>
+ <hr>
+ </div>
<div ng-include="'../dhis-web-commons/customform/custom-form.html'"></div>
</div>
- <!-- custom registration form ends -->
-
+ <!-- custom registration form ends-->
+
<!-- default registration form begins -->
- <div class="row col-sm-12 vertical-spacing" ng-if="!selectedProgram.displayCustomForm">
+ <div class="row col-sm-12 vertical-spacing" ng-if="!customFormExists">
<div ng-if='!selectedProgram'>
<h3>{{'category'| translate}}</h3>
<table class="table-borderless table-striped">
@@ -76,4 +90,5 @@
<button type="button" class="btn btn-default small-horizonal-spacing" ng-click="showRegistration()">{{'cancel'| translate}}</button>
</div>
</form>
+ <!--registration form ends -->
</div>
\ No newline at end of file
=== 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 2015-02-26 11:22:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-02-27 09:37:56 +0000
@@ -476,6 +476,11 @@
return {
getByProgram: function(program, attributes){
+
+ if(!program){
+ program = {id: 'NO_PROGRAM', name: 'NO_PROGRAM', selectIncidentDatesInFuture: false, selectEnrollmentDatesInFuture: false, displayIncidentDate: false};
+ }
+
var def = $q.defer();
TCStorageService.currentStore.open().done(function(){
=== 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 2015-02-26 11:22:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2015-02-27 09:37:56 +0000
@@ -166,8 +166,7 @@
promise = promise.then( getTrackedEntityAttributes );
promise = promise.then( getOptionSetsForAttributes );
promise = promise.then( getMetaProgramValidations );
- promise = promise.then( getProgramValidations );
- promise = promise.then( getMetaTrackedEntityForms );
+ promise = promise.then( getProgramValidations );
promise = promise.then( getTrackedEntityForms );
promise.done(function() {
@@ -720,115 +719,34 @@
};
}
-function getMetaTrackedEntityForms( programs )
+function getTrackedEntityForms( )
{
-
- if( !programs ){
- return;
- }
-
- var def = $.Deferred();
-
- var programIds = [];
- _.each( _.values( programs ), function ( program ) {
- if( program.id ) {
- programIds.push( program.id );
+ dhis2.tc.store.getKeys( 'trackedEntityForms').done(function(res){
+ if(res.length > 0){
+ return;
}
- });
-
- $.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 &&
- programIds.indexOf( trackedEntityForm.program.id ) !== -1) {
-
- trackedEntityForms.push( trackedEntityForm );
- }
-
- });
-
- def.resolve( trackedEntityForms );
-
- }).fail(function(){
- def.resolve( null );
- });
-
- 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();
- } );
- }).fail(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 ){
-
+ var def = $.Deferred();
+
+ $.ajax({
+ url: '../api/trackedEntityForms.json?paging=false&fields=id,program[id,name],dataEntryForm[name,htmlCode]',
+ type: 'GET'
+ }).done(function(response) {
_.each( _.values( response.trackedEntityForms ), function ( trackedEntityForm ) {
- if( trackedEntityForm &&
- trackedEntityForm.id &&
- trackedEntityForm.program &&
- trackedEntityForm.program.id ) {
-
+ if( trackedEntityForm && trackedEntityForm.id){
+ if(!trackedEntityForm.program || !trackedEntityForm.program.id){
+ trackedEntityForm.program = {id: 'NO_PROGRAM', name: 'NO_PROGRAM'};
+ }
trackedEntityForm.id = trackedEntityForm.program.id;
dhis2.tc.store.set( 'trackedEntityForms', trackedEntityForm );
}
});
+
+ def.resolve();
+ }).fail(function(){
+ def.resolve();
});
- };
+
+ return def.promise();
+ });
}
\ No newline at end of file