=== 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 @@
-
+
@@ -123,7 +123,7 @@
-
+
=== 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 @@
-
+
-
+
=== 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 @@ - -
-
+ +
+
@@ -40,12 +40,26 @@
+
+ + + + + +
+ {{'entity_type'| translate}} + + +
+
+
- - + + -
+

{{'category'| translate}}

@@ -76,4 +90,5 @@ + \ 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