dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30202
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15311: a little timeout to ensure broadcasts are not missed between controllers
------------------------------------------------------------
revno: 15311
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Tue 2014-05-20 15:24:54 +0200
message:
a little timeout to ensure broadcasts are not missed between controllers
modified:
dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
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/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-05-20 08:20:18 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js 2014-05-20 13:24:54 +0000
@@ -95,7 +95,7 @@
}
}
}
- };
+ };
$scope.getProgramAttributes = function(program){
$scope.trackedEntityList = null;
@@ -122,10 +122,9 @@
if($scope.selectedProgram){
programUrl = 'program=' + $scope.selectedProgram.id;
- }
-
- $scope.gridColumns = $scope.generateGridColumns($scope.attributes);
+ }
+ //check search mode
if( mode === $scope.searchMode.freeText ){
if(!$scope.searchText){
$scope.emptySearchText = true;
@@ -156,9 +155,15 @@
programUrl,
attributeUrl.url).then(function(data){
$scope.trackedEntityList = data;
+
+ if($scope.trackedEntityList){
+ $scope.gridColumns = $scope.generateGridColumns($scope.trackedEntityList.headers);
+ }
+
});
};
+ //generate grid columns from teilist attributes
$scope.generateGridColumns = function(attributes){
var columns = angular.copy(attributes);
@@ -241,7 +246,7 @@
$scope.hiddenGridColumns = 0;
- angular.forEach($scope.gColumns, function(gridColumn){
+ angular.forEach($scope.gridColumns, function(gridColumn){
if(!gridColumn.show){
$scope.hiddenGridColumns++;
}
@@ -330,7 +335,6 @@
}
});
-
$scope.registerEntity = function(showDashboard){
//get selected entity
@@ -408,12 +412,14 @@
});
};
})
+
//Controller for dashboard
.controller('DashboardController',
function($rootScope,
$scope,
$location,
$modal,
+ $timeout,
storage,
TEIService,
CurrentSelection,
@@ -439,6 +445,9 @@
$rootScope.dashboardWidgets.smaller.push($rootScope.notesWidget);
//selections
+ $scope.selectedEntityId = null;
+ $scope.selectedProgramId = null;
+
$scope.selectedEntityId = ($location.search()).selectedEntityId;
$scope.selectedProgramId = ($location.search()).selectedProgramId;
$scope.selectedOrgUnit = storage.get('SELECTED_OU');
@@ -455,9 +464,11 @@
//Fetch the selected entity
TEIService.get($scope.selectedEntityId).then(function(data){
CurrentSelection.set({tei: data, pr: $scope.selectedProgram});
-
+
//broadcast selected entity for dashboard controllers
- $rootScope.$broadcast('selectedEntity', {});
+ $timeout(function() {
+ $rootScope.$broadcast('selectedEntity', {});
+ }, 100);
});
}
@@ -503,10 +514,9 @@
//listen for the selected entity
$scope.$on('selectedEntity', function(event, args) {
-
var selections = CurrentSelection.get();
- $scope.selectedEntity = selections.tei;
-
+ $scope.selectedEntity = selections.tei;
+
angular.forEach(storage.get('TRACKED_ENTITIES'), function(te){
if($scope.selectedEntity.trackedEntity === te.id){
$scope.trackedEntity = te;
=== 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-20 08:20:18 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-05-20 13:24:54 +0000
@@ -238,13 +238,7 @@
return {
getAll: function(){
-
- var attributes = storage.get('ATTRIBUTES');
-
- if(attributes){
- return attributes;
- }
- return;
+ return storage.get('ATTRIBUTES');
},
getByProgram: function(program){
var attributes = [];
@@ -576,7 +570,7 @@
//grid.headers[5..] = Attribute, Attribute,....
var attributes = [];
for(var i=5; i<grid.headers.length; i++){
- attributes.push({id: grid.headers[i].name, name: grid.headers[i].column});
+ attributes.push({id: grid.headers[i].name, name: grid.headers[i].column, type: grid.headers[i].type});
}
var entityList = [];