dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13045
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4112: Upgraded the format used for identifiers of input fields in data entry module. The old format was...
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4112 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-07-11 12:49:37 +0200
message:
Upgraded the format used for identifiers of input fields in data entry module. The old format was verbose and contained brackets which are not allowed in HTML 4 and not jquery-friendly. Added a startup routine which updates existing custom data entry forms. This implies that forms used with 2.4 will not work with 2.3.
added:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormUpgrader.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormPopulator.java
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/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataentryform/DataEntryFormServiceTest.java
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/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/javascript/history.js
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/select.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.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-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2011-05-11 11:18:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormService.java 2011-07-11 10:22:45 +0000
@@ -45,7 +45,7 @@
String ID = DataEntryFormService.class.getName();
final Pattern INPUT_PATTERN = Pattern.compile( "(<input.*?/>)", Pattern.DOTALL );
- final Pattern IDENTIFIER_PATTERN = Pattern.compile( "value\\[(.*)\\].value:value\\[(.*)\\].value" );
+ final Pattern IDENTIFIER_PATTERN = Pattern.compile( "(\\d+)-(\\d+)-val" );
final Pattern INDICATOR_PATTERN = Pattern.compile( "indicatorid=\"(.*?)\"" );
final Pattern VALUE_TAG_PATTERN = Pattern.compile( "value=\"(.*?)\"", Pattern.DOTALL );
final Pattern TITLE_TAG_PATTERN = Pattern.compile( "title=\"(.*?)\"", Pattern.DOTALL );
@@ -109,7 +109,8 @@
Collection<DataEntryForm> getDataEntryForms( final Collection<Integer> identifiers );
/**
- * Prepare DataEntryForm code for persisting.
+ * Prepare DataEntryForm code for save by reversing the effects of
+ * prepareDataEntryFormForEdit().
*
* @return htmlCode the HTML code of the data entry form.
*/
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormPopulator.java 2010-08-31 14:34:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormPopulator.java 2011-07-11 10:22:45 +0000
@@ -72,7 +72,6 @@
try
{
-// jdbcTemplate.execute( "INSERT INTO dataentryformassociation SELECT 'dataset', datasetid, dataentryformid FROM dataentryform;" );
jdbcTemplate.execute( statementBuilder.getDropDatasetForeignKeyForDataEntryFormTable() );
jdbcTemplate.execute( "ALTER TABLE dataentryform DROP COLUMN datasetid;" );
}
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormUpgrader.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormUpgrader.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DataEntryFormUpgrader.java 2011-07-11 10:22:45 +0000
@@ -0,0 +1,61 @@
+package org.hisp.dhis.dataentryform;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.system.startup.AbstractStartupRoutine;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Upgrades the format of the input field identifiers from the legacy "value[12].value:value[34].value"
+ * to the new "12-34-val"
+ */
+public class DataEntryFormUpgrader
+ extends AbstractStartupRoutine
+{
+ private static final Log log = LogFactory.getLog( DataEntryFormUpgrader.class );
+
+ private final static String ID_EXPRESSION = "id=\"value\\[(\\d+)\\]\\.value:value\\[(\\d+)\\]\\.value\"";
+ private final static Pattern ID_PATTERN = Pattern.compile( ID_EXPRESSION );
+
+ private DataEntryFormService dataEntryFormService;
+
+ public void setDataEntryFormService( DataEntryFormService dataEntryFormService )
+ {
+ this.dataEntryFormService = dataEntryFormService;
+ }
+
+ @Transactional
+ @Override
+ public void execute()
+ {
+ int i = 0;
+
+ for ( DataEntryForm form : dataEntryFormService.getAllDataEntryForms() )
+ {
+ Matcher matcher = ID_PATTERN.matcher( form.getHtmlCode() );
+
+ StringBuffer out = new StringBuffer();
+
+ while ( matcher.find() )
+ {
+ String upgradedId = "id=\"" + matcher.group(1) + "-" + matcher.group(2) + "-val\"";
+
+ matcher.appendReplacement( out, upgradedId );
+
+ i++;
+ }
+
+ matcher.appendTail( out );
+
+ form.setHtmlCode( out.toString() );
+ form.setHtmlCode( form.getHtmlCode().replaceAll( "view=\"@@deshortname@@\"", "" ) );
+
+ dataEntryFormService.updateDataEntryForm( form );
+ }
+
+ log.info( "Upgraded custom data entry form identifiers: " + i );
+ }
+}
=== 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-04 08:15:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-07-11 10:22:45 +0000
@@ -234,22 +234,20 @@
Collection<DataValue> dataValues, Map<String, MinMaxDataElement> minMaxMap, String disabled, I18n i18n, DataSet dataSet )
{
// ---------------------------------------------------------------------
- // Inline javascript to add to HTML before output
+ // Inline javascript/html to add to HTML before output
// ---------------------------------------------------------------------
int i = 1;
- final String jsCodeForInputFields = " name=\"entryfield\" $DISABLED onchange=\"saveValue( $DATAELEMENTID, $OPTIONCOMBOID, '$DATAELEMENTNAME' )\" style=\"text-align:center\" onkeyup=\"return keyPress(event, this)\" ";
+
+ final String jsCodeForInputFields = " name=\"entryfield\" $DISABLED onchange=\"saveVal( $DATAELEMENTID, $OPTIONCOMBOID )\" style=\"text-align:center\" onkeyup=\"return keyPress(event, this)\" ";
final String jsCodeForSelectLists = " name=\"entryfield\" $DISABLED onchange=\"saveBoolean( $DATAELEMENTID, $OPTIONCOMBOID, this )\" onkeyup=\"return keyPress(event, this)\" ";
- final String historyCode = " ondblclick='javascript:viewHistory( $DATAELEMENTID, $OPTIONCOMBOID, true )' ";
-
- // ---------------------------------------------------------------------
- // Metadata code to add to HTML before output
- // ---------------------------------------------------------------------
-
- final String metaDataCode = "<span id=\"value[$DATAELEMENTID].name\" style=\"display:none\">$DATAELEMENTNAME</span>"
- + "<span id=\"value[$DATAELEMENTID].type\" style=\"display:none\">$DATAELEMENTTYPE</span>"
- + "<div id=\"value[$DATAELEMENTID:$OPTIONCOMBOID].min\" style=\"display:none\">$MIN</div>"
- + "<div id=\"value[$DATAELEMENTID:$OPTIONCOMBOID].max\" style=\"display:none\">$MAX</div>";
+
+ final String historyCode = " ondblclick='javascript:viewHist( $DATAELEMENTID, $OPTIONCOMBOID )' ";
+
+ final String metaDataCode = "<span id=\"$DATAELEMENTID-dataelement\" style=\"display:none\">$DATAELEMENTNAME</span>"
+ + "<span id=\"$DATAELEMENTID-type\" style=\"display:none\">$DATAELEMENTTYPE</span>"
+ + "<div id=\"$DATAELEMENTID-$OPTIONCOMBOID-min\" style=\"display:none\">$MIN</div>"
+ + "<div id=\"$DATAELEMENTID-$OPTIONCOMBOID-max\" style=\"display:none\">$MAX</div>";
StringBuffer sb = new StringBuffer();
@@ -319,8 +317,6 @@
String minValue = minMaxDataElement != null ? String.valueOf( minMaxDataElement.getMin() ) : "-";
String maxValue = minMaxDataElement != null ? String.valueOf( minMaxDataElement.getMax() ) : "-";
- inputHtml = inputHtml.replaceAll( "view=\".*?\"", "" ); // For backwards compatibility
-
StringBuilder title = new StringBuilder( "title=\"Name: " ).append( dataElement.getName() ).append( " " ).
append( categoryOptionCombo.getName() ).append( " Type: " ).append( dataElement.getType() ).
append( " Min: " ).append( minValue ).append( " Max: " ).append( maxValue ).append( "\"" );
@@ -370,9 +366,11 @@
if ( dataElement.getType().equals( VALUE_TYPE_INT ) )
{
appendCode += historyCode;
+
if ( minMaxDataElement != null && !dataElementValue.equals( EMPTY ) )
{
double value = Double.parseDouble( dataElementValue );
+
if ( value < minMaxDataElement.getMin() || value > minMaxDataElement.getMax() )
{
backgroundColor = "style=\"background-color:#ff6600;";
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-06-30 08:31:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2011-07-11 10:22:45 +0000
@@ -994,6 +994,12 @@
<property name="runlevel" value="5" />
<property name="skipInTests" value="true" />
</bean>
+
+ <bean id="org.hisp.dhis.dataentryform.DataEntryFormUpgrader" class="org.hisp.dhis.dataentryform.DataEntryFormUpgrader">
+ <property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService"/>
+ <property name="runlevel" value="5" />
+ <property name="skipInTests" value="true" />
+ </bean>
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="org.hisp.dhis.system.startup.StartupRoutineExecutor" />
@@ -1008,6 +1014,7 @@
<ref local="org.hisp.dhis.dataset.DataSetShortNamePopulator" />
<ref local="org.hisp.dhis.organisationunit.OrganisationUnitGroupSetPopulator" />
<ref local="org.hisp.dhis.dataentryform.DataEntryFormPopulator" />
+ <ref local="org.hisp.dhis.dataentryform.DataEntryFormUpgrader" />
</list>
</list>
</property>
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataentryform/DataEntryFormServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataentryform/DataEntryFormServiceTest.java 2011-05-12 12:43:04 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataentryform/DataEntryFormServiceTest.java 2011-07-11 10:22:45 +0000
@@ -251,13 +251,12 @@
@Test
public void testPrepareForEdit()
{
- String html = "<table><tr><td><input id=\"value[" + dataElementId + "].value:value[" + categoryOptionComboId + "].value\" style=\"width:4em;text-align:center\" title=\"\" value=\"\" /></td></tr></table>";
+ String html = "<table><tr><td><input id=\"" + dataElementId + "-" + categoryOptionComboId + "-val\" style=\"width:4em;text-align:center\" title=\"\" value=\"\" /></td></tr></table>";
String title = "" + dataElementId + " - " + dataElement.getName() + " - " + categoryOptionComboId + " - " + categoryOptionCombo.getName() + " - " + dataElement.getType();
String value = "[ " + dataElement.getName() + " " + categoryOptionCombo.getName() + "Â ]";
- String expected = "<table><tr><td><input id=\"value[" + dataElementId + "].value:value[" + categoryOptionComboId + "].value\" style=\"width:4em;text-align:center\" title=\"" + title + "\" value=\"" + value + "\" /></td></tr></table>";
+ String expected = "<table><tr><td><input id=\"" + dataElementId + "-" + categoryOptionComboId + "-val\" style=\"width:4em;text-align:center\" title=\"" + title + "\" value=\"" + value + "\" /></td></tr></table>";
String actual = dataEntryFormService.prepareDataEntryFormForEdit( html );
assertEquals( expected.length(), actual.length() );
- // assertEquals( expected, actual ); TODO
}
}
=== 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-05-02 12:54:28 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2011-07-11 10:22:45 +0000
@@ -26,7 +26,7 @@
#set( $dataElements = $orderedDataElements.get( $categoryCombo ) )
#set( $optionCombos = $orderdCategoryOptionCombos.get( $categoryCombo.id ) )
#set( $mark = 0 )
- #foreach( $optionCombo in $optionCombos )<span id="value[option${optionCombo.id}].name" class="hidden">${optionCombo.name}</span>
+ #foreach( $optionCombo in $optionCombos )<span id="${optionCombo.id}-optioncombo" class="hidden">${encoder.htmlEncode( $optionCombo.name )}</span>
#end
#foreach( $dataElement in $dataElements )
#if( $mark == 1 )
@@ -38,8 +38,8 @@
#set( $count = $count + 1 )
<tr>
<td style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;">
- <span id="value[$dataElement.id].name" title="$!encoder.htmlEncode( $dataElement.description )">$encoder.htmlEncode( $dataElement.name )</span>
- <span id="value[$dataElement.id].type" class="hidden">$dataElement.getDetailedNumberType()</span>
+ <span id="${dataElement.id}-dataelement" title="$!encoder.htmlEncode( $dataElement.description )">${encoder.htmlEncode( $dataElement.name )}</span>
+ <span id="${dataElement.id}-type" class="hidden">$dataElement.getDetailedNumberType()</span>
</td>
#foreach( $optionCombo in $optionCombos )
@@ -47,7 +47,7 @@
#set( $minMax = $minMaxMap.get( "$dataElement.id:$optionCombo.id" ) )
#set( $dataValue = false )
#set( $dataValue = $dataValueMap.get( "$dataElement.id:$optionCombo.id" ) )
- #set( $dataEntryId = "value[$dataElement.id].value:value[$optionCombo.id].value" )
+ #set( $dataEntryId = "${dataElement.id}-${optionCombo.id}-val" )
#set( $minMaxError = false )
#if( $dataElement.type == "int" && $dataValue && $minMax )
#if( $integer.parseInt( $dataValue.value ) < $minMax.min || $integer.parseInt( $dataValue.value ) > $minMax.max )
@@ -55,12 +55,11 @@
#end
#end
- <span id="value[${dataElement.id}:${optionCombo.id}].min" class="hidden">$!minMax.min</span>
- <span id="value[${dataElement.id}:${optionCombo.id}].max" class="hidden">$!minMax.max</span>
+ <span id="${dataElement.id}-${optionCombo.id}-min" class="hidden">$!minMax.min</span>
+ <span id="${dataElement.id}-${optionCombo.id}-max" class="hidden">$!minMax.max</span>
<td>
#if( $dataElement.type == "bool" )
- <span id="value[option$optionCombo.id].name" style="display:none">$optionCombo.name</span>
<select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) onchange="saveBoolean($dataElement.id,$optionCombo.id, this )" #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
<option value="">[$i18n.getString( "no_value" )]</option>
<option value="true" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
=== 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-06-24 22:42:47 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-07-11 10:22:45 +0000
@@ -1,3 +1,15 @@
+
+/**
+ * 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}-{optioncomboid}-min // min value for data value
+ * {dataelementid}-{optioncomboid}-max // max value for data value
+ * {dataelementid}-type // data element type
+ */
+
// -----------------------------------------------------------------------------
// Save
// -----------------------------------------------------------------------------
@@ -67,13 +79,12 @@
var dataElementId = operand.substring( 0, operand.indexOf( SEPARATOR ) );
var categoryOptionComboId = operand.substring( operand.indexOf( SEPARATOR ) + 1, operand.length );
- var entryFieldId = 'value[' + dataElementId + '].value:value[' + categoryOptionComboId + '].value';
+ var entryFieldId = dataElementId + '-' + categoryOptionComboId + '-val';
var entryField = document.getElementById( entryFieldId );
var value = entryField && entryField.value ? entryField.value : '0';
- expression = expression.replace( match, value ); // TODO signed
- // numbers
+ expression = expression.replace( match, value ); // TODO signed numbers
}
return expression;
@@ -84,25 +95,10 @@
*/
function saveVal( dataElementId, optionComboId )
{
- var dataElementName = document.getElementById( 'value[' + dataElementId + '].name' ).innerHTML;
-
- saveValueInternal( dataElementId, optionComboId, dataElementName, null );
-}
-
-/**
- * /* Used by custom forms.
- */
-function saveValue( dataElementId, optionComboId, dataElementName )
-{
- saveValueInternal( dataElementId, optionComboId, dataElementName );
- updateIndicators();
-}
-
-function saveValueInternal( dataElementId, optionComboId, dataElementName )
-{
- var field = document.getElementById( 'value[' + dataElementId + '].value' + ':' + 'value[' + optionComboId
- + '].value' );
- var type = document.getElementById( 'value[' + dataElementId + '].type' ).innerHTML;
+ var dataElementName = document.getElementById( dataElementId + '-dataelement' ).innerHTML;
+
+ var field = document.getElementById( dataElementId + '-' + optionComboId + '-val' );
+ var type = document.getElementById( dataElementId + '-type' ).innerHTML;
var organisationUnitId = getFieldValue( 'organisationUnitId' );
field.style.backgroundColor = COLOR_YELLOW;
@@ -147,8 +143,8 @@
}
}
- var minString = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].min' ).innerHTML;
- var maxString = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].max' ).innerHTML;
+ var minString = document.getElementById( dataElementId + '-' + optionComboId + '-min' ).innerHTML;
+ var maxString = document.getElementById( dataElementId + '-' + optionComboId + '-max' ).innerHTML;
if ( minString.length != 0 && maxString.length != 0 )
{
@@ -158,22 +154,20 @@
if ( value < min )
{
- var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, field.value,
- COLOR_ORANGE );
+ var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, field.value, COLOR_ORANGE );
valueSaver.save();
- window.alert( i18n_value_of_data_element_less + '\n\n' + dataElementName );
+ window.alert( i18n_value_of_data_element_less + ': ' + min + '\n\n' + dataElementName );
return;
}
if ( value > max )
{
- var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, field.value,
- COLOR_ORANGE );
+ var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, field.value, COLOR_ORANGE );
valueSaver.save();
- window.alert( i18n_value_of_data_element_greater + '\n\n' + dataElementName );
+ window.alert( i18n_value_of_data_element_greater + ': ' + max + '\n\n' + dataElementName );
return;
}
@@ -183,6 +177,8 @@
var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, field.value, COLOR_GREEN, '' );
valueSaver.save();
+
+ updateIndicators(); // Update indicators in case of custom form
}
function saveBoolean( dataElementId, optionComboId, selectedOption )
@@ -199,8 +195,8 @@
function saveDate( dataElementId, dataElementName )
{
- var field = document.getElementById( 'value[' + dataElementId + '].date' );
- var type = document.getElementById( 'value[' + dataElementId + '].valueType' ).innerHTML;
+ var field = document.getElementById( dataElementId + '-date' );
+ var type = document.getElementById( dataElementId + '-valuetype' ).innerHTML;
var organisationUnitId = getFieldValue( 'organisationUnitId' );
field.style.backgroundColor = COLOR_YELLOW;
@@ -209,19 +205,6 @@
valueSaver.save();
}
-function saveComment( dataElementId, optionComboId, commentValue )
-{
- var field = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comment' );
- var select = document.getElementById( 'value[' + dataElementId + ':' + optionComboId + '].comments' );
- var organisationUnitId = getFieldValue( 'organisationUnitId' );
-
- field.style.backgroundColor = COLOR_YELLOW;
- select.style.backgroundColor = COLOR_YELLOW;
-
- var commentSaver = new CommentSaver( dataElementId, optionComboId, organisationUnitId, commentValue );
- commentSaver.save();
-}
-
/**
* Supportive method.
*/
@@ -266,7 +249,8 @@
if ( code == 0 )
{
markValue( resultColor );
- } else
+ }
+ else
{
markValue( COLOR_RED );
window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
@@ -281,24 +265,7 @@
function markValue( color )
{
- var type = document.getElementById( 'value[' + dataElementId + '].type' ).innerText;
- var element;
-
- if ( type == 'bool' )
- {
- element = document.getElementById( 'value[' + dataElementId + '].boolean' );
- } else if ( type == 'date' )
- {
- element = document.getElementById( 'value[' + dataElementId + '].date' );
- } else if ( selectedOption )
- {
- element = selectedOption;
- } else
- {
- element = document.getElementById( 'value[' + dataElementId + '].value' + ':' + 'value[' + optionComboId
- + '].value' );
- }
-
+ var element = document.getElementById( dataElementId + '-' + optionComboId + '-val' );
element.style.backgroundColor = color;
}
}
=== 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-06-23 06:46:26 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-07-11 10:41:54 +0000
@@ -234,82 +234,15 @@
function valueFocus( e )
{
- // Retrieve the data element id from the id of the field
- var baseId = e.target.id;
-
- var opId = baseId;
- var str = baseId;
-
- if ( baseId.indexOf( ':' ) != -1 )
- {
- opId = baseId.substr( baseId.indexOf( ':' ) + 1, baseId.length );
- str = baseId.substr( 0, baseId.indexOf( ':' ) );
- }
-
- var match1 = /.*\[(.*)\]/.exec( str ); // value[-dataElementId-]
- var match2 = /.*\[(.*)\]/.exec( opId ); // value[-optionComboId-]
-
- if ( !match1 )
- {
- return;
- }
-
- deId = match1[1];
- ocId = match2[1];
-
- var nameContainer = document.getElementById( 'value[' + deId + '].name' );
- var opCbContainer = document.getElementById( 'value[option' + ocId + '].name' );
- var minContainer = document.getElementById( 'value[' + deId + ':' + ocId + '].min' );
- var maxContainer = document.getElementById( 'value[' + deId + ':' + ocId + '].max' );
-
- if ( !nameContainer )
- {
- return;
- }
-
- var name = '';
- var optionName = '';
-
- var as = nameContainer.getElementsByTagName( 'a' );
-
- if ( as.length > 0 ) // Admin rights: Name is in a link
- {
- name = as[0].firstChild.nodeValue;
- } else
- {
- name = nameContainer.firstChild.nodeValue;
- }
-
- if ( opCbContainer )
- {
- if ( opCbContainer.firstChild )
- {
- optionName = opCbContainer.firstChild.nodeValue;
- }
- }
-
- if ( minContainer )
- {
- if ( minContainer.firstChild )
- {
- optionName += " - " + minContainer.firstChild.nodeValue;
- }
- }
-
- if ( maxContainer )
- {
- if ( maxContainer.firstChild )
- {
- optionName += " - " + maxContainer.firstChild.nodeValue;
- }
- }
-
- var curDeSpan = document.getElementById( 'currentDataElement' );
-
- curDeSpan.firstChild.nodeValue = name;
-
- document.getElementById( "currentOptionCombo" ).innerHTML = optionName;
-
+ var id = e.target.id;
+
+ var dataElementId = id.split( '-' )[0];
+ var optionComboId = id.split( '-' )[1];
+
+ var dataElementName = $( '#' + dataElementId + '-dataelement' ).text();
+ var optionComboName = $( '#' + optionComboId + '-optioncombo' ).text();
+
+ $( "#currentDataElement" ).html( dataElementName + ' ' + optionComboName );
}
function keyPress( event, field )
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2011-06-27 10:39:01 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2011-07-11 10:22:45 +0000
@@ -106,8 +106,8 @@
}
if ( window.opener && window.opener.document ) {
- window.opener.document.getElementById( 'value[' + currentDataElementId + ':' + currentOptionComboId + '].min' ).innerHTML = minValue;
- window.opener.document.getElementById( 'value[' + currentDataElementId + ':' + currentOptionComboId + '].max' ).innerHTML = maxValue;
+ window.opener.document.getElementById( currentDataElementId + '-' + currentOptionComboId + '-min' ).innerHTML = minValue;
+ window.opener.document.getElementById( currentDataElementId + '-' + currentOptionComboId + '-max' ).innerHTML = maxValue;
}
var url = 'saveMinMaxLimits.action?organisationUnitId=' + currentOrganisationUnitId + '&dataElementId=' + currentDataElementId +
=== 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-03-20 21:45:37 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2011-07-11 10:22:45 +0000
@@ -44,7 +44,7 @@
#set( $count = 0 )
#set( $mark = 0 )
#set( $optionCombos = $orderdCategoryOptionCombos.get( $categoryComboId ) )
- #foreach( $optionCombo in $optionCombos )<span id="value[option${optionCombo.id}].name" class="hidden">${optionCombo.name}</span>
+ #foreach( $optionCombo in $optionCombos )<span id="${optionCombo.id}-optioncombo" class="hidden">${encoder.htmlEncode( $optionCombo.name )}</span>
#end
#foreach( $dataElement in $section.dataElements )
#if( $mark == 1 )
@@ -55,14 +55,14 @@
#set( $count = $count + 1 )
<tr>
<td style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;">
- <span id="value[$dataElement.id].name" title="$!encoder.htmlEncode( $dataElement.description )">$encoder.htmlEncode( $dataElement.name )</span><span id="value[$dataElement.id].type" class="hidden">$dataElement.getDetailedNumberType()</span>
+ <span id="${dataElement.id}-dataelement" title="$!{encoder.htmlEncode( $dataElement.description )}">${encoder.htmlEncode( $dataElement.name )}</span><span id="${dataElement.id}-type" class="hidden">$dataElement.getDetailedNumberType()</span>
</td>
#foreach( $optionCombo in $optionCombos )
#set( $minMax = false )
#set( $minMax = $minMaxMap.get( "$dataElement.id:$optionCombo.id" ) )
#set( $dataValue = false )
#set( $dataValue = $dataValueMap.get( "$dataElement.id:$optionCombo.id" ) )
- #set( $dataEntryId = "value[$dataElement.id].value:value[$optionCombo.id].value" )
+ #set( $dataEntryId = "${dataElement.id}-${optionCombo.id}-val" )
#set( $greyedField = false )
#set( $greyedField = $greyedFields.get( "$dataElement.id:$optionCombo.id" ) )
#set( $minMaxError = false )
@@ -71,10 +71,9 @@
#set( $minMaxError = true )
#end
#end
- <span id="value[${dataElement.id}:${optionCombo.id}].min" class="hidden">$!minMax.min</span><span id="value[${dataElement.id}:${optionCombo.id}].max" class="hidden">$!minMax.max</span>
+ <span id="${dataElement.id}-${optionCombo.id}-min" class="hidden">$!minMax.min</span><span id="${dataElement.id}-${optionCombo.id}-max" class="hidden">$!minMax.max</span>
<td>
#if( $dataElement.type == "bool" )
- <span id="value[option$optionCombo.id].name" style="display:none">$optionCombo.name</span>
<select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) onchange="saveBoolean($dataElement.id,$optionCombo.id, this )" #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end #if( $greyedField ) disabled="disabled"#end>
<option value="">[$i18n.getString( "no_value" )]</option>
<option value="true" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
=== 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-06-19 21:36:17 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2011-07-11 10:41:54 +0000
@@ -25,8 +25,7 @@
<span style="float:left;cursor:pointer;margin-right:5px;"><img src="../images/hide.png" title="$i18n.getString( 'close' )" onclick="closeCurrentSelection()"></span>
<span id="currentOrganisationUnit">$i18n.getString( "no_organisationunit_selected" )</span> -
<span id="currentPeriod">$i18n.getString( "no_period_selected" )</span/><br>
- <span id="currentDataElement">$i18n.getString( "no_dataelement_selected" )</span> -
- <span id="currentOptionCombo">$i18n.getString( "no_option_selected" )</span>
+ <span id="currentDataElement">$i18n.getString( "no_dataelement_selected" )</span>
</div>
<div id="actions" style="">
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js 2011-06-10 11:09:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js 2011-07-11 10:22:45 +0000
@@ -198,28 +198,22 @@
+ optionComboId + " - " + optionComboName + " - " + dataElementType;
var displayName = "[ " + dataElementName + " " + optionComboName + " ]";
- var dataEntryId = "value[" + dataElementId + "].value:value["
- + optionComboId + "].value";
- var boolDataEntryId = "value[" + dataElementId + "].value:value["
- + optionComboId + "].value";
+ var dataEntryId = dataElementId + "-" + optionComboId + "-val";
- var id = "";
var html = "";
if (dataElementType == "bool") {
- id = boolDataEntryId;
html = "<input title=\"" + titleValue
- + "\" value=\"" + displayName + "\" id=\"" + boolDataEntryId
+ + "\" value=\"" + displayName + "\" id=\"" + dataEntryId
+ "\" style=\"width:7em;text-align:center\"/>";
}
else {
- id = dataEntryId;
html = "<input title=\"" + titleValue
+ "\" value=\"" + displayName + "\" id=\"" + dataEntryId
+ "\" style=\"width:7em;text-align:center\"/>";
}
- if (!checkExisted(id)) {
+ if (!checkExisted(dataEntryId)) {
oEditor.insertHtml(html);
} else {
showThenFadeOutMessage( "<b>" + i18n_dataelement_already_inserted + "</b>" );