dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13229
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4190: Moved data element names from forms to javascript
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4190 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-07-21 20:22:13 +0200
message:
Moved data element names from forms to javascript
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/resources/struts.xml
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
--
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-07-21 17:38:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-07-21 18:20:49 +0000
@@ -235,12 +235,10 @@
int i = 1;
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 )\" onkeyup=\"return keyPress(event, this)\" ";
+ final String jsCodeForSelectLists = " name=\"entryfield\" $DISABLED onchange=\"saveBoolean( $DATAELEMENTID, $OPTIONCOMBOID )\" onkeyup=\"keyPress(event, this)\" ";
final String historyCode = " ondblclick='javascript:viewHist( $DATAELEMENTID, $OPTIONCOMBOID )' ";
- final String metaDataCode = "<span id=\"$DATAELEMENTID-dataelement\" style=\"display:none\">$DATAELEMENTNAME</span>"; //TODO read from js
-
StringBuffer sb = new StringBuffer();
Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
@@ -324,7 +322,6 @@
inputHtml = inputHtml.replace( TAG_CLOSE, appendCode );
- inputHtml += metaDataCode;
inputHtml = inputHtml.replace( "$DATAELEMENTID", String.valueOf( dataElementId ) );
inputHtml = inputHtml.replace( "$DATAELEMENTNAME", dataElement.getName() );
inputHtml = inputHtml.replace( "$DATAELEMENTTYPE", dataElementValueType );
=== 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-07-21 14:01:52 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/struts.xml 2011-07-21 17:58:42 +0000
@@ -64,7 +64,7 @@
<action name="viewHistory" class="org.hisp.dhis.de.action.HistoryAction">
<result name="success" type="velocity">/popup.vm</result>
<param name="page">/dhis-web-dataentry/history.vm</param>
- <param name="javascripts">javascript/form.js,javascript/history.js</param>
+ <param name="javascripts">javascript/history.js</param>
</action>
<action name="registerCompleteDataSet" class="org.hisp.dhis.de.action.RegisterCompleteDataSetAction">
=== 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-21 17:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2011-07-21 18:20:49 +0000
@@ -14,7 +14,7 @@
#set( $cols = $colRepeat.get( $category.id ) )
#foreach( $col in $cols )
#foreach( $categoryOption in $categoryOptions )
- <th colspan="$colCount"><div align="center"> #if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.name )}#end </div></th>
+ <th colspan="$colCount"><div align="center">#if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.name )}#end</div></th>
#end
#end
</tr>
@@ -32,26 +32,23 @@
#else
#set( $mark = 1 )
#end
-
#set( $count = $count + 1 )
<tr>
- <td style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;">
- <span id="${dataElement.id}-dataelement">${encoder.htmlEncode( $dataElement.name )}</span>
- </td>
+ <td style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;"><span>${encoder.htmlEncode( $dataElement.name )}</span></td>
#foreach( $optionCombo in $optionCombos )
- #set( $dataEntryId = "${dataElement.id}-${optionCombo.id}-val" )
- <td>
- #if( $dataElement.type == "bool" )
- <select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) onchange="saveBoolean($dataElement.id,$optionCombo.id )" #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
- <option value="">[$i18n.getString( "no_value" )]</option>
- <option value="true">$i18n.getString( "yes" )</option>
- <option value="false">$i18n.getString( "no" )</option>
- </select>
- #else
- <input name="entryfield" id="$dataEntryId" type="text" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="return keyPress(event,this)" class="entryField" tabindex="$tabIndex" #if( $locked )disabled="disabled"#end>
- #end
- </td>
- #set( $tabIndex = $tabIndex + 1 )
+ #set( $dataEntryId = "${dataElement.id}-${optionCombo.id}-val" )
+ <td>
+ #if( $dataElement.type == "bool" )
+ <select name="entryselect" id="$dataEntryId" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) onchange="saveBoolean($dataElement.id,$optionCombo.id )" #else disabled="disabled" #end style="width:100%" tabindex="$tabIndex" #if( $locked ) disabled="disabled"#end>
+ <option value="">[$i18n.getString( "no_value" )]</option>
+ <option value="true">$i18n.getString( "yes" )</option>
+ <option value="false">$i18n.getString( "no" )</option>
+ </select>
+ #else
+ <input name="entryfield" id="$dataEntryId" type="text" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="keyPress(event,this)" class="entryField" tabindex="$tabIndex" #if( $locked )disabled="disabled"#end>
+ #end
+ </td>
+ #set( $tabIndex = $tabIndex + 1 )
#end
</tr>
#end
=== 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-07-21 17:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-07-21 18:20:49 +0000
@@ -90,8 +90,7 @@
*/
function saveVal( dataElementId, optionComboId )
{
- var dataElementName = $( '#' + dataElementId + '-dataelement' ).html();
-
+ var dataElementName = dataElements[dataElementId].name;
var fieldId = '#' + dataElementId + '-' + optionComboId + '-val';
var value =$( fieldId ).val();
var type = dataElements[dataElementId].type;
=== 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-21 17:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-07-21 18:20:49 +0000
@@ -314,7 +314,7 @@
var dataElementId = id.split( '-' )[0];
var optionComboId = id.split( '-' )[1];
- var dataElementName = $( '#' + dataElementId + '-dataelement' ).text();
+ var dataElementName = dataElements[dataElementId].name;
var optionComboName = $( '#' + optionComboId + '-optioncombo' ).text();
$( "#currentDataElement" ).html( dataElementName + ' ' + optionComboName );
@@ -331,8 +331,6 @@
{
focusField.focus();
}
-
- return true;
}
function getNextEntryField( 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-07-21 14:01:52 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/history.js 2011-07-21 17:58:42 +0000
@@ -114,8 +114,9 @@
$( '#maxSpan' ).html( '' );
}
- currentMinMaxValueMap[currentDataElementId + '-' + currentOptionComboId + '-min'] = minValue;
- currentMinMaxValueMap[currentDataElementId + '-' + currentOptionComboId + '-max'] = maxValue;
+ // TODO fix
+ //currentMinMaxValueMap[currentDataElementId + '-' + currentOptionComboId + '-min'] = minValue;
+ //currentMinMaxValueMap[currentDataElementId + '-' + currentOptionComboId + '-max'] = maxValue;
var url = 'saveMinMaxLimits.action?organisationUnitId=' + currentOrganisationUnitId + '&dataElementId=' + currentDataElementId +
'&optionComboId=' + currentOptionComboId + '&minLimit=' + minValue + '&maxLimit=' + maxValue;
=== 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-21 17:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2011-07-21 18:20:49 +0000
@@ -1,7 +1,7 @@
#set( $marker = 0 )
#set( $tabIndex = 1 )
-#foreach( $section in $sections)
+#foreach( $section in $sections )
#if( $marker == 1 )
#set( $marker = 0 )
@@ -29,12 +29,12 @@
#set( $categoryOptions = $optionsMap.get( $category.id ) )
#set( $colCount = $colCount / $categoryOptions.size() )
<tr colspan="$colCount">
- <td></td>
+ <td></td>
#set( $cols = $colRepeat.get( $category.id ) )
#foreach( $col in $cols )
- #foreach( $categoryOption in $categoryOptions )
- <th colspan="$colCount"><div align="center"> #if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.name )}#end </div></th>
- #end
+ #foreach( $categoryOption in $categoryOptions )
+ <th colspan="$colCount"><div align="center">#if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.name )}#end</div></th>
+ #end
#end
</tr>
#end
@@ -52,9 +52,7 @@
#end
#set( $count = $count + 1 )
<tr>
- <td style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;">
- <span id="${dataElement.id}-dataelement">${encoder.htmlEncode( $dataElement.name )}</span>
- </td>
+ <td style="#if( $mark == 1 )background-color:#e0e0e0;#end padding-right:50px;"><span>${encoder.htmlEncode( $dataElement.name )}</span></td>
#foreach( $optionCombo in $optionCombos )
#set( $dataEntryId = "${dataElement.id}-${optionCombo.id}-val" )
#set( $greyedField = false )
@@ -67,7 +65,7 @@
<option value="false">$i18n.getString( "no" )</option>
</select>
#else
- <input name="entryfield" id="$dataEntryId" type="text" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="return keyPress(event,this)" class="entryField #if( $locked || $greyedField ) grey#end" tabindex="$tabIndex" #if( $locked || $greyedField )disabled="disabled"#end>
+ <input name="entryfield" id="$dataEntryId" type="text" #if( $auth.hasAccess( "dhis-web-dataentry", "saveValue") ) onchange="saveVal(${dataElement.id},${optionCombo.id})" ondblclick="viewHist(${dataElement.id},${optionCombo.id})" #else disabled="disabled"#end onkeyup="keyPress(event,this)" class="entryField#if( $locked || $greyedField ) grey#end" tabindex="$tabIndex" #if( $locked || $greyedField )disabled="disabled"#end>
#end
</td>
#set( $tabIndex = $tabIndex + 1 )
=== 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-07-21 17:38:11 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2011-07-21 18:20:49 +0000
@@ -28,7 +28,8 @@
#set( $size2 = $dataElements.size() )
#foreach( $dataElement in $dataElements )
"${dataElement.id}": {
-"type":"${dataElement.getDetailedNumberType()}"
+"name":"${dataElement.name}",
+"type":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )"
}#if( $velocityCount < $size2 ),#end
#end };
@@ -40,8 +41,8 @@
#set( $size3 = $dataSets.size() )
#foreach( $dataSet in $dataSets )
"${dataSet.id}": {
-"name":"$!encoder.jsonEncode( ${dataSet.name} )",
-"periodType":"$!encoder.jsonEncode( ${dataSet.periodType.name} )"
+"name":"$encoder.jsonEncode( ${dataSet.name} )",
+"periodType":"$encoder.jsonEncode( ${dataSet.periodType.name} )"
}#if( $velocityCount < $size3 ),#end
#end };