dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34533
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17700: app for clearing dhis2 related browser cache
------------------------------------------------------------
revno: 17700
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-12-15 15:00:00 +0100
message:
app for clearing dhis2 related browser cache
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/app.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.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-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html
--
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/relationship/relationship-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2014-12-08 15:56:07 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js 2014-12-15 14:00:00 +0000
@@ -25,6 +25,7 @@
$scope.trackedEntity = $scope.selections.te;
$scope.selectedEnrollment = $scope.selections.enrollment;
$scope.selectedProgram = $scope.selections.pr;
+ console.log('the program leading to relationship is: ', $scope.selectedProgram);
if($scope.selectedProgram && $scope.selectedProgram.relationshipText){
$scope.addRelationshipLabel = $scope.selectedProgram.relationshipText;
}
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2014-12-09 23:24:16 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html 2014-12-15 14:00:00 +0000
@@ -71,12 +71,16 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
<!--<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>-->
+
+ <script src="../dhis-web-commons/ouwt/ouwt.js"></script>
+ <script src="scripts/tracker-capture.js"></script>
+ <!--<script src="scripts/idxdb.js"></script>-->
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/select2.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angularjs-nvd3-directives.min.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angularLocalStorage.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate.min.js"></script>
- <!--<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/dhis2/directives.js"></script>-->
+ <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/dhis2/directives.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/dhis2/filters.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/dhis2/services.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/dhis2/controllers.js"></script>
@@ -88,7 +92,6 @@
<script type="text/javascript" src="scripts/controllers.js"></script>
<script type="text/javascript" src="scripts/leftbar-menu-controller.js"></script>
<script type="text/javascript" src="scripts/report-types-controller.js"></script>
- <!--<script type="text/javascript" src="scripts/tracker-capture.js"></script>-->
<script type="text/javascript" src="scripts/ng-csv.js"></script>
<script type="text/javascript" src="components/dashboard/dashboard-controller.js"></script>
<script type="text/javascript" src="components/dashboard/dashboard-widgets-controller.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/app.js 2014-12-09 23:24:16 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/app.js 2014-12-15 14:00:00 +0000
@@ -11,6 +11,7 @@
'trackerCaptureFilters',
'trackerCaptureDirectives',
'trackerCaptureControllers',
+ 'd2Directives',
'd2Filters',
'd2Services',
'd2Controllers',
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js 2014-12-09 23:24:16 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/directives.js 2014-12-15 14:00:00 +0000
@@ -2,9 +2,9 @@
/* Directives */
-var trackerCaptureDirectives = angular.module('trackerCaptureDirectives', [])
+var trackerCaptureDirectives = angular.module('trackerCaptureDirectives', []);
-.directive('inputValidator', function() {
+/*.directive('inputValidator', function() {
return {
require: 'ngModel',
@@ -276,4 +276,4 @@
}
});
};
-});
\ No newline at end of file
+});*/
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-12-09 23:24:16 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2014-12-15 14:00:00 +0000
@@ -4,26 +4,113 @@
var trackerCaptureServices = angular.module('trackerCaptureServices', ['ngResource'])
-.factory('StorageService', function(){
+.factory('TCStorageService', function(){
var store = new dhis2.storage.Store({
name: "dhis2tc",
adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
- objectStores: ['tcPrograms', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes','optionSets']
+ objectStores: ['programs', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes', 'relationshipTypes', 'optionSets']
});
return{
currentStore: store
};
})
+/* Factory to fetch geojsons */
+.factory('GeoJsonFactory', function($q, $rootScope, TCStorageService) {
+ return {
+ getAll: function(){
+
+ var def = $q.defer();
+
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.getAll('geoJsons').done(function(geoJsons){
+ $rootScope.$apply(function(){
+ def.resolve(geoJsons);
+ });
+ });
+ });
+
+ return def.promise;
+ },
+ get: function(level){
+
+ var def = $q.defer();
+
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.get('geoJsons', level).done(function(geoJson){
+ $rootScope.$apply(function(){
+ def.resolve(geoJson);
+ });
+ });
+ });
+ return def.promise;
+ }
+ };
+})
+
+/* Factory to fetch optionSets */
+.factory('OptionSetService', function($q, $rootScope, TCStorageService) {
+ return {
+ getAll: function(){
+
+ var def = $q.defer();
+
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.getAll('optionSets').done(function(optionSets){
+ $rootScope.$apply(function(){
+ def.resolve(optionSets);
+ });
+ });
+ });
+
+ return def.promise;
+ },
+ get: function(uid){
+
+ var def = $q.defer();
+
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.get('optionSets', uid).done(function(optionSet){
+ $rootScope.$apply(function(){
+ def.resolve(optionSet);
+ });
+ });
+ });
+ return def.promise;
+ },
+ getCode: function(options, key){
+ if(options){
+ for(var i=0; i<options.length; i++){
+ if( key === options[i].name){
+ return options[i].code;
+ }
+ }
+ }
+ return key;
+ },
+ getName: function(options, key){
+ if(options){
+ for(var i=0; i<options.length; i++){
+ if( key === options[i].code){
+ return options[i].name;
+ }
+ }
+ }
+ return key;
+ }
+ };
+})
+
+
/* Factory to fetch relationships */
-.factory('RelationshipFactory', function($q, $rootScope, StorageService) {
+.factory('RelationshipFactory', function($q, $rootScope, TCStorageService) {
return {
getAll: function(){
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.getAll('relationshipTypes').done(function(relationshipTypes){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.getAll('relationshipTypes').done(function(relationshipTypes){
$rootScope.$apply(function(){
def.resolve(relationshipTypes);
});
@@ -36,8 +123,8 @@
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.get('relationshipTypes', uid).done(function(relationshipType){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.get('relationshipTypes', uid).done(function(relationshipType){
$rootScope.$apply(function(){
def.resolve(relationshipType);
});
@@ -49,19 +136,25 @@
})
/* Factory to fetch programs */
-.factory('ProgramFactory', function($q, $rootScope, StorageService) {
+.factory('ProgramFactory', function($q, $rootScope, TCStorageService) {
return {
getAll: function(){
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.getAll('tcPrograms').done(function(programs){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.getAll('programs').done(function(prs){
+ var programs = [];
+ angular.forEach(prs, function(pr){
+ if(pr.type === 1){
+ programs.push(pr);
+ }
+ });
$rootScope.$apply(function(){
def.resolve(programs);
- });
+ });
});
- });
+ });
return def.promise;
},
@@ -69,8 +162,8 @@
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.get('tcPrograms', uid).done(function(pr){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.get('programs', uid).done(function(pr){
$rootScope.$apply(function(){
def.resolve(pr);
});
@@ -82,13 +175,13 @@
})
/* Factory to fetch programStages */
-.factory('ProgramStageFactory', function($q, $rootScope, StorageService) {
+.factory('ProgramStageFactory', function($q, $rootScope, TCStorageService) {
return {
get: function(uid){
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.get('programStages', uid).done(function(pst){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.get('programStages', uid).done(function(pst){
$rootScope.$apply(function(){
def.resolve(pst);
});
@@ -104,8 +197,8 @@
stageIds.push(stage.id);
});
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.getAll('programStages').done(function(stages){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.getAll('programStages').done(function(stages){
angular.forEach(stages, function(stage){
if(stageIds.indexOf(stage.id) !== -1){
programStages.push(stage);
@@ -225,15 +318,15 @@
})
/* Service for getting tracked entity */
-.factory('TEService', function(StorageService, $q, $rootScope) {
+.factory('TEService', function(TCStorageService, $q, $rootScope) {
return {
getAll: function(){
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.getAll('trackedEntities').done(function(entities){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.getAll('trackedEntities').done(function(entities){
$rootScope.$apply(function(){
def.resolve(entities);
});
@@ -244,8 +337,8 @@
get: function(uid){
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.get('trackedEntities', uid).done(function(te){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.get('trackedEntities', uid).done(function(te){
$rootScope.$apply(function(){
def.resolve(te);
});
@@ -257,14 +350,14 @@
})
/* Service for getting tracked entity Form */
-.factory('TEFormService', function(StorageService, $q, $rootScope) {
+.factory('TEFormService', function(TCStorageService, $q, $rootScope) {
return {
getByProgram: function(programUid){
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.get('trackedEntityForms', programUid).done(function(te){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.get('trackedEntityForms', programUid).done(function(te){
$rootScope.$apply(function(){
def.resolve(te);
});
@@ -380,15 +473,15 @@
})
/* Factory for getting tracked entity attributes */
-.factory('AttributesFactory', function($q, $rootScope, StorageService, orderByFilter, DateUtils) {
+.factory('AttributesFactory', function($q, $rootScope, TCStorageService, orderByFilter, DateUtils) {
return {
getAll: function(){
var def = $q.defer();
- StorageService.currentStore.open().done(function(){
- StorageService.currentStore.getAll('attributes').done(function(attributes){
+ TCStorageService.currentStore.open().done(function(){
+ TCStorageService.currentStore.getAll('attributes').done(function(attributes){
$rootScope.$apply(function(){
def.resolve(attributes);
});
=== 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 2014-12-09 23:24:16 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js 2014-12-15 14:00:00 +0000
@@ -3,10 +3,6 @@
// whether current user has any organisation units
dhis2.tc.emptyOrganisationUnits = false;
-// Instance of the StorageManager
-dhis2.tc.storageManager = new StorageManager();
-
-var TC_STORE_NAME = "dhis2tc";
var i18n_no_orgunits = 'No organisation unit attached to current user, no data entry possible';
var i18n_offline_notification = 'You are offline, data will be stored locally';
var i18n_online_notification = 'You are online';
@@ -32,37 +28,9 @@
}
dhis2.tc.store = new dhis2.storage.Store({
- name: TC_STORE_NAME,
- objectStores: [
- {
- name: 'tcPrograms',
- adapters: adapters
- },
- {
- name: 'programStages',
- adapters: adapters
- },
- {
- name: 'trackedEntities',
- adapters: adapters
- },
- {
- name: 'trackedEntityForms',
- adapters: adapters
- },
- {
- name: 'attributes',
- adapters: adapters
- },
- {
- name: 'relationshipTypes',
- adapters: adapters
- },
- {
- name: 'optionSets',
- adapters: adapters
- }
- ]
+ name: 'dhis2tc',
+ adapters: [dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter],
+ objectStores: ['programs', 'programStages', 'trackedEntities', 'trackedEntityForms', 'attributes', 'relationshipTypes', 'optionSets']
});
(function($) {
@@ -95,23 +63,11 @@
{
if (loggedIn)
{
- if (dhis2.tc.storageManager.hasLocalData())
- {
- var message = i18n_need_to_sync_notification
- + ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
-
- setHeaderMessage(message);
-
- $('#sync_button').bind('click', uploadLocalData);
+ if (dhis2.tc.emptyOrganisationUnits) {
+ setHeaderMessage(i18n_no_orgunits);
}
- else
- {
- if (dhis2.tc.emptyOrganisationUnits) {
- setHeaderMessage(i18n_no_orgunits);
- }
- else {
- setHeaderDelayMessage(i18n_online_notification);
- }
+ else {
+ setHeaderDelayMessage(i18n_online_notification);
}
}
else
@@ -162,7 +118,9 @@
});
//stop date picker's event bubling
-$(document).on('click.dropdown touchstart.dropdown.data-api', '#ui-datepicker-div', function (e) { e.stopPropagation() });
+$(document).on('click.dropdown touchstart.dropdown.data-api', '#ui-datepicker-div', function (e) {
+ e.stopPropagation();
+});
$(window).resize(function() {
$("#selectDropDown").width($("#selectDropDownParent").width());
@@ -211,6 +169,7 @@
promise = promise.then( getMetaTrackedEntityForms );
promise = promise.then( getTrackedEntityForms );
promise.done(function() {
+ console.log( 'Finished loading meta-data' );
selection.responseReceived();
});
@@ -401,7 +360,7 @@
build = build.then(function() {
var d = $.Deferred();
var p = d.promise();
- dhis2.tc.store.get('tcPrograms', program.id).done(function(obj) {
+ dhis2.tc.store.get('programs', program.id).done(function(obj) {
if(!obj || obj.version !== program.version) {
promise = promise.then( getProgram( program.id ) );
}
@@ -432,7 +391,7 @@
return $.ajax( {
url: '../api/programs.json',
type: 'GET',
- data: 'paging=false&filter=id:eq:' + id +'&fields=id,name,version,dataEntryMethod,relationshipText,relationshipFromA,dateOfEnrollmentDescription,dateOfIncidentDescription,displayIncidentDate,ignoreOverdueEvents,realionshipText,relationshipFromA,selectEnrollmentDatesInFuture,selectIncidentDatesInFuture,onlyEnrollOnce,externalAccess,displayOnAllOrgunit,registration,trackedEntity[id,name,description],userRoles[id,name],organisationUnits[id,name],programStages[id,name,version,minDaysFromStart,standardInterval,generatedByEnrollmentDate,reportDateDescription,repeatable,autoGenerateEvent,openAfterEnrollment,reportDateToUse],programTrackedEntityAttributes[displayInList,mandatory,allowFutureDate,trackedEntityAttribute[id]]'
+ data: 'paging=false&filter=id:eq:' + id +'&fields=id,name,type,version,dataEntryMethod,relationshipText,relationshipFromA,dateOfEnrollmentDescription,dateOfIncidentDescription,displayIncidentDate,ignoreOverdueEvents,realionshipText,relationshipFromA,selectEnrollmentDatesInFuture,selectIncidentDatesInFuture,onlyEnrollOnce,externalAccess,displayOnAllOrgunit,registration,trackedEntity[id,name,description],userRoles[id,name],organisationUnits[id,name],programStages[id,name,version,minDaysFromStart,standardInterval,generatedByEnrollmentDate,reportDateDescription,repeatable,autoGenerateEvent,openAfterEnrollment,reportDateToUse],programTrackedEntityAttributes[displayInList,mandatory,allowFutureDate,trackedEntityAttribute[id]]'
}).done( function( response ){
_.each( _.values( response.programs ), function ( program ) {
@@ -451,7 +410,7 @@
program.userRoles = ur;
- dhis2.tc.store.set( 'tcPrograms', program );
+ dhis2.tc.store.set( 'programs', program );
});
});
@@ -677,270 +636,4 @@
});
});
};
-}
-
-function uploadLocalData()
-{
- if (!dhis2.tc.storageManager.hasLocalData())
- {
- return;
- }
-
- setHeaderWaitMessage(i18n_uploading_data_notification);
-
- var events = dhis2.tc.storageManager.getEventsAsArray();
-
- _.each(_.values(events), function(event) {
-
- if (event.hasOwnProperty('src')) {
- if (event.src == 'local') {
- delete event.event;
- }
-
- delete event.src;
- }
- });
-
- events = {eventList: events};
-
- //jackson insists for valid json, where properties are bounded with ""
- events = JSON.stringify(events);
-
- $.ajax({
- url: '../api/events.json',
- type: 'POST',
- data: events,
- contentType: 'application/json',
- success: function()
- {
- dhis2.tc.storageManager.clear();
- log('Successfully uploaded local events');
- setHeaderDelayMessage(i18n_sync_success);
- //selection.responseReceived(); //notify angular
- },
- error: function(xhr)
- {
- if (409 == xhr.status) // Invalid event
- {
- // there is something wrong with the data - ignore for now.
-
- dhis2.tc.storageManager.clear();
- }
- else // Connection lost during upload
- {
- var message = i18n_sync_failed
- + ' <button id="sync_button" type="button">' + i18n_sync_now + '</button>';
-
- setHeaderMessage(message);
- $('#sync_button').bind('click', uploadLocalData);
- }
- }
- });
-}
-
-// -----------------------------------------------------------------------------
-// StorageManager
-// -----------------------------------------------------------------------------
-
-/**
- * This object provides utility methods for localStorage and manages data entry
- * forms and data values.
- */
-function StorageManager()
-{
- var MAX_SIZE = new Number(2600000);
-
- /**
- * Returns the total number of characters currently in the local storage.
- *
- * @return number of characters.
- */
- this.totalSize = function()
- {
- var totalSize = new Number();
-
- for (var i = 0; i < localStorage.length; i++)
- {
- var value = localStorage.key(i);
-
- if (value)
- {
- totalSize += value.length;
- }
- }
-
- return totalSize;
- };
-
- /**
- * Return the remaining capacity of the local storage in characters, ie. the
- * maximum size minus the current size.
- */
- this.remainingStorage = function()
- {
- return MAX_SIZE - this.totalSize();
- };
-
- /**
- * Clears stored events.
- */
- this.clear = function()
- {
- localStorage.removeItem(TRACKER_VALUES);
- };
-
- /**
- * Saves an event
- *
- * @param event The event in json format.
- */
- this.saveEvent = function(event)
- {
- //var newEvent = event;
-
- if (!event.hasOwnProperty('src'))
- {
- if (!event.event) {
- event.event = this.generatePseudoUid();
- event.src = 'local';
- }
- }
-
- var events = {};
-
- if (localStorage[TRACKER_VALUES] != null)
- {
- events = JSON.parse(localStorage[TRACKER_VALUES]);
- }
-
- events[event.event] = event;
-
- try
- {
- localStorage[TRACKER_VALUES] = JSON.stringify(events);
-
- log('Successfully stored event - locally');
- }
- catch (e)
- {
- log('Max local storage quota reached, not storing data value locally');
- }
- };
-
- /**
- * Gets the value for the event with the given arguments, or null if it
- * does not exist.
- *
- * @param id the event identifier.
- *
- */
- this.getEvent = function(id)
- {
- if (localStorage[TRACKER_VALUES] != null)
- {
- var events = JSON.parse(localStorage[TRACKER_VALUES]);
-
- return events[id];
- }
-
- return null;
- };
-
- /**
- * Removes the given event from localStorage.
- *
- * @param event and identifiers in json format.
- */
- this.clearEvent = function(event)
- {
- var events = this.getAllEvents();
-
- if (events != null && events[event.event] != null)
- {
- delete events[event.event];
- localStorage[TRACKER_VALUES] = JSON.stringify(events);
- }
- };
-
- /**
- * Returns events matching the arguments provided
- *
- * @param orgUnit
- * @param programStage
- *
- * @return a JSON associative array.
- */
- this.getEvents = function(orgUnit, programStage)
- {
- var events = this.getEventsAsArray();
- var match = [];
- for (var i = 0; i < events.length; i++) {
- if (events[i].orgUnit == orgUnit && events[i].programStage == programStage) {
- match.push(events[i]);
- }
- }
-
- return match;
- };
-
- /**
- *
- * @return a JSON associative array.
- */
- this.getAllEvents = function()
- {
- return localStorage[TRACKER_VALUES] != null ? JSON.parse(localStorage[TRACKER_VALUES]) : null;
- };
-
- /**
- * Returns all event objects in an array. Returns an empty array if no
- * event exist. Items in array are guaranteed not to be undefined.
- */
- this.getEventsAsArray = function()
- {
- var values = new Array();
- var events = this.getAllEvents();
-
- if (undefined == events)
- {
- return values;
- }
-
- for (i in events)
- {
- if (events.hasOwnProperty(i) && undefined !== events[i])
- {
- values.push(events[i]);
- }
- }
-
- return values;
- };
-
- /**
- * Indicates whether there exists data values or complete data set
- * registrations in the local storage.
- *
- * @return true if local data exists, false otherwise.
- */
- this.hasLocalData = function()
- {
- var events = this.getAllEvents();
-
- if (events == null)
- {
- return false;
- }
- if (Object.keys(events).length < 1)
- {
- return false;
- }
-
- return true;
- };
-
- this.generatePseudoUid = function()
- {
- return Math.random().toString(36).substr(2, 11);
- };
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html 2014-10-23 14:40:31 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/views/home.html 2014-12-15 14:00:00 +0000
@@ -1,5 +1,34 @@
-<script src="../dhis-web-commons/ouwt/ouwt.js"></script>
-<script src="scripts/tracker-capture.js"></script>
+<!--<script src="../dhis-web-commons/ouwt/ouwt.js"></script>
+<script src="scripts/tracker-capture.js"></script>-->
+
+<script>
+ $(".select-dropdown-button").on('click', function (e) {
+ $("#selectDropDown").width($("#selectDropDownParent").width());
+ e.stopPropagation();
+ $("#selectDropDown").dropdown('toggle');
+ });
+ $(".select-dropdown-caret").on('click', function (e) {
+ $("#selectDropDown").width($("#selectDropDownParent").width());
+ e.stopPropagation();
+ $("#selectDropDown").dropdown('toggle');
+ });
+ $(".search-dropdown-button").on('click', function () {
+ $("#searchDropDown").width($("#searchDropDownParent").width());
+ });
+ $('#searchDropDown').on('click', "[data-stop-propagation]", function (e) {
+ e.stopPropagation();
+ });
+
+ //stop date picker's event bubling
+ $(document).on('click.dropdown touchstart.dropdown.data-api', '#ui-datepicker-div', function (e) {
+ e.stopPropagation();
+ });
+
+ $(window).resize(function () {
+ $("#selectDropDown").width($("#selectDropDownParent").width());
+ $("#searchDropDown").width($("#searchDropDownParent").width());
+ });
+</script>
<div id="leftBar">