dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25036
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12342: Data entry, setting complete/incomplete button according to locally stored complete registrations...
------------------------------------------------------------
revno: 12342
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-09-30 17:52:24 +0200
message:
Data entry, setting complete/incomplete button according to locally stored complete registrations when offline
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-commons-resources/src/main/webapp/cacheManifest.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm 2013-09-27 12:55:38 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm 2013-09-30 15:52:24 +0000
@@ -1,5 +1,5 @@
CACHE MANIFEST
-# 2.13-SNAPSHOT V12
+# 2.13-SNAPSHOT V13
NETWORK:
*
CACHE:
@@ -53,5 +53,7 @@
../images/transparent.gif
../images/ajax-loader-circle.gif
../images/ajax-loader-bar.gif
+../images/warning_small.png
+../images/success_small.png
../dhis-web-dataentry/javascript/form.js
../dhis-web-dataentry/javascript/entry.js
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2013-09-30 15:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2013-09-30 15:52:24 +0000
@@ -1060,22 +1060,23 @@
$( '.entryfield' ).filter( ':disabled' ).css( 'background-color', COLOR_GREY );
+ var params = {
+ periodId : periodId,
+ dataSetId : dataSetId,
+ organisationUnitId : getCurrentOrganisationUnit(),
+ multiOrganisationUnit: multiOrganisationUnit
+ };
+
$.ajax( {
url: 'getDataValues.action',
- data:
- {
- periodId : periodId,
- dataSetId : dataSetId,
- organisationUnitId : getCurrentOrganisationUnit(),
- multiOrganisationUnit: multiOrganisationUnit
- },
+ data: params,
dataType: 'json',
error: function() // offline
{
$( '#completenessDiv' ).show();
$( '#infoDiv' ).hide();
- var json = getOfflineDataValueJson( periodId );
+ var json = getOfflineDataValueJson( params );
insertDataValues( json );
},
@@ -1090,14 +1091,15 @@
} );
}
-function getOfflineDataValueJson( periodId )
+function getOfflineDataValueJson( params )
{
- var dataValues = storageManager.getDataValuesInForm( periodId, getCurrentOrganisationUnit() );
+ var dataValues = storageManager.getDataValuesInForm( params );
+ var complete = storageManager.hasCompleteDataSet( params );
var json = {};
json.dataValues = new Array();
json.locked = false;
- json.complete = false;
+ json.complete = complete;
json.date = "";
json.storedBy = "";
@@ -2008,10 +2010,9 @@
* Returns the data values for the given period and organisation unit
* identifiers as an array.
*
- * @param periodId the period identifier.
- * @param organisationUnitId the organisation unit identifier.
+ * @param json object with periodId and organisationUnitId properties.
*/
- this.getDataValuesInForm = function( periodId, organisationUnitId )
+ this.getDataValuesInForm = function( json )
{
var dataValues = this.getDataValuesAsArray();
var valuesInForm = new Array();
@@ -2020,7 +2021,7 @@
{
var val = dataValues[i];
- if ( val.periodId == periodId && val.organisationUnitId == organisationUnitId )
+ if ( val.periodId == json.periodId && val.organisationUnitId == json.organisationUnitId )
{
valuesInForm.push( val );
}
@@ -2106,14 +2107,6 @@
};
/**
- * Generates an identifier based on the given data value object.
- */
- this.getDataValueId = function( dv )
- {
- return dv.dataElementId + '-' + dv.categoryOptionComboId + '-' + dv.periodId + '-' + dv.organisationUnitId;
- }
-
- /**
* Generates an identifier.
*/
this.getCompleteDataSetId = function( json )
@@ -2183,6 +2176,25 @@
log( 'Max local storage quota reached, not storing complete registration locally' );
}
};
+
+ /**
+ * Indicates whether a complete data set registration exists for the given
+ * argument.
+ *
+ * @param json object with periodId, dataSetId, organisationUnitId properties.
+ */
+ this.hasCompleteDataSet = function( json )
+ {
+ var id = this.getCompleteDataSetId( json );
+ var registrations = this.getCompleteDataSets();
+
+ if ( null != registrations && undefined !== registrations && undefined !== registrations[id] )
+ {
+ return true;
+ }
+
+ return false;
+ }
/**
* Removes the given complete data set registration.