dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30459
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15455: display only those attributes matching selected program in tei profile widget
------------------------------------------------------------
revno: 15455
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Wed 2014-05-28 17:20:11 +0200
message:
display only those attributes matching selected program in tei profile widget
modified:
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html
dhis-2/dhis-web/dhis-web-tracker-capture/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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2014-05-28 13:51:22 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/enrollment/enrollment-controller.js 2014-05-28 15:20:11 +0000
@@ -45,6 +45,14 @@
}
});
}
+
+ $scope.selectedProgram = '';
+ $scope.selectedEnrollment = '';
+ CurrentSelection.set({tei: $scope.selectedEntity, pr: $scope.selectedProgram.id});
+ $rootScope.$broadcast('dashboard', {selectedEntity: $scope.selectedEntity,
+ selectedOrgUnit: $scope.selectedOrgUnit,
+ selectedProgramId: $scope.selectedProgram.id,
+ selectedEnrollment: $scope.selectedEnrollment})
});
});
@@ -79,6 +87,7 @@
$scope.programStages.push(ps);
});
+ CurrentSelection.set({tei: $scope.selectedEntity, pr: $scope.selectedProgram.id});
$rootScope.$broadcast('dashboard', {selectedEntity: $scope.selectedEntity,
selectedOrgUnit: $scope.selectedOrgUnit,
selectedProgramId: $scope.selectedProgram.id,
@@ -87,6 +96,7 @@
else{
$scope.selectedProgram = '';
$scope.selectedEnrollment = '';
+ CurrentSelection.set({tei: $scope.selectedEntity, pr: $scope.selectedProgram.id});
$rootScope.$broadcast('dashboard', {selectedEntity: $scope.selectedEntity,
selectedOrgUnit: $scope.selectedOrgUnit,
selectedProgramId: $scope.selectedProgram.id,
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2014-05-28 13:36:26 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile-controller.js 2014-05-28 15:20:11 +0000
@@ -3,6 +3,7 @@
storage,
CurrentSelection,
TEIService,
+ AttributesFactory,
TranslationService) {
TranslationService.translate();
@@ -16,10 +17,28 @@
});
//listen for the selected entity
- $scope.$on('selectedEntity', function(event, args) {
- var selections = CurrentSelection.get();
- $scope.selectedEntity = selections.tei;
-
+ /*$scope.$on('selectedEntity', function(event, args) {
+ var selections = CurrentSelection.get();
+ $scope.selectedEntity = selections.tei;
+ $scope.selectedProgram = selections.pr ? storage.get(selections.pr) : null;
+ $scope.getTei();
+
+ });*/
+
+ $scope.$on('dashboard', function(event, args) {
+ var selections = CurrentSelection.get();
+ $scope.selectedEntity = selections.tei;
+ $scope.selectedProgram = selections.pr ? storage.get(selections.pr) : null;
+ $scope.processTeiAttributes();
+
+ });
+
+ //display only those attributes that belong the selected program
+ //if no program, display attributesInNoProgram
+ $scope.processTeiAttributes = function(){
+
+ $scope.entityAttributes = angular.copy($scope.selectedEntity.attributes);
+
angular.forEach(storage.get('TRACKED_ENTITIES'), function(te){
if($scope.selectedEntity.trackedEntity === te.id){
$scope.trackedEntity = te;
@@ -30,12 +49,13 @@
if(att.type === 'number' && !isNaN(parseInt(att.value))){
att.value = parseInt(att.value);
}
- });
- $scope.entityAttributes = angular.copy($scope.selectedEntity.attributes);
- });
+ });
+
+ $scope.selectedEntity.attributes = AttributesFactory.hideAttributesNotInProgram($scope.selectedEntity, $scope.selectedProgram);
+ };
- $scope.showEdit = function(){
- $scope.editProfile = !$scope.editProfile;
+ $scope.enableEdit = function(){
+ $scope.editProfile = !$scope.editProfile;
};
$scope.save = function(){
@@ -60,8 +80,6 @@
return;
}
});
-
- console.log('the tei is: ', tei);
$scope.editProfile = !$scope.editProfile;
};
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html 2014-05-27 12:38:36 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/profile/profile.html 2014-05-28 15:20:11 +0000
@@ -3,14 +3,14 @@
<div class="panel-heading">
{{trackedEntity.name|| 'entity' | translate}} {{profileWidget.title| translate}}
<span class="nav-pills" ng-show="selectedEntity.attributes.length">
- | <span><a href ng-click="showEdit()" title="{{'edit_profile'| translate}}">{{'edit'| translate}}</a></span>
+ | <span><a href ng-click="enableEdit()" title="{{'edit_profile'| translate}}">{{'edit'| translate}}</a></span>
</span>
<span class="pull-right">
<a href ng-click="removeWidget(profileWidget)" title="{{'remove'| translate}}"><span class='black'><i class="fa fa-times-circle"></i></span></a>
</span>
</div>
<table class="table-borderless table-striped">
- <tr ng-repeat="attribute in selectedEntity.attributes">
+ <tr ng-repeat="attribute in selectedEntity.attributes" ng-show="attribute.show">
<td>
{{attribute.displayName}}
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-05-28 13:36:26 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-05-28 15:20:11 +0000
@@ -248,18 +248,22 @@
return storage.get('ATTRIBUTES');
},
getByProgram: function(program){
- var attributes = [];
- var programAttributes = [];
-
- angular.forEach(this.getAll(), function(attribute){
- attributes[attribute.id] = attribute;
- });
-
- angular.forEach(program.programTrackedEntityAttributes, function(pAttribute){
- programAttributes.push(attributes[pAttribute.attribute.id]);
- });
-
- return programAttributes;
+
+ if(program){
+ var attributes = [];
+ var programAttributes = [];
+
+ angular.forEach(this.getAll(), function(attribute){
+ attributes[attribute.id] = attribute;
+ });
+
+ angular.forEach(program.programTrackedEntityAttributes, function(pAttribute){
+ programAttributes.push(attributes[pAttribute.attribute.id]);
+ });
+
+ return programAttributes;
+ }
+ return this.getWithoutProgram();
},
getWithoutProgram: function(){
var attributes = [];
@@ -296,6 +300,24 @@
}
}
return missingAttributes;
+ },
+ hideAttributesNotInProgram: function(tei, program){
+ var programAttributes = this.getByProgram(program);
+ var teiAttributes = tei.attributes;
+
+ for(var i=0; i<teiAttributes.length; i++){
+ teiAttributes[i].show = true;
+ var inProgram = false;
+ for(var j=0; j<programAttributes.length && !inProgram; j++){
+ if(teiAttributes[i].attribute === programAttributes[j].id){
+ inProgram = true;
+ }
+ }
+ if(!inProgram){
+ teiAttributes[i].show = false;
+ }
+ }
+ return tei.attributes;
}
};
})