=== 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-07-12 13:49:47 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-07-12 15:55:08 +0000 @@ -289,7 +289,7 @@ String dataElementValue = getValue( dataValues, dataElementId, optionComboId ); // ------------------------------------------------------------- - // Insert data value for data element in output code + // Insert data value for data element in output code for boolean // ------------------------------------------------------------- if ( dataElement.getType().equals( DataElement.VALUE_TYPE_BOOL ) ) @@ -297,17 +297,6 @@ inputHtml = inputHtml.replace( "input", "select" ); inputHtml = inputHtml.replaceAll( "value=\".*?\"", "" ); } - else - { - if ( inputHtml.contains( EMPTY_VALUE_TAG ) ) - { - inputHtml = inputHtml.replace( EMPTY_VALUE_TAG, "value=\"" + dataElementValue + "\"" ); - } - else - { - inputHtml += "value=\"" + dataElementValue + "\""; - } - } // ------------------------------------------------------------- // Insert title info === added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java 2011-07-12 14:44:28 +0000 @@ -0,0 +1,90 @@ +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 org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.datavalue.DataValue; +import org.hisp.dhis.datavalue.DataValueService; +import org.hisp.dhis.de.state.SelectedStateManager; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; + +import com.opensymphony.xwork2.Action; + +/** + * @author Lars Helge Overland + */ +public class GetDataValuesForDataSetAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataValueService dataValueService; + + public void setDataValueService( DataValueService dataValueService ) + { + this.dataValueService = dataValueService; + } + + private SelectedStateManager selectedStateManager; + + public void setSelectedStateManager( SelectedStateManager selectedStateManager ) + { + this.selectedStateManager = selectedStateManager; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Collection dataValues; + + public Collection getDataValues() + { + return dataValues; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + Period period = selectedStateManager.getSelectedPeriod(); + DataSet dataSet = selectedStateManager.getSelectedDataSet(); + OrganisationUnit unit = selectedStateManager.getSelectedOrganisationUnit(); + + dataValues = dataValueService.getDataValues( unit, period, dataSet.getDataElements() ); + + 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-06-27 10:39:01 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml 2011-07-12 14:44:28 +0000 @@ -19,7 +19,13 @@ - + + + + + + === 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-06-23 08:20:44 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2011-07-12 14:44:28 +0000 @@ -12,6 +12,10 @@ displayForm.action + + /dhis-web-dataentry/responseDataValues.vm + + /main.vm === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2011-07-12 13:49:47 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2011-07-12 15:55:08 +0000 @@ -66,7 +66,7 @@ #else - + #end #set( $tabIndex = $tabIndex + 1 ) === 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-07-11 10:41:54 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-07-12 15:55:08 +0000 @@ -53,7 +53,7 @@ if ( json.periodValid ) { showLoader(); - $( '#contentDiv' ).load( 'select.action', displayEntryFormCompleted ); + $( '#contentDiv' ).load( 'select.action', loadDataValues ); } } else { @@ -146,7 +146,7 @@ { showLoader(); $( '#selectedPeriodIndex' ).val( periodIndex ); - $( '#contentDiv' ).load( 'select.action', setDisplayModes ); + $( '#contentDiv' ).load( 'select.action', loadDataValuesAndDisplayModes ); } else { clearEntryForm(); @@ -165,7 +165,7 @@ var url = 'select.action?displayMode=' + $( "input[name='displayMode']:checked" ).val(); - $( '#contentDiv' ).load( url, displayEntryFormCompleted ); + $( '#contentDiv' ).load( url, loadDataValues ); } // ----------------------------------------------------------------------------- @@ -179,27 +179,50 @@ $( '#currentPeriod' ).html( periodName ); var periodIndex = $( '#selectedPeriodIndex' ).val(); - + if ( periodIndex && periodIndex != -1 ) { showLoader(); var url = 'select.action?selectedPeriodIndex=' + periodIndex; - $( '#contentDiv' ).load( url, setDisplayModes ); + $( '#contentDiv' ).load( url, loadDataValuesAndDisplayModes ); } } -function displayEntryFormCompleted() -{ - addEventListeners(); - hideLoader(); - enable( 'validationButton' ); - updateIndicators(); +// ----------------------------------------------------------------------------- +// Form +// ----------------------------------------------------------------------------- + +function loadDataValues() +{ + insertDataValues(); + displayEntryFormCompleted(); +} + +function loadDataValuesAndDisplayModes() +{ + insertDataValues(); + setDisplayModes(); + displayEntryFormCompleted(); +} + +function insertDataValues() +{ + $.getJSON( 'getDataValues.action', function( json ) + { + $.each( json.dataValues, function( i, value ) + { + var fieldId = '#' + value.id; + + if ( $( fieldId ) ) + { + $( fieldId ).val( value.val ); + } + } ); + } ); } function setDisplayModes() { - displayEntryFormCompleted(); - $.getJSON( 'loadDisplayModes.action', function( json ) { $( '#displayModeCustom' ).removeAttr( 'disabled' ); @@ -213,10 +236,12 @@ if ( json.displayMode == 'customform' ) { $( '#displayModeCustom' ).attr( 'checked', 'checked' ); - } else if ( json.displayMode == 'sectionform' ) + } + else if ( json.displayMode == 'sectionform' ) { $( '#displayModeSection' ).attr( 'checked', 'checked' ); - } else + } + else { $( '#displayModeDefault' ).attr( 'checked', 'checked' ); } @@ -232,6 +257,14 @@ } ); } +function displayEntryFormCompleted() +{ + addEventListeners(); + hideLoader(); + enable( 'validationButton' ); + updateIndicators(); +} + function valueFocus( e ) { var id = e.target.id; === added file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseDataValues.vm 2011-07-12 14:44:28 +0000 @@ -0,0 +1,8 @@ +#set( $size = $dataValues.size() ) +{ "dataValues": [ +#foreach( $value in $dataValues ) +{ + "id":"${value.dataElement.id}-${value.optionCombo.id}-val", + "val":"${value.value}" +}#if( $velocityCount < $size ),#end +#end ] } === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2011-07-12 13:49:47 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2011-07-12 15:55:08 +0000 @@ -80,7 +80,7 @@ #else - + #end #set( $tabIndex = $tabIndex + 1 )