=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-02-19 15:42:18 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js 2015-02-24 11:08:22 +0000 @@ -14,6 +14,7 @@ EnrollmentService, ProgramFactory, DashboardLayoutService, + AttributesFactory, CurrentSelection) { //selections $scope.selectedTeiId = ($location.search()).tei; @@ -86,7 +87,16 @@ $scope.dashboardWidgetsOrder.smallerWidgets.push(w.title); }); - $scope.broadCastSelections(); + AttributesFactory.getAll().then(function(atts){ + $scope.attributes = []; + $scope.attributesById = []; + angular.forEach(atts, function(att){ + $scope.attributesById[att.id] = att; + }); + + CurrentSelection.setAttributesById($scope.attributesById); + $scope.broadCastSelections(); + }); }); }; === 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-20 15:06:35 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2015-02-24 11:08:22 +0000 @@ -17,17 +17,7 @@ DialogService) { $scope.today = DateUtils.getToday(); - $scope.selectedOrgUnit = storage.get('SELECTED_OU'); - - AttributesFactory.getAll().then(function(atts){ - $scope.attributes = []; - $scope.attributesById = []; - angular.forEach(atts, function(att){ - $scope.attributesById[att.id] = att; - }); - - CurrentSelection.setAttributesById($scope.attributesById); - }); + $scope.selectedOrgUnit = storage.get('SELECTED_OU'); //listen for the selected items var selections = {}; === 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-20 12:08:37 +0000 +++ 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 @@ -12,15 +12,6 @@ $scope.enrollmentEditing = false; $scope.widget = 'PROFILE'; - //attributes for profile - $scope.attributes = []; - $scope.attributesById = []; - AttributesFactory.getAll().then(function(atts){ - angular.forEach(atts, function(att){ - $scope.attributesById[att.id] = att; - }); - }); - //listen for the selected entity var selections = {}; $scope.$on('dashboardWidgets', function(event, args) { @@ -33,6 +24,7 @@ $scope.trackedEntityForm = null; $scope.customForm = null; $scope.attributes = []; + $scope.attributesById = CurrentSelection.getAttributesById(); //display only those attributes that belong to the selected program //if no program, display attributesInNoProgram === 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-01-20 11:51:34 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/add-relationship.html 2015-02-24 11:08:22 +0000 @@ -16,7 +16,14 @@
-
{{relationship.selected.aIsToB}}
+
@@ -31,7 +38,14 @@
-
{{relationship.selected.bIsToA}}
+
@@ -44,7 +58,7 @@
-
+
=== 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-02-12 10:51:40 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2015-02-24 11:08:22 +0000 @@ -18,6 +18,7 @@ $scope.selections = CurrentSelection.get(); $scope.optionSets = $scope.selections.optionSets; $scope.selectedTei = angular.copy($scope.selections.tei); + $scope.attributesById = CurrentSelection.getAttributesById(); $scope.trackedEntity = $scope.selections.te; $scope.selectedEnrollment = $scope.selections.selectedEnrollment; @@ -37,8 +38,7 @@ $scope.relationships[rel.id] = rel; }); - setRelationships(); - + setRelationships(); }); }); @@ -135,8 +135,26 @@ $scope.relationshipSources = ['search_from_existing','register_new']; $scope.selectedRelationshipSource = {}; + $scope.selectedRelationship = {}; $scope.relationship = {}; + + //watch for selection of relationship + $scope.$watch('relationship.selected', function() { + if( angular.isObject($scope.relationship.selected)){ + $scope.selectedRelationship = {aIsToB: $scope.relationship.selected.aIsToB, bIsToA: $scope.relationship.selected.bIsToA}; + } + }); + + $scope.setRelationshipSides = function(side){ + if(side === 'A'){ + $scope.selectedRelationship.bIsToA = $scope.selectedRelationship.aIsToB === $scope.relationship.selected.aIsToB ? $scope.relationship.selected.bIsToA : $scope.relationship.selected.aIsToB; + } + if(side === 'B'){ + $scope.selectedRelationship.aIsToB = $scope.selectedRelationship.bIsToA === $scope.relationship.selected.bIsToA ? $scope.relationship.selected.aIsToB : $scope.relationship.selected.bIsToA; + } + }; + //Selection $scope.selectedOrgUnit = storage.get('SELECTED_OU'); $scope.optionSets = selections.optionSets; @@ -164,20 +182,11 @@ } } - if($scope.selectedProgramForRelative){ - AttributesFactory.getByProgram($scope.selectedProgramForRelative).then(function(atts){ - $scope.attributes = atts; - $scope.attributes = $scope.generateAttributeFilters($scope.attributes); - $scope.gridColumns = $scope.generateGridColumns($scope.attributes); - }); - } - else{ - AttributesFactory.getWithoutProgram().then(function(atts){ - $scope.attributes = atts; - $scope.attributes = $scope.generateAttributeFilters($scope.attributes); - $scope.gridColumns = $scope.generateGridColumns($scope.attributes); - }); - } + AttributesFactory.getByProgram($scope.selectedProgramForRelative).then(function(atts){ + $scope.attributes = atts; + $scope.attributes = $scope.generateAttributeFilters($scope.attributes); + $scope.gridColumns = $scope.generateGridColumns($scope.attributes); + }); //set attributes as per selected program $scope.setAttributesForSearch = function(program){ @@ -380,11 +389,13 @@ $scope.addRelationship = function(){ if($scope.selectedTei && $scope.teiForRelationship && $scope.relationship.selected){ - var relationship = {relationship: $scope.relationship.selected.id, - displayName: $scope.relationship.selected.name, - trackedEntityInstanceA: $scope.selectedTei.trackedEntityInstance, - trackedEntityInstanceB: $scope.teiForRelationship.id}; + var relationship = {}; + relationship.relationship = $scope.relationship.selected.id; + relationship.displayName = $scope.relationship.selected.name; + relationship.trackedEntityInstanceA = $scope.selectedRelationship.aIsToB === $scope.relationship.selected.aIsToB ? $scope.selectedTei.trackedEntityInstance : $scope.teiForRelationship.id; + relationship.trackedEntityInstanceB = $scope.selectedRelationship.bIsToA === $scope.relationship.selected.bIsToA ? $scope.teiForRelationship.id : $scope.selectedTei.trackedEntityInstance; + if($scope.selectedTei.relationships){ $scope.selectedTei.relationships.push(relationship); } @@ -437,16 +448,9 @@ //watch for selection of program $scope.$watch('selectedProgramForRelative', function() { - if( angular.isObject($scope.selectedProgramForRelative)){ - AttributesFactory.getByProgram($scope.selectedProgramForRelative).then(function(atts){ - $scope.attributes = atts; - }); - } - else{ - AttributesFactory.getWithoutProgram().then(function(atts){ - $scope.attributes = atts; - }); - } + AttributesFactory.getByProgram($scope.selectedProgramForRelative).then(function(atts){ + $scope.attributes = atts; + }); }); $scope.trackedEntities = {available: []}; === modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html' --- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html 2015-02-12 10:51:40 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/search.html 2015-02-24 11:08:22 +0000 @@ -15,11 +15,11 @@ {{'program' | translate}} - === 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-20 16:29:28 +0000 +++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-02-24 11:08:22 +0000 @@ -443,8 +443,7 @@ /* Service for getting tracked entity */ .factory('TEService', function(TCStorageService, $q, $rootScope) { - return { - + return { getAll: function(){ var def = $q.defer();