dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22581
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10889: store and load coordinates in the browser if offline (no upload yet)
------------------------------------------------------------
revno: 10889
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-05-19 13:46:31 +0700
message:
store and load coordinates in the browser if offline (no upload yet)
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.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-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-05-19 06:23:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js 2013-05-19 06:46:31 +0000
@@ -2032,6 +2032,19 @@
} ).done(function() {
byId( 'longitude' ).style.backgroundColor = SUCCESS_COLOR;
byId( 'latitude' ).style.backgroundColor = SUCCESS_COLOR;
+ } ).fail(function() {
+ if(DAO.store && programStageInstanceId.indexOf('local') != -1 ) {
+ DAO.store.get( 'dataValues', programStageInstanceId ).done( function ( data ) {
+ data.coordinates = {};
+ data.coordinates.longitude = longitude;
+ data.coordinates.latitude = latitude;
+
+ this.set( 'dataValues', data ).done( function () {
+ byId( 'longitude' ).style.backgroundColor = SUCCESS_COLOR;
+ byId( 'latitude' ).style.backgroundColor = SUCCESS_COLOR;
+ } );
+ } );
+ }
});
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2013-05-19 05:57:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2013-05-19 06:46:31 +0000
@@ -725,15 +725,22 @@
$( "#entryFormContainer input[id='programStageInstanceId']" ).val( programStageInstanceId );
DAO.store.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
- if(obj && obj.values !== undefined ) {
- _.each( _.keys(obj.values), function(key, idx) {
- var fieldId = getProgramStageUid() + '-' + key + '-val';
- var field = $('#' + fieldId);
-
- if ( field ) {
- field.val( decodeURI( obj.values[key].value ) );
- }
- });
+ if(obj ) {
+ if(obj.values !== undefined) {
+ _.each( _.keys(obj.values), function(key, idx) {
+ var fieldId = getProgramStageUid() + '-' + key + '-val';
+ var field = $('#' + fieldId);
+
+ if ( field ) {
+ field.val( decodeURI( obj.values[key].value ) );
+ }
+ });
+ }
+
+ if ( obj.coordinates !== undefined ) {
+ $( '#longitude' ).val( obj.coordinates.longitude );
+ $( '#latitude' ).val( obj.coordinates.latitude );
+ }
}
if( always ) always();