dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13466
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4333: Loading meta-data asynchronously
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4333 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-08-17 15:41:04 +0200
message:
Loading meta-data asynchronously
added:
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/PageInitAction.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
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/select.vm
--
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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-08-13 18:09:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-08-17 12:25:41 +0000
@@ -57,7 +57,6 @@
{
private static final String EMPTY_VALUE_TAG = "value=\"\"";
private static final String EMPTY_TITLE_TAG = "title=\"\"";
- private static final String STYLE_TAG = "style=\"";
private static final String TAG_CLOSE = "/>";
private static final String EMPTY = "";
@@ -286,8 +285,6 @@
inputHtml = inputHtml.contains( EMPTY_TITLE_TAG ) ? inputHtml.replace( EMPTY_TITLE_TAG, title ) : inputHtml + " " + title;
- String backgroundColor = "style=\"";
-
String appendCode = "";
if ( dataElement.getType().equals( VALUE_TYPE_BOOL ) )
@@ -306,8 +303,6 @@
inputHtml = inputHtml.replace( TAG_CLOSE, appendCode );
- inputHtml = inputHtml.replace( STYLE_TAG, backgroundColor );
-
inputMatcher.appendReplacement( sb, inputHtml );
}
}
=== added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java 2011-08-17 13:41:04 +0000
@@ -0,0 +1,166 @@
+package org.hisp.dhis.de.action;
+
+/*
+ * Copyright (c) 2004-2010, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.expression.ExpressionService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.organisationunit.OrganisationUnitDataSetAssociationSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class GetMetaDataAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ private IndicatorService indicatorService;
+
+ public void setIndicatorService( IndicatorService indicatorService )
+ {
+ this.indicatorService = indicatorService;
+ }
+
+ private ExpressionService expressionService;
+
+ public void setExpressionService( ExpressionService expressionService )
+ {
+ this.expressionService = expressionService;
+ }
+
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Collection<DataElement> significantZeros;
+
+ public Collection<DataElement> getSignificantZeros()
+ {
+ return significantZeros;
+ }
+
+ private Collection<DataElement> dataElements;
+
+ public Collection<DataElement> getDataElements()
+ {
+ return dataElements;
+ }
+
+ private Collection<Indicator> indicators;
+
+ public Collection<Indicator> getIndicators()
+ {
+ return indicators;
+ }
+
+ private Collection<DataSet> dataSets;
+
+ public Collection<DataSet> getDataSets()
+ {
+ return dataSets;
+ }
+
+ private List<Set<Integer>> dataSetAssociationSets;
+
+ public List<Set<Integer>> getDataSetAssociationSets()
+ {
+ return dataSetAssociationSets;
+ }
+
+ private Map<Integer, Integer> organisationUnitAssociationSetMap;
+
+ public Map<Integer, Integer> getOrganisationUnitAssociationSetMap()
+ {
+ return organisationUnitAssociationSetMap;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ significantZeros = dataElementService.getDataElementsByZeroIsSignificant( true );
+
+ dataElements = dataElementService.getDataElementsWithDataSets();
+
+ indicators = indicatorService.getIndicatorsWithDataSets();
+
+ OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet();
+
+ dataSetAssociationSets = organisationUnitSet.getDataSetAssociationSets();
+
+ organisationUnitAssociationSetMap = organisationUnitSet.getOrganisationUnitAssociationSetMap();
+
+ dataSets = dataSetService.getDataSets( organisationUnitSet.getDistinctDataSets() );
+
+ for ( Indicator indicator : indicators )
+ {
+ indicator.setExplodedNumerator( expressionService.explodeExpression( indicator.getNumerator() ) );
+ indicator.setExplodedDenominator( expressionService.explodeExpression( indicator.getDenominator() ) );
+ }
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/PageInitAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/PageInitAction.java 2011-08-13 10:41:20 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/PageInitAction.java 2011-08-17 13:41:04 +0000
@@ -27,20 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
-import org.hisp.dhis.expression.ExpressionService;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.organisationunit.OrganisationUnitDataSetAssociationSet;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
import com.opensymphony.xwork2.Action;
@@ -55,34 +41,6 @@
// Dependencies
// -------------------------------------------------------------------------
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
- private IndicatorService indicatorService;
-
- public void setIndicatorService( IndicatorService indicatorService )
- {
- this.indicatorService = indicatorService;
- }
-
- private ExpressionService expressionService;
-
- public void setExpressionService( ExpressionService expressionService )
- {
- this.expressionService = expressionService;
- }
-
- private DataSetService dataSetService;
-
- public void setDataSetService( DataSetService dataSetService )
- {
- this.dataSetService = dataSetService;
- }
-
private OrganisationUnitSelectionManager selectionManager;
public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
@@ -90,59 +48,6 @@
this.selectionManager = selectionManager;
}
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private Collection<DataElement> significantZeros;
-
- public Collection<DataElement> getSignificantZeros()
- {
- return significantZeros;
- }
-
- private Collection<DataElement> dataElements;
-
- public Collection<DataElement> getDataElements()
- {
- return dataElements;
- }
-
- private Collection<Indicator> indicators;
-
- public Collection<Indicator> getIndicators()
- {
- return indicators;
- }
-
- private Collection<DataSet> dataSets;
-
- public Collection<DataSet> getDataSets()
- {
- return dataSets;
- }
-
- private List<Set<Integer>> dataSetAssociationSets;
-
- public List<Set<Integer>> getDataSetAssociationSets()
- {
- return dataSetAssociationSets;
- }
-
- private Map<Integer, Integer> organisationUnitAssociationSetMap;
-
- public Map<Integer, Integer> getOrganisationUnitAssociationSetMap()
- {
- return organisationUnitAssociationSetMap;
- }
-
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -151,26 +56,6 @@
{
selectionManager.clearSelectedOrganisationUnits();
- significantZeros = dataElementService.getDataElementsByZeroIsSignificant( true );
-
- dataElements = dataElementService.getDataElementsWithDataSets();
-
- indicators = indicatorService.getIndicatorsWithDataSets();
-
- OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet();
-
- dataSetAssociationSets = organisationUnitSet.getDataSetAssociationSets();
-
- organisationUnitAssociationSetMap = organisationUnitSet.getOrganisationUnitAssociationSetMap();
-
- dataSets = dataSetService.getDataSets( organisationUnitSet.getDistinctDataSets() );
-
- for ( Indicator indicator : indicators )
- {
- indicator.setExplodedNumerator( expressionService.explodeExpression( indicator.getNumerator() ) );
- indicator.setExplodedDenominator( expressionService.explodeExpression( indicator.getDenominator() ) );
- }
-
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-08-13 18:03:46 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-08-17 13:41:04 +0000
@@ -11,18 +11,19 @@
<!-- Actions -->
- <bean id="org.hisp.dhis.de.action.PageInitAction" class="org.hisp.dhis.de.action.PageInitAction"
- scope="prototype">
+ <bean id="org.hisp.dhis.de.action.PageInitAction" class="org.hisp.dhis.de.action.PageInitAction" scope="prototype">
+ <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+ </bean>
+
+ <bean id="org.hisp.dhis.de.action.GetMetaDataAction" class="org.hisp.dhis.de.action.GetMetaDataAction" scope="prototype">
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
</bean>
-
- <bean id="org.hisp.dhis.de.action.GetDataValuesForDataSetAction" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction"
- scope="prototype">
+
+ <bean id="org.hisp.dhis.de.action.GetDataValuesForDataSetAction" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction" scope="prototype">
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
<property name="minMaxDataElementService" ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2011-08-16 14:47:35 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2011-08-17 13:41:04 +0000
@@ -18,6 +18,10 @@
<param name="stylesheets">style/dhis-web-dataentry.css</param>
<param name="offline">true</param>
</action>
+
+ <action name="getMetaData" class="org.hisp.dhis.de.action.GetMetaDataAction">
+ <result name="success" type="velocity-json">/dhis-web-dataentry/responseMetaData.vm</result>
+ </action>
<action name="getDataValues" class="org.hisp.dhis.de.action.GetDataValuesForDataSetAction">
<result name="success" type="velocity-json">/dhis-web-dataentry/responseDataValues.vm</result>
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-16 18:57:34 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-08-17 13:41:04 +0000
@@ -3,9 +3,10 @@
*
* Format for the span/input identifiers for selectors:
*
- * {dataelementid}-{optioncomboid}-val // data value {dataelementid}-dataelement //
- * name of data element {optioncomboid}-optioncombo // name of category option
- * combo {dataelementid}-cell // table cell for data element name
+ * {dataelementid}-{optioncomboid}-val // data value
+ * {dataelementid}-dataelement name of data element
+ * {optioncomboid}-optioncombo // name of category option combo
+ * {dataelementid}-cell // table cell for data element name
* {dataelementid}-{optioncomboid}-min // min value for data value
* {dataelementid}-{optioncomboid}-max // max value for data value
*
@@ -204,25 +205,6 @@
return false;
}
-function saveDataValuesInLocalStorage() {
- var dataValues = storageManager.getAllDataValues();
-
- for(var dataValueKey in dataValues) {
- var dataValue = dataValues[dataValueKey];
-
- $.ajax( {
- url : "saveValue.action",
- data : dataValue,
- dataType : 'json',
- dataValue: dataValue,
- success : function( data, textStatus, jqXHR ) {
- storageManager.clearDataValueJSON( this.dataValue );
- console.log("Successfully saved dataValue with value " + this.dataValue );
- }
- } );
- }
-}
-
// -----------------------------------------------------------------------------
// Saver objects
// -----------------------------------------------------------------------------
=== 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 2011-08-17 13:38:07 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-08-17 13:41:04 +0000
@@ -1,22 +1,21 @@
-// Identifiers for which zero values are insignificant, also used in entry.js, populated in select.vm
+// Identifiers for which zero values are insignificant, also used in entry.js
var significantZeros = [];
// Array with associative arrays for each data element, populated in select.vm
var dataElements = [];
// Associative array with [indicator id, expression] for indicators in form,
-// also used in entry.js, populated in select.vm
+// also used in entry.js
var indicatorFormulas = [];
// Array with associative arrays for each data set, populated in select.vm
var dataSets = [];
-// Associative array with identifier and array of assigned data sets, populated
-// in select.vm
+// Associative array with identifier and array of assigned data sets
var dataSetAssociationSets = [];
// Associate array with mapping between organisation unit identifier and data
-// set association set identifier, populated in select.vm
+// set association set identifier
var organisationUnitAssociationSetMap = [];
// Array with keys on form {dataelementid}-{optioncomboid}-min/max with min/max
@@ -48,58 +47,104 @@
var COLOR_ORANGE = '#ff6600';
var COLOR_WHITE = '#ffffff';
-// Page init
-
+/**
+ * Page init. The order of events is:
+ *
+ * 1. Load ouwt
+ * 2. Load meta-data
+ * 3. Upload potential locally stored data values to server
+ * 4. Check and potentially download updated forms from server
+ */
$( document ).ready( function()
{
selection.setListenerFunction( organisationUnitSelected );
$( '#orgUnitTree' ).one( 'ouwtLoaded', function() {
- setTimeout( "updateForms();", 1500 ); // TODO improve
- saveDataValuesInLocalStorage();
- } );
-
- $(document).bind("dhis2.online", function(event, loggedIn) {
- if(loggedIn) {
- if(isHeaderMessageVisible()) {
- updateHeaderMessage( "Successful connection with server." )
- } else {
- setHeaderMessage( "Successful connection with server." )
- }
- } else {
- if(isHeaderMessageVisible()) {
- updateHeaderMessage( '<form style="display: inline;"><label for="username">Username</label><input name="username" id="username" type="text" size="10"/><label for="password">Password</label><input name="password" id="password" type="password" size="10"/><button id="login_button" type="button">Login</button></form>' )
- ajax_login();
- } else {
- setHeaderMessage( '<form style="display: inline;"><label for="username">Username</label><input name="username" id="username" type="text" size="10"/><label for="password">Password</label><input name="password" id="password" type="password" size="10"/><button id="login_button" type="button">Login</button></form>' )
- ajax_login();
- }
- }
- })
-
- $(document).bind("dhis2.offline", function() {
- if(isHeaderMessageVisible()) {
- updateHeaderMessage( "You are offline. Data will be stored locally." )
- } else {
- setHeaderMessage( "You are offline. Data will be stored locally." )
- }
- })
+ console.log( 'Ouwt loaded' );
+ loadMetaData();
+ } );
+
+ $( document ).bind( 'dhis2.online', function( event, loggedIn ) {
+ if( loggedIn ) {
+ if( isHeaderMessageVisible() ) {
+ updateHeaderMessage( 'You are online' );
+ } else {
+ setHeaderMessage( 'You are online' );
+ }
+ }
+ else {
+ if( isHeaderMessageVisible() ) {
+ updateHeaderMessage( '<form style="display: inline;"><label for="username">Username</label><input name="username" id="username" type="text" size="10"/><label for="password">Password</label><input name="password" id="password" type="password" size="10"/><button id="login_button" type="button">Login</button></form>' );
+ ajax_login();
+ } else {
+ setHeaderMessage( '<form style="display: inline;"><label for="username">Username</label><input name="username" id="username" type="text" size="10"/><label for="password">Password</label><input name="password" id="password" type="password" size="10"/><button id="login_button" type="button">Login</button></form>' );
+ ajax_login();
+ }
+ }
+ } );
+
+ $( document ).bind( 'dhis2.offline', function() {
+ if( isHeaderMessageVisible() ) {
+ updateHeaderMessage( 'You are offline. Data will be stored locally.' );
+ } else {
+ setHeaderMessage( 'You are offline. Data will be stored locally.' );
+ }
+ } );
dhis2.availability.startAvailabilityCheck();
} );
-function ajax_login() {
- $("#login_button").bind("click", function() {
- var username = $("#username").val();
- var password = $("#password").val();
-
- $.post("../dhis-web-commons-security/login.action", {
- "j_username": username,
- "j_password": password
- }).success(function() {
- alert("login attempt successful, TODO check if login was successful with checkAvailability");
- })
- })
+function loadMetaData()
+{
+ $.getJSON( 'getMetaData.action', function( json ) {
+ significantZeros = json.metaData.significantZeros;
+ dataElements = json.metaData.dataElements;
+ indicatorFormulas = json.metaData.indicatorFormulas;
+ dataSets = json.metaData.dataSets;
+ dataSetAssociationSets = json.metaData.dataSetAssociationSets;
+ organisationUnitAssociationSetMap = json.metaData.organisationUnitAssociationSetMap;
+
+ console.log( 'Meta-data loaded' );
+ uploadDataValuesInLocalStorage();
+ } );
+}
+
+function uploadDataValuesInLocalStorage()
+{
+ var dataValues = storageManager.getAllDataValues();
+
+ for ( var dataValueKey in dataValues )
+ {
+ var dataValue = dataValues[dataValueKey];
+
+ $.ajax( {
+ url : 'saveValue.action',
+ data : dataValue,
+ dataType : 'json',
+ dataValue: dataValue,
+ success : function( data, textStatus, jqXHR ) {
+ storageManager.clearDataValueJSON( this.dataValue );
+ console.log( 'Successfully saved data value with value: ' + this.dataValue );
+ }
+ } );
+ }
+
+ updateForms();
+}
+
+function ajax_login()
+{
+ $( '#login_button' ).bind( 'click', function() {
+ var username = $( '#username' ).val();
+ var password = $( '#password' ).val();
+
+ $.post( '../dhis-web-commons-security/login.action', {
+ 'j_username': username,
+ 'j_password': password
+ } ).success( function() {
+ alert( 'Login attempt successful, TODO check if login was successful with checkAvailability' );
+ } );
+ } );
}
function addEventListeners()
=== added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm 2011-08-17 13:41:04 +0000
@@ -0,0 +1,47 @@
+{ "metaData": {
+
+"significantZeros": [
+#set( $size = $significantZeros.size() )
+#foreach( $dataElement in $significantZeros )
+${dataElement.id}#if( $velocityCount < $size ),#end
+#end ],
+
+"dataElements": {
+#set( $size = $dataElements.size() )
+#foreach( $dataElement in $dataElements )
+"${dataElement.id}":{"name":"$encoder.jsonEncode( ${dataElement.name} )","type":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )"
+}#if( $velocityCount < $size ),#end
+#end },
+
+"indicatorFormulas": {
+#set( $size = $indicators.size() )
+#foreach( $indicator in $indicators )
+"${indicator.id}":"($!{indicator.explodedNumerator})/($!{indicator.explodedDenominator})*($!{indicator.indicatorType.factor})"
+#if( $velocityCount < $size ),#end
+#end },
+
+"dataSets": {
+#set( $size = $dataSets.size() )
+#foreach( $dataSet in $dataSets )
+"${dataSet.id}":{"name":"$encoder.jsonEncode( ${dataSet.name} )","periodType":"$encoder.jsonEncode( ${dataSet.periodType.name} )","version":"${dataSet.version}"
+}#if( $velocityCount < $size ),#end
+#end },
+
+"dataSetAssociationSets": {
+#set( $size1 = $dataSetAssociationSets.size() )
+#set( $index = 0 )
+#foreach( $associationSet in $dataSetAssociationSets )
+"${index}": [
+#set( $index = $index + 1 )
+#set( $size2 = $associationSet.size() )
+#foreach( $id in $associationSet )
+${id}#if( $velocityCount < $size2 ),#end
+#end ]#if( $velocityCount < $size1 ),#end
+#end },
+
+"organisationUnitAssociationSetMap": {
+#set( $size = $organisationUnitAssociationSetMap.size() )
+#foreach( $orgUnit in $organisationUnitAssociationSetMap.keySet() )
+"${orgUnit}":"$organisationUnitAssociationSetMap.get( ${orgUnit} )"#if( $velocityCount < $size ),#end
+#end }
+} }
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2011-08-16 13:40:15 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2011-08-17 13:41:04 +0000
@@ -25,51 +25,6 @@
var i18n_mark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "mark_value_for_followup" ) , "'")';
var i18n_unmark_value_for_followup = '$encoder.jsEscape( $i18n.getString( "unmark_value_for_followup" ) , "'")';
-significantZeros = [
-#set( $size1 = $significantZeros.size() )
-#foreach( $dataElement in $significantZeros )
-${dataElement.id}#if( $velocityCount < $size1 ),#end
-#end ];
-
-dataElements = {
-#set( $size2 = $dataElements.size() )
-#foreach( $dataElement in $dataElements )
-"${dataElement.id}":{"name":"$encoder.jsonEncode( ${dataElement.name} )","type":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )"
-}#if( $velocityCount < $size2 ),#end
-#end };
-
-indicatorFormulas = {
-#set( $size3 = $indicators.size() )
-#foreach( $indicator in $indicators )
-"${indicator.id}":"($!{indicator.explodedNumerator})/($!{indicator.explodedDenominator})*($!{indicator.indicatorType.factor})"
-#if( $velocityCount < $size3 ),#end
-#end };
-
-dataSets = {
-#set( $size4 = $dataSets.size() )
-#foreach( $dataSet in $dataSets )
-"${dataSet.id}":{"name":"$encoder.jsonEncode( ${dataSet.name} )","periodType":"$encoder.jsonEncode( ${dataSet.periodType.name} )","version":"${dataSet.version}"
-}#if( $velocityCount < $size4 ),#end
-#end };
-
-dataSetAssociationSets = {
-#set( $size5 = $dataSetAssociationSets.size() )
-#set( $index = 0 )
-#foreach( $associationSet in $dataSetAssociationSets )
-"${index}": [
-#set( $index = $index + 1 )
-#set( $size6 = $associationSet.size() )
-#foreach( $id in $associationSet )
-${id}#if( $velocityCount < $size6 ),#end
-#end ]#if( $velocityCount < $size5 ),#end
-#end };
-
-organisationUnitAssociationSetMap = {
-#set( $size7 = $organisationUnitAssociationSetMap.size() )
-#foreach( $orgUnit in $organisationUnitAssociationSetMap.keySet() )
-"${orgUnit}":"$organisationUnitAssociationSetMap.get( ${orgUnit} )"#if( $velocityCount < $size7 ),#end
-#end };
-
</script>
<h3>$i18n.getString( "data_entry" ) #openHelp( "dataEntry" )</h3>