dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36142
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18505: tracker-capture: show only those programs that a selected OU has access
------------------------------------------------------------
revno: 18505
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-06 11:22:47 +0100
message:
tracker-capture: show only those programs that a selected OU has access
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.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/report/overdue-events-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js 2015-02-18 13:00:15 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js 2015-03-06 10:22:47 +0000
@@ -25,6 +25,7 @@
$scope.$watch('selectedOrgUnit', function() {
$scope.reportFinished = false;
$scope.reportStarted = false;
+ $scope.selectedProgram = null;
if( angular.isObject($scope.selectedOrgUnit)){
storage.set('SELECTED_OU', $scope.selectedOrgUnit);
$scope.loadPrograms($scope.selectedOrgUnit);
@@ -36,24 +37,24 @@
$scope.selectedOrgUnit = orgUnit;
if (angular.isObject($scope.selectedOrgUnit)){
ProgramFactory.getAll().then(function(programs){
- $scope.programs = programs;
+ $scope.programs = [];
+ angular.forEach(programs, function(program){
+ if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnit.id)){
+ $scope.programs.push(program);
+ }
+ });
if($scope.programs.length === 1){
$scope.selectedProgram = $scope.programs[0];
}
else{
- if(angular.isObject($scope.selectedProgram)){
- var continueLoop = true;
- for(var i=0; i<programs.length && continueLoop; i++){
- if(programs[i].id === $scope.selectedProgram.id){
- $scope.selectedProgram = programs[i];
- continueLoop = false;
- }
- }
- if(continueLoop){
- $scope.selectedProgram = null;
+ var continueLoop = true;
+ for(var i=0; i<programs.length && continueLoop; i++){
+ if(programs[i].id === $scope.selectedProgram.id){
+ $scope.selectedProgram = programs[i];
+ continueLoop = false;
}
}
- else{
+ if(continueLoop){
$scope.selectedProgram = null;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics-controller.js 2014-12-08 15:56:07 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-statistics-controller.js 2015-03-06 10:22:47 +0000
@@ -18,7 +18,8 @@
$scope.pager = {pageSize: 50, page: 1, toolBarDisplay: 5};
//watch for selection of org unit from tree
- $scope.$watch('selectedOrgUnit', function() {
+ $scope.$watch('selectedOrgUnit', function() {
+ $scope.selectedProgram = null;
if( angular.isObject($scope.selectedOrgUnit)){
storage.set('SELECTED_OU', $scope.selectedOrgUnit);
$scope.loadPrograms($scope.selectedOrgUnit);
@@ -26,14 +27,31 @@
});
//load programs associated with the selected org unit.
- $scope.loadPrograms = function(orgUnit) {
+ $scope.loadPrograms = function(orgUnit) {
$scope.selectedOrgUnit = orgUnit;
if (angular.isObject($scope.selectedOrgUnit)){
ProgramFactory.getAll().then(function(programs){
- $scope.programs = programs;
+ $scope.programs = [];
+ angular.forEach(programs, function(program){
+ if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnit.id)){
+ $scope.programs.push(program);
+ }
+ });
if($scope.programs.length === 1){
$scope.selectedProgram = $scope.programs[0];
- }
+ }
+ else{
+ var continueLoop = true;
+ for(var i=0; i<programs.length && continueLoop; i++){
+ if(programs[i].id === $scope.selectedProgram.id){
+ $scope.selectedProgram = programs[i];
+ continueLoop = false;
+ }
+ }
+ if(continueLoop){
+ $scope.selectedProgram = null;
+ }
+ }
});
}
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2015-02-18 13:00:15 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2015-03-06 10:22:47 +0000
@@ -16,7 +16,8 @@
$scope.report = {};
//watch for selection of org unit from tree
- $scope.$watch('selectedOrgUnit', function() {
+ $scope.$watch('selectedOrgUnit', function() {
+ $scope.selectedProgram = null;
if( angular.isObject($scope.selectedOrgUnit)){
storage.set('SELECTED_OU', $scope.selectedOrgUnit);
$scope.loadPrograms($scope.selectedOrgUnit);
@@ -24,14 +25,31 @@
});
//load programs associated with the selected org unit.
- $scope.loadPrograms = function(orgUnit) {
+ $scope.loadPrograms = function(orgUnit) {
$scope.selectedOrgUnit = orgUnit;
if (angular.isObject($scope.selectedOrgUnit)){
ProgramFactory.getAll().then(function(programs){
- $scope.programs = programs;
+ $scope.programs = [];
+ angular.forEach(programs, function(program){
+ if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnit.id)){
+ $scope.programs.push(program);
+ }
+ });
if($scope.programs.length === 1){
$scope.selectedProgram = $scope.programs[0];
- }
+ }
+ else{
+ var continueLoop = true;
+ for(var i=0; i<programs.length && continueLoop; i++){
+ if(programs[i].id === $scope.selectedProgram.id){
+ $scope.selectedProgram = programs[i];
+ continueLoop = false;
+ }
+ }
+ if(continueLoop){
+ $scope.selectedProgram = null;
+ }
+ }
});
}
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js 2015-03-06 09:37:05 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/upcoming-events-controller.js 2015-03-06 10:22:47 +0000
@@ -22,7 +22,8 @@
$scope.pager = {pageSize: 50, page: 1, toolBarDisplay: 5};
//watch for selection of org unit from tree
- $scope.$watch('selectedOrgUnit', function() {
+ $scope.$watch('selectedOrgUnit', function() {
+ $scope.selectedProgram = null;
if( angular.isObject($scope.selectedOrgUnit)){
storage.set('SELECTED_OU', $scope.selectedOrgUnit);
$scope.loadPrograms($scope.selectedOrgUnit);
@@ -34,24 +35,24 @@
$scope.selectedOrgUnit = orgUnit;
if (angular.isObject($scope.selectedOrgUnit)){
ProgramFactory.getAll().then(function(programs){
- $scope.programs = programs;
+ $scope.programs = [];
+ angular.forEach(programs, function(program){
+ if(program.organisationUnits.hasOwnProperty($scope.selectedOrgUnit.id)){
+ $scope.programs.push(program);
+ }
+ });
if($scope.programs.length === 1){
$scope.selectedProgram = $scope.programs[0];
}
else{
- if(angular.isObject($scope.selectedProgram)){
- var continueLoop = true;
- for(var i=0; i<programs.length && continueLoop; i++){
- if(programs[i].id === $scope.selectedProgram.id){
- $scope.selectedProgram = programs[i];
- continueLoop = false;
- }
- }
- if(continueLoop){
- $scope.selectedProgram = null;
+ var continueLoop = true;
+ for(var i=0; i<programs.length && continueLoop; i++){
+ if(programs[i].id === $scope.selectedProgram.id){
+ $scope.selectedProgram = programs[i];
+ continueLoop = false;
}
}
- else{
+ if(continueLoop){
$scope.selectedProgram = null;
}
}