dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36572
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18707: wrapper for sessionStorage
------------------------------------------------------------
revno: 18707
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-27 13:43:44 +0100
message:
wrapper for sessionStorage
modified:
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-tracker-capture/components/dataentry/dataentry-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.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/event-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2015-03-19 14:30:09 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js 2015-03-27 12:43:44 +0000
@@ -167,13 +167,19 @@
function getCalendarSetting()
{
+ var SessionStorageService = angular.element('body').injector().get('SessionStorageService');
+
+ if( SessionStorageService.get('CALENDAR_SETTING') ){
+ return;
+ }
+
var def = $.Deferred();
$.ajax({
url: '../api/systemSettings?key=keyCalendar&key=keyDateFormat',
type: 'GET'
}).done(function(response) {
- localStorage['CALENDAR_SETTING'] = JSON.stringify(response);
+ SessionStorageService.set('CALENDAR_SETTING', response);
def.resolve();
}).fail(function(){
def.resolve();
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-03-27 09:49:12 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-03-27 12:43:44 +0000
@@ -8,6 +8,7 @@
EventUtils,
orderByFilter,
storage,
+ SessionStorageService,
ProgramStageFactory,
DHIS2EventFactory,
OptionSetService,
@@ -24,7 +25,7 @@
$scope.currentPeriod = [];
$scope.filterEvents = true;
- var userProfile = storage.get('USER_PROFILE');
+ var userProfile = SessionStorageService.get('USER_PROFILE');
var storedBy = userProfile && userProfile.username ? userProfile.username : '';
var today = DateUtils.getToday();
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js 2015-03-27 09:49:12 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/notes/notes-controller.js 2015-03-27 12:43:44 +0000
@@ -1,14 +1,16 @@
+/* global trackerCapture, angular */
+
trackerCapture.controller('NotesController',
function($scope,
- storage,
DateUtils,
EnrollmentService,
CurrentSelection,
+ SessionStorageService,
orderByFilter) {
- var userProfile = storage.get('USER_PROFILE');
+ var userProfile = SessionStorageService.get('USER_PROFILE');
var storedBy = userProfile && userProfile.username ? userProfile.username : '';
-
+
var today = DateUtils.getToday();
$scope.showMessagingDiv = false;
@@ -50,7 +52,7 @@
$scope.addNote = function(){
- if(!angular.isUndefined($scope.note) && $scope.note != ""){
+ if(!angular.isUndefined($scope.note) && $scope.note !== ""){
var newNote = {value: $scope.note};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2015-03-19 14:30:09 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2015-03-27 12:43:44 +0000
@@ -1,4 +1,4 @@
-/* global dhis2 */
+/* global dhis2, angular */
dhis2.util.namespace('dhis2.tc');
@@ -158,7 +158,9 @@
function getCalendarSetting()
{
- if(localStorage['CALENDAR_SETTING']){
+ var SessionStorageService = angular.element('body').injector().get('SessionStorageService');
+
+ if( SessionStorageService.get('CALENDAR_SETTING') ){
return;
}
@@ -168,7 +170,7 @@
url: '../api/systemSettings?key=keyCalendar&key=keyDateFormat',
type: 'GET'
}).done(function(response) {
- localStorage['CALENDAR_SETTING'] = JSON.stringify(response);
+ SessionStorageService.set('CALENDAR_SETTING', response);
def.resolve();
}).fail(function(){
def.resolve();
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-03-19 10:18:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-03-27 12:43:44 +0000
@@ -2,7 +2,7 @@
var d2Services = angular.module('d2Services', ['ngResource'])
/* Factory for loading translation strings */
-.factory('i18nLoader', function ($q, $http, storage, DialogService) {
+.factory('i18nLoader', function ($q, $http, SessionStorageService, DialogService) {
var getTranslationStrings = function(locale){
var defaultUrl = 'i18n/i18n_app.properties';
@@ -39,7 +39,7 @@
var locale = 'en';
var promise = $http.get('../api/me/profile.json').then(function(response){
- storage.set('USER_PROFILE', response.data);
+ SessionStorageService.set( 'USER_PROFILE', response.data );
if(response.data && response.data.settings && response.data.settings.keyUiLocale){
locale = response.data.settings.keyUiLocale;
}
@@ -52,7 +52,7 @@
};
return function () {
var deferred = $q.defer(), translations;
- var userProfile = storage.get('USER_PROFILE');
+ var userProfile = SessionStorageService.get( 'USER_PROFILE' );
if(userProfile && userProfile.settings && userProfile.settings.keyUiLocale){
getTranslationStrings(userProfile.settings.keyUiLocale).then(function(response){
translations = response.keys;
@@ -85,14 +85,26 @@
};
})
+/* service for wrapping sessionStorage '*/
+.service('SessionStorageService', function($window){
+ return {
+ get: function(key){
+ return JSON.parse( $window.sessionStorage.getItem( key ) );
+ },
+ set: function(key, obj) {
+ $window.sessionStorage.setItem( key, JSON.stringify( obj ) );
+ }
+ };
+})
+
/* service for getting calendar setting */
-.service('CalendarService', function(storage, $rootScope){
+.service('CalendarService', function(storage, $rootScope, SessionStorageService){
return {
getSetting: function() {
var dhis2CalendarFormat = {keyDateFormat: 'yyyy-MM-dd', keyCalendar: 'gregorian', momentFormat: 'YYYY-MM-DD'};
- var storedFormat = storage.get('CALENDAR_SETTING');
+ var storedFormat = SessionStorageService.get('CALENDAR_SETTING');
if(angular.isObject(storedFormat) && storedFormat.keyDateFormat && storedFormat.keyCalendar){
if(storedFormat.keyCalendar === 'iso8601'){
storedFormat.keyCalendar = 'gregorian';