dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34170
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17541: event capture - some cleanups
------------------------------------------------------------
revno: 17541
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-11-19 20:47:21 +0100
message:
event capture - some cleanups
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-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-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2014-11-19 12:00:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2014-11-19 19:47:21 +0000
@@ -47,7 +47,7 @@
var loginDetails = storage.get('LOGIN_DETAILS');
var storedBy = '';
- if(loginDetails){
+ if(loginDetails && loginDetails.userCredentials){
storedBy = loginDetails.userCredentials.username;
}
$scope.noteExists = false;
@@ -57,8 +57,10 @@
$scope.dhis2Events = [];
if( angular.isObject($scope.selectedOrgUnit)){
+ //storage.set('SELECTED_OU', $scope.selectedOrgUnit);
//apply translation - by now user's profile is fetched from server.
- TranslationService.translate();
+
+ TranslationService.translate();
$scope.loadPrograms();
}
});
@@ -66,8 +68,6 @@
GeoJsonFactory.getAll().then(function(geoJsons){
$scope.geoJsons = geoJsons;
});
-
-
//load programs associated with the selected org unit.
$scope.loadPrograms = function() {
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js 2014-11-19 12:00:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js 2014-11-19 19:47:21 +0000
@@ -23,89 +23,25 @@
restrict: 'A',
link: function(scope, element, attrs){
- //when tree has loaded, get selected orgunit - if there is any - and inform angular
- /*$(function() {
-
- var adapters = [];
- var partial_adapters = [];
-
- if( dhis2.ou.memoryOnly ) {
- adapters = [ dhis2.storage.InMemoryAdapter ];
- partial_adapters = [ dhis2.storage.InMemoryAdapter ];
- } else {
- adapters = [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ];
- partial_adapters = [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter ];
- }
-
- dhis2.ou.store = new dhis2.storage.Store({
- name: OU_STORE_NAME,
- objectStores: [
- {
- name: OU_KEY,
- adapters: adapters
- },
- {
- name: OU_PARTIAL_KEY,
- adapters: partial_adapters
- }
- ]
- });
-
- dhis2.ou.store.open().done( function() {
- selection.load();
- $( "#orgUnitTree" ).one( "ouwtLoaded", function() {
- var selected = selection.getSelected()[0];
- selection.getOrganisationUnit(selected).done(function(data){
- if( data ){
- scope.selectedOrgUnit = {id: selected, name: data[selected].n, programs: []};
- scope.$apply();
- }
- });
- });
-
- });
- });
-
- //listen to user selection, and inform angular
- selection.setListenerFunction( organisationUnitSelected );
- selection.responseReceived();
-
- function organisationUnitSelected( orgUnits, orgUnitNames ) {
- scope.selectedOrgUnit = {id: orgUnits[0], name: orgUnitNames[0], programs: []};
- scope.$apply();
- }*/
-
- //reloadtree, incase not loaded
- $(function() {
- dhis2.ou.store.open().done( function() {
- selection.load();
- $( "#orgUnitTree" ).one( "ouwtLoaded", function() {
- var selected = selection.getSelected()[0];
- selection.getOrganisationUnit(selected).done(function(data){
- if( data ){
- $timeout(function() {
- scope.selectedOrgUnit = {id: selected, name: data[selected].n, programs: []};
- scope.$apply();
- });
- }
- });
- });
- });
- });
-
- //listen to user selection, and inform angular
- selection.responseReceived();
- selection.setListenerFunction( organisationUnitSelected );
-
- function organisationUnitSelected( orgUnits, orgUnitNames ) {
- var ou = {id: orgUnits[0], name: orgUnitNames[0]};
- var selectedOld = storage.get('SELECTED_OU');
- if(!selectedOld || ou.id !== selectedOld.id){
- $timeout(function() {
- scope.selectedOrgUnit = ou;
- scope.$apply();
- });
- }
+ //reloadtree, incase not loaded. get selected orgunit - if there is any - and inform angular
+ $(function() {
+ dhis2.ou.store.open().done( function() {
+ selection.load();
+ $( "#orgUnitTree" ).one( "ouwtLoaded", function(event, ids, names) {
+ setSelectedOu(ids, names);
+ });
+ });
+ });
+
+ //listen to user selection, and inform angular
+ selection.setListenerFunction( setSelectedOu, true );
+
+ function setSelectedOu( ids, names ) {
+ var ou = {id: ids[0], name: names[0]};
+ $timeout(function() {
+ scope.selectedOrgUnit = ou;
+ scope.$apply();
+ });
}
}
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2014-11-19 09:03:43 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2014-11-19 19:47:21 +0000
@@ -164,36 +164,7 @@
});
}
-function downloadMetaData(){
- /*var adapters = [];
- if( dhis2.ec.memoryOnly ) {
- adapters = [ dhis2.storage.InMemoryAdapter ];
- } else {
- adapters = [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ];
- }
-
-
- dhis2.ec.store = new dhis2.storage.Store({
- name: EC_STORE_NAME,
- objectStores: [
- {
- name: 'ecPrograms',
- adapters: adapters
- },
- {
- name: 'programStages',
- adapters: adapters
- },
- {
- name: 'geoJsons',
- adapters: adapters
- },
- {
- name: 'optionSets',
- adapters: adapters
- }
- ]
- });*/
+function downloadMetaData(){
var def = $.Deferred();
var promise = def.promise();
@@ -209,8 +180,8 @@
promise = promise.then( getProgramStages );
promise = promise.then( getOptionSets );
promise.done( function() {
- selection.responseReceived();
- });
+ selection.responseReceived();
+ });
def.resolve();
}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-11-19 12:45:44 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js 2014-11-19 19:47:21 +0000
@@ -234,9 +234,9 @@
getByStage: function(orgUnit, programStage, pager){
var pgSize = pager ? pager.pageSize : 50;
var pg = pager ? pager.page : 1;
- var url = '../api/events.json?' + 'orgUnit=' + orgUnit + '&programStage=' + programStage + '&pageSize=' + pgSize + '&page=' + pg;
-
- var promise = $http.get( url ).then(function(response){
+ var url = '../api/events.json?' + 'orgUnit=' + orgUnit + '&programStage=' + programStage + '&pageSize=' + pgSize + '&page=' + pg;
+
+ var promise = $http.get( url ).then(function(response){
return response.data;
}, function(){
return dhis2.ec.storageManager.getEvents(orgUnit, programStage);