dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35903
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18385: More flexibility in relationship assignment. However, when a program has a related program assig...
------------------------------------------------------------
revno: 18385
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-02-24 12:08:22 +0100
message:
More flexibility in relationship assignment. However, when a program has a related program assigned to it, then the flexibility is disabled.
modified:
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/enrollment/enrollment-controller.js
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/relationship/add-relationship.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html
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/search.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.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/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 @@
<hr>
<div class="row col-md-12">
<div class="col-md-5">
- <div class='align-center bold'>{{relationship.selected.aIsToB}}</div>
+ <select name="foo"
+ ng-model="selectedRelationship.aIsToB"
+ class="form-control"
+ ng-change="setRelationshipSides('A')"
+ ng-disabled="selectedProgramForRelative && selectedProgram.relatedProgram">
+ <option>{{relationship.selected.aIsToB}}</option>
+ <option>{{relationship.selected.bIsToA}}</option>
+ </select>
<div class='relationship-container'>
<table class="table table-striped table-compact table-borderless">
<tr ng-repeat="attribute in selectedTeiForDisplay.attributes">
@@ -31,7 +38,14 @@
</div>
</div>
<div class="col-md-7">
- <div class='align-center bold'>{{relationship.selected.bIsToA}}</div>
+ <select name="foo"
+ ng-model="selectedRelationship.bIsToA"
+ class="form-control"
+ ng-change="setRelationshipSides('B')"
+ ng-disabled="selectedProgramForRelative && selectedProgram.relatedProgram">
+ <option>{{relationship.selected.aIsToB}}</option>
+ <option>{{relationship.selected.bIsToA}}</option>
+ </select>
<div class='relationship-container' ng-show="teiForRelationship">
<table class="table table-striped table-compact table-borderless">
<tr ng-repeat="gridColumn in gridColumns">
@@ -44,7 +58,7 @@
</tr>
</table>
</div>
- <div class='relationship-container' ng-show="!teiForRelationship">
+ <div class='relationship-container' ng-show="!teiForRelationship">
<select ng-model="selectedRelationshipSource.value"
class="form-control"
ng-options="relationshipSource | translate for relationshipSource in relationshipSources">
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html 2015-01-05 15:31:59 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/registration.html 2015-02-24 11:08:22 +0000
@@ -5,6 +5,7 @@
<select ng-model="selectedProgramForRelative"
class="form-control"
+ ng-disabled="programs.length < 1 || (selectedProgramForRelative && selectedProgram.relatedProgram)"
ng-options="program as program.name for program in programs | orderBy: 'name'">
<option value="">{{'please_select_a_program'| translate}}</option>
</select>
=== 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}}
</td>
<td>
- <select ng-model="program"
+ <select ng-model="selectedProgramForRelative"
class="form-control"
ng-options="program as program.name for program in programs | orderBy: 'name'"
- ng-disabled="programs.length < 1"
- ng-change="setAttributesForSearch(program)">
+ ng-disabled="programs.length < 1 || (selectedProgramForRelative && selectedProgram.relatedProgram)"
+ ng-change="setAttributesForSearch(selectedProgramForRelative)">
<option value="">{{programs.length > 0 ? 'please_select_a_program' : 'no_program_exists' | translate}}</option>
</select>
</td>
=== 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();