=== 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-03-19 10:18:00 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-03-25 16:43:47 +0000 @@ -251,7 +251,7 @@ var val = dataValue.value; var de = $scope.prStDes[dataValue.dataElement].dataElement; - if(de){ + if(de){ if(val && de.type === 'string' && de.optionSet && $scope.optionSets[de.optionSet.id].options ){ val = OptionSetService.getName($scope.optionSets[de.optionSet.id].options, val); } @@ -276,8 +276,7 @@ if(stage.captureCoordinates){ event.coordinate = {latitude: event.coordinate.latitude ? event.coordinate.latitude : '', longitude: event.coordinate.longitude ? event.coordinate.longitude : ''}; - } - + } event.allowProvidedElsewhereExists = false; angular.forEach(stage.programStageDataElements, function(prStDe){ === 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-03-11 11:21:40 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2015-03-25 16:43:47 +0000 @@ -1,20 +1,18 @@ +/* global trackerCapture, angular */ + trackerCapture.controller('EnrollmentController', function($rootScope, $scope, $location, $timeout, DateUtils, - EventUtils, storage, - DHIS2EventFactory, AttributesFactory, CurrentSelection, - TEIService, TEFormService, CustomFormService, EnrollmentService, - ModalService, - DialogService) { + ModalService) { $scope.today = DateUtils.getToday(); $scope.selectedOrgUnit = storage.get('SELECTED_OU'); @@ -97,11 +95,15 @@ $scope.trackedEntityForm = teForm; $scope.customForm = CustomFormService.getForTrackedEntity($scope.trackedEntityForm, 'ENROLLMENT'); } + if($scope.selectedEnrollment.enrollment){ + $scope.broadCastSelections('dashboardWidgets'); + } + }); + } + else{ + if($scope.selectedEnrollment.enrollment){ $scope.broadCastSelections('dashboardWidgets'); - }); - } - else{ - $scope.broadCastSelections('dashboardWidgets'); + } } }); }; @@ -110,12 +112,21 @@ $scope.showEnrollmentDiv = !$scope.showEnrollmentDiv; - if($scope.showEnrollmentDiv){ + $timeout(function() { + $rootScope.$broadcast('enrollmentEditing', {enrollmentEditing: $scope.showEnrollmentDiv}); + }, 100); + + if($scope.showEnrollmentDiv){ + $scope.showEnrollmentHistoryDiv = false; //load new enrollment details $scope.selectedEnrollment = {}; $scope.loadEnrollmentDetails($scope.selectedEnrollment); + + $timeout(function() { + $rootScope.$broadcast('registrationWidget', {registrationMode: 'ENROLLMENT', selectedTei: $scope.selectedTei}); + }, 100); } else{ hideEnrollmentDiv(); @@ -134,77 +145,6 @@ } }; - $scope.enroll = function(){ - - //check for form validity - $scope.outerForm.submitted = true; - if( $scope.outerForm.$invalid ){ - return false; - } - - //form is valid, continue with enrollment - var result = getProcessedForm(); - $scope.formEmpty = result.formEmpty; - var tei = result.tei; - - if($scope.formEmpty){//form is empty - return false; - } - - var enrollment = {trackedEntityInstance: tei.trackedEntityInstance, - program: $scope.selectedProgram.id, - status: 'ACTIVE', - dateOfEnrollment: $scope.selectedEnrollment.dateOfEnrollment, - dateOfIncident: $scope.selectedEnrollment.dateOfIncident ? $scope.selectedEnrollment.dateOfIncident : $scope.selectedEnrollment.dateOfEnrollment - }; - - TEIService.update(tei, $scope.optionSets, $scope.attributesById).then(function(updateResponse){ - - if(updateResponse.status === 'SUCCESS'){ - //registration is successful, continue for enrollment - EnrollmentService.enroll(enrollment).then(function(enrollmentResponse){ - if(enrollmentResponse.status !== 'SUCCESS'){ - //enrollment has failed - var dialogOptions = { - headerText: 'enrollment_error', - bodyText: enrollmentResponse - }; - DialogService.showDialog({}, dialogOptions); - return; - } - - enrollment.enrollment = enrollmentResponse.reference; - $scope.selectedEnrollment = enrollment; - $scope.enrollments.push($scope.selectedEnrollment); - - var dhis2Events = EventUtils.autoGenerateEvents(tei.trackedEntityInstance, $scope.selectedProgram, $scope.selectedOrgUnit, $scope.selectedEnrollment); - - $scope.showEnrollmentDiv = false; - $scope.outerForm.submitted = false; - - CurrentSelection.set({tei: tei, te: $scope.selectedEntity, prs: $scope.programs, pr: $scope.selectedProgram, prNames: $scope.programNames, prStNames: $scope.programStageNames, enrollments: $scope.enrollments, selectedEnrollment: $scope.selectedEnrollment, optionSets: $scope.optionSets}); - if(dhis2Events.events.length > 0){ - DHIS2EventFactory.create(dhis2Events).then(function(data) { - $scope.broadCastSelections('dashboardWidgets'); - }); - } - else{ - $scope.broadCastSelections('dashboardWidgets'); - } - }); - } - else{ - //update has failed - var dialogOptions = { - headerText: 'registration_error', - bodyText: updateResponse.description - }; - DialogService.showDialog({}, dialogOptions); - return; - } - }); - }; - $scope.broadCastSelections = function(listeners){ var selections = CurrentSelection.get(); var tei = selections.tei; @@ -213,24 +153,6 @@ $timeout(function() { $rootScope.$broadcast(listeners, {}); }, 100); - - $timeout(function() { - $rootScope.$broadcast('enrollmentEditing', {enrollmentEditing: $scope.showEnrollmentDiv}); - }, 100); - }; - - var getProcessedForm = function(){ - var tei = angular.copy(selections.tei); - tei.attributes = []; - var formEmpty = true; - for(var k in $scope.attributesById){ - if( $scope.selectedTei[k] ){ - tei.attributes.push({attribute: $scope.attributesById[k].id, value: $scope.selectedTei[k], displayName: $scope.attributesById[k].name, type: $scope.attributesById[k].valueType}); - formEmpty = false; - } - } - - return {tei: tei, formEmpty: formEmpty}; }; var processSelectedTei = function(){ === 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-27 09:37:56 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment.html 2015-03-25 16:43:47 +0000 @@ -82,70 +82,7 @@ -
+ @@ -189,4 +126,4 @@ - \ 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-controller.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2015-03-09 16:23:47 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2015-03-25 16:43:47 +0000 @@ -1,11 +1,12 @@ +/* global trackerCapture, angular */ + trackerCapture.controller('ProfileController', function($rootScope, - $scope, + $scope, + $timeout, CurrentSelection, CustomFormService, TEFormService, - TEIService, - DialogService, AttributesFactory) { $scope.editingDisabled = true; @@ -47,6 +48,9 @@ }); } }); + $timeout(function() { + $rootScope.$broadcast('registrationWidget', {registrationMode: 'PROFILE', selectedTei: $scope.selectedTei, enrollment: $scope.selectedEnrollment}); + }, 100); }); //listen for enrollment editing @@ -60,50 +64,11 @@ $rootScope.profileWidget.expand = true; }; - $scope.save = function(){ - //check for form validity - $scope.outerForm.submitted = true; - if( $scope.outerForm.$invalid ){ - return false; - } - - //form is valid, continue the update process - //get tei attributes and their values - //but there could be a case where attributes are non-mandatory and - //form comes empty, in this case enforce at least one value - $scope.formEmpty = true; - var tei = angular.copy(selections.tei); - tei.attributes = []; - for(var k in $scope.attributesById){ - if( $scope.selectedTei.hasOwnProperty(k) && $scope.selectedTei[k] ){ - tei.attributes.push({attribute: $scope.attributesById[k].id, value: $scope.selectedTei[k], type: $scope.attributesById[k].valueType}); - $scope.formEmpty = false; - } - } - - if($scope.formEmpty){//form is empty - return false; - } - - TEIService.update(tei, $scope.optionSets, $scope.attributesById).then(function(updateResponse){ - - if(updateResponse.status !== 'SUCCESS'){//update has failed - var dialogOptions = { - headerText: 'update_error', - bodyText: updateResponse.description - }; - DialogService.showDialog({}, dialogOptions); - return; - } - - $scope.editingDisabled = !$scope.editingDisabled; - CurrentSelection.set({tei: tei, te: $scope.trackedEntity, pr: $scope.selectedProgram, enrollment: $scope.selectedEnrollment, optionSets: $scope.optionSets}); - $scope.outerForm.submitted = false; - }); - }; - $scope.cancel = function(){ $scope.selectedTei = $scope.teiOriginal; $scope.editingDisabled = !$scope.editingDisabled; + $timeout(function() { + $rootScope.$broadcast('registrationWidget', {registrationMode: 'PROFILE', selectedTei: $scope.selectedTei, enrollment: $scope.selectedEnrollment}); + }, 100); }; }); \ 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-27 09:37:56 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html 2015-03-25 16:43:47 +0000 @@ -1,6 +1,5 @@