dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22148
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10625: wip, offline completeness for anonmyous programs
------------------------------------------------------------
revno: 10625
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-04-18 22:23:00 +0700
message:
wip, offline completeness for anonmyous programs
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.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/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java 2013-04-16 02:02:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CompleteDataEntryAction.java 2013-04-18 15:23:00 +0000
@@ -115,6 +115,11 @@
public String execute()
throws Exception
{
+ if ( programStageInstanceId == null )
+ {
+ return INPUT;
+ }
+
ProgramStageInstance programStageInstance = programStageInstanceService
.getProgramStageInstance( programStageInstanceId );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java 2013-04-18 12:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/UploadAnonymousEventAction.java 2013-04-18 15:23:00 +0000
@@ -139,6 +139,8 @@
Boolean completed = (Boolean) executionDate.get( "completed" );
+ System.err.println( "Completed: " + completed );
+
ProgramStageInstance programStageInstance = saveExecutionDate( programId, organisationUnitId, date, completed );
Map<String, Object> values = (Map<String, Object>) input.get( "values" );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm 2013-04-18 13:24:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/anonymousRegistration.vm 2013-04-18 15:23:00 +0000
@@ -190,7 +190,7 @@
var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
var i18n_date_is_greater_then_or_equals_due_date = '$encoder.jsEscape( $i18n.getString( "date_is_greater_then_or_equals_due_date" ) , "'")';
-
+
var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
var i18n_specify_data_element = '$encoder.jsEscape( $i18n.getString( "specify_data_element" ) , "'")';
@@ -203,7 +203,7 @@
var i18n_remove_empty_events_success = '$encoder.jsEscape( $i18n.getString( "remove_empty_events_success" ) , "'")';
var i18n_confirm_remove_empty_events = '$encoder.jsEscape( $i18n.getString( "confirm_remove_empty_events" ) , "'")';
var i18n_report_date = '$encoder.jsEscape( $i18n.getString( "report_date" ) , "'")';
-
+
var i18n_male = '$encoder.jsEscape( $i18n.getString( "male" ) , "'")';
var i18n_female = '$encoder.jsEscape( $i18n.getString( "female" ) , "'")';
var i18n_transgender = '$encoder.jsEscape( $i18n.getString( "transgender" ) , "'")';
@@ -222,6 +222,7 @@
var i18n_sync_success = '$encoder.jsEscape( $i18n.getString( "sync_success" ) , "'")';
var i18n_sync_failed = '$encoder.jsEscape( $i18n.getString( "sync_failed" ) , "'")';
var i18n_uploading_data_notification = '$encoder.jsEscape( $i18n.getString( "uploading_data_notification" ) , "'")';
+ var i18n_incomplete_confirm_message = '$encoder.jsEscape( $i18n.getString( "incomplete_confirm_message" ) , "'")';
isAjax = true;
contentDiv = '';
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm 2013-04-16 03:30:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm 2013-04-18 15:23:00 +0000
@@ -22,6 +22,7 @@
../dhis-web-commons/javascripts/periodType.js
../dhis-web-commons/javascripts/date.js
../dhis-web-commons/javascripts/dhis2/dhis2.util.js
+../dhis-web-commons/javascripts/dhis2/dhis2.trigger.js
../dhis-web-commons/javascripts/dhis2/dhis2.array.js
../dhis-web-commons/javascripts/dhis2/dhis2.select.js
../dhis-web-commons/javascripts/dhis2/dhis2.comparator.js
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-04-18 13:24:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-04-18 15:23:00 +0000
@@ -39,6 +39,8 @@
} ).fail( function () {
selection.setListenerFunction( organisationUnitSelected );
$( document ).trigger('dhis2.anonymous.programsInitialized');
+
+ DAO.optionSets = new dhis2.storage.Store( {name: OPTION_SET_STORE, adapter: 'dom-ss'}, function() {} );
} );
} );
}
@@ -876,6 +878,8 @@
var data = {};
data.executionDate = createExecutionDate(programId, programStageInstanceId, executionDate, organisationUnitId);
+ data.executionDate.completed = false;
+
DAO.offlineData.add(programStageInstanceId, data);
});
} else {
=== 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-04-18 13:24:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2013-04-18 15:23:00 +0000
@@ -539,9 +539,14 @@
}else {
if( confirm(i18n_complete_confirm_message) )
{
- $.postJSON( "completeDataEntry.action", {
- programStageInstanceId: getFieldValue( 'programStageInstanceId' )
- }, function (json) {
+ $.ajax({
+ url: 'completeDataEntry.action',
+ dataType: 'json',
+ data: {
+ programStageInstanceId: getFieldValue( 'programStageInstanceId' )
+ },
+ type: 'POST'
+ } ).done(function(json) {
jQuery(".stage-object-selected").css('border-color', COLOR_GREEN);
jQuery(".stage-object-selected").css('background-color', COLOR_LIGHT_GREEN);
@@ -572,6 +577,7 @@
}
disableCompletedButton(true);
+
var eventBox = jQuery('#ps_' + getFieldValue('programStageInstanceId'));
eventBox.attr('status',1);
resetActiveEvent( eventBox.attr("pi") );
@@ -581,6 +587,32 @@
if ( isCreateEvent ) {
showAddEventForm();
}
+ } ).fail(function() {
+ if ( getProgramType() == 3 ) {
+ var programStageInstanceId = getFieldValue( 'programStageInstanceId' );
+
+ if ( window.DAO && window.DAO.offlineData ) {
+ jQuery(".stage-object-selected").css('border-color', COLOR_GREEN);
+ jQuery(".stage-object-selected").css('background-color', COLOR_LIGHT_GREEN);
+
+ DAO.offlineData.fetch( programStageInstanceId, function ( store, arr ) {
+ if ( arr.length > 0 ) {
+ var obj = arr[0];
+ obj.executionDate.completed = true;
+ DAO.offlineData.add( programStageInstanceId, obj );
+ }
+ } );
+
+ var blocked = jQuery('#entryFormContainer [id=blockEntryForm]').val();
+
+ if( blocked=='true' ) {
+ blockEntryForm();
+ }
+
+ disableCompletedButton(true);
+ hideLoader();
+ }
+ }
});
}
}
@@ -590,9 +622,14 @@
{
if( confirm(i18n_incomplete_confirm_message) )
{
- $.postJSON( "uncompleteDataEntry.action", {
- programStageInstanceId: getFieldValue('programStageInstanceId')
- }, function (data) {
+ $.ajax({
+ url: 'uncompleteDataEntry.action',
+ dataType: 'json',
+ data: {
+ programStageInstanceId: getFieldValue( 'programStageInstanceId' )
+ },
+ type: 'POST'
+ } ).done(function(json) {
jQuery(".stage-object-selected").css('border-color', COLOR_LIGHTRED);
jQuery(".stage-object-selected").css('background-color', COLOR_LIGHT_LIGHTRED);
unblockEntryForm();
@@ -600,6 +637,23 @@
var eventBox = jQuery('#ps_' + getFieldValue('programStageInstanceId'));
eventBox.attr('status',2);
resetActiveEvent( eventBox.attr("pi") );
+ } ).fail(function() {
+ if ( getProgramType() == 3 ) {
+ var programStageInstanceId = getFieldValue( 'programStageInstanceId' );
+
+ if ( window.DAO && window.DAO.offlineData ) {
+ DAO.offlineData.fetch( programStageInstanceId, function ( store, arr ) {
+ if ( arr.length > 0 ) {
+ var obj = arr[0];
+ obj.executionDate.completed = false;
+ DAO.offlineData.add( programStageInstanceId, obj );
+ }
+ } );
+ }
+
+ unblockEntryForm();
+ disableCompletedButton(false);
+ }
});
}
}
@@ -916,13 +970,13 @@
minLength: 0,
select: function( event, ui ) {
var fieldValue = ui.item.value;
-
+
if ( !dhis2.trigger.invoke( "caseentry-value-selected", [dataElementUid, fieldValue] ) ) {
input.val( "" );
return false;
}
-
- input.val( fieldValue );
+
+ input.val( fieldValue );
if ( !unSave ) {
saveVal( dataElementUid );
}