=== 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-09-11 15:16:03 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js 2015-09-14 15:16:33 +0000 @@ -86,7 +86,6 @@ $scope.selectedTei = {}; $scope.tei = {}; $scope.registrationMode = args.registrationMode; - $scope.getAttributes($scope.registrationMode); if($scope.registrationMode !== 'REGISTRATION'){ $scope.selectedTei = args.selectedTei; @@ -96,6 +95,15 @@ if($scope.registrationMode === 'PROFILE'){ $scope.selectedEnrollment = args.enrollment; } + + if($scope.registrationMode === 'RELATIONSHIP'){ + $scope.mainTei = args.mainTei; + $scope.selectedTei = {}; + $scope.tei = {}; + $scope.selectedProgram = args.relativeProgram; + } + + $scope.getAttributes($scope.registrationMode); }); $scope.getAttributes = function(_mode){ @@ -112,6 +120,14 @@ $scope.trackedEntityForm.displayIncidentDate = $scope.selectedProgram.displayIncidentDate; $scope.customForm = CustomFormService.getForTrackedEntity($scope.trackedEntityForm, mode); } + + if(mode === 'RELATIONSHIP'){ + angular.forEach($scope.attributes, function(att){ + if(att.inherit && $scope.mainTei[att.id]){ + $scope.selectedTei[att.id] = $scope.mainTei[att.id]; + } + }); + } }); }; @@ -126,8 +142,20 @@ program: $scope.selectedProgram ? $scope.selectedProgram.id: null}); } else if(destination === 'RELATIONSHIP' ){ - $scope.tei.trackedEntityInstance = teiId; - $scope.broadCastSelections(); + if($scope.tei){ + angular.forEach($scope.tei.attributes, function(att){ + $scope.tei[att.attribute] = att.value; + }); + + $scope.tei.orgUnitName = $scope.selectedOrgUnit.name; + $scope.tei.created = DateUtils.formatFromApiToUser(new Date()); + + CurrentSelection.setRelationshipInfo({tei: $scope.tei}); + + $timeout(function() { + $rootScope.$broadcast('relationship', {result: 'SUCCESS'}); + }, 200); + } } }; @@ -260,19 +288,12 @@ } }; - - $scope.broadCastSelections = function(){ - angular.forEach($scope.tei.attributes, function(att){ - $scope.tei[att.attribute] = att.value; - }); - - $scope.tei.orgUnitName = $scope.selectedOrgUnit.name; - $scope.tei.created = DateUtils.formatFromApiToUser(new Date()); - CurrentSelection.setRelationshipInfo({tei: $scope.tei, src: $scope.selectedRelationshipSource}); + $scope.cancelRelativeRegistration = function(){ $timeout(function() { - $rootScope.$broadcast('relationship', {}); + $rootScope.$broadcast('relationship', {result: 'CANCEL'}); }, 200); - }; + }; + var processRuleEffect = function(){ === 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-06-02 12:25:03 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration.html 2015-09-14 15:16:33 +0000 @@ -62,6 +62,11 @@ +
+ + +
+ \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/add-relationship.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/add-relationship.html 2015-05-08 20:12:05 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/add-relationship.html 2015-09-14 15:16:33 +0000 @@ -106,7 +106,8 @@
-
+ +
 
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2015-09-14 10:11:37 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2015-09-14 15:16:33 +0000 @@ -172,6 +172,7 @@ function($scope, $rootScope, $translate, + $timeout, DateUtils, CurrentSelection, OperatorFactory, @@ -271,9 +272,15 @@ } //listen for selections - $scope.$on('relationship', function() { - var relationshipInfo = CurrentSelection.getRelationshipInfo(); - $scope.teiForRelationship = relationshipInfo.tei; + $scope.$on('relationship', function(event, args){ + if(args.result === 'SUCCESS'){ + var relationshipInfo = CurrentSelection.getRelationshipInfo(); + $scope.teiForRelationship = relationshipInfo.tei; + } + + if(args.result === 'CANCEL'){ + $scope.showRegistration(); + } }); //sortGrid @@ -465,6 +472,13 @@ if($scope.showRegistrationDiv){ $scope.showTrackedEntityDiv = false; + $timeout(function() { + var mainTei = angular.copy($scope.selectedTei); + angular.forEach(mainTei.attributes, function(att){ + mainTei[att.attribute] = att.value; + }); + $rootScope.$broadcast('registrationWidget', {registrationMode: 'RELATIONSHIP', mainTei: mainTei, relativeProgram: $scope.selectedProgramForRelative}); + }, 200); } else{ $scope.showTrackedEntityDiv = true; @@ -557,13 +571,22 @@ $scope.enrollment = {enrollmentDate: '', incidentDate: ''}; $scope.attributesById = CurrentSelection.getAttributesById(); - var selections = CurrentSelection.get(); + var selections = CurrentSelection.get(); $scope.optionSets = selections.optionSets; $scope.programs = selections.prs; + var mainTei = angular.copy(selections.tei); + angular.forEach(mainTei.attributes, function(att){ + mainTei[att.attribute] = att.value; + }); var getProgramAttributes = function(program){ AttributesFactory.getByProgram(program).then(function(atts){ - $scope.attributes = atts; + $scope.attributes = atts; + angular.forEach($scope.attributes, function(att){ + if(att.inherit && mainTei[att.id]){ + att.value = mainTei[att.id]; + } + }); }); };