dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13053
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4119: Simplified saving of boolean values
------------------------------------------------------------
revno: 4119
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-07-12 15:49:47 +0200
message:
Simplified saving of boolean values
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/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/sectionForm.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-11 10:22:45 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java 2011-07-12 13:49:47 +0000
@@ -240,7 +240,7 @@
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, this )\" onkeyup=\"return keyPress(event, this)\" ";
+ final String jsCodeForSelectLists = " name=\"entryfield\" $DISABLED onchange=\"saveBoolean( $DATAELEMENTID, $OPTIONCOMBOID )\" onkeyup=\"return keyPress(event, this)\" ";
final String historyCode = " ondblclick='javascript:viewHist( $DATAELEMENTID, $OPTIONCOMBOID )' ";
=== 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-11 10:22:45 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2011-07-12 13:49:47 +0000
@@ -60,7 +60,7 @@
<td>
#if( $dataElement.type == "bool" )
- <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>
+ <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" #if( $dataValue.value == "true" ) selected="selected" #end>$i18n.getString( "yes" )</option>
<option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</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-07-12 13:41:21 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js 2011-07-12 13:49:47 +0000
@@ -167,32 +167,21 @@
}
}
- var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, value, COLOR_GREEN, '' );
+ var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, value, COLOR_GREEN );
valueSaver.save();
updateIndicators(); // Update indicators in case of custom form
}
-function saveBoolean( dataElementId, optionComboId, selectedOption )
-{
- var select = selectedOption.options[selectedOption.selectedIndex].value
- var organisationUnitId = getFieldValue( 'organisationUnitId' );
-
- selectedOption.style.backgroundColor = COLOR_YELLOW;
-
- var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, select, COLOR_GREEN, selectedOption );
- valueSaver.save();
-}
-
-function saveDate( dataElementId, dataElementName )
-{
- var field = document.getElementById( dataElementId + '-date' );
- var type = document.getElementById( dataElementId + '-valuetype' ).innerHTML;
- var organisationUnitId = getFieldValue( 'organisationUnitId' );
-
- field.style.backgroundColor = COLOR_YELLOW;
-
- var valueSaver = new ValueSaver( dataElementId, '', organisationUnitId, field.value, COLOR_GREEN, '' );
+function saveBoolean( dataElementId, optionComboId )
+{
+ var fieldId = '#' + dataElementId + '-' + optionComboId + '-val';
+ var value = $( fieldId + ' option:selected' ).val();
+ var organisationUnitId = $( '#organisationUnitId' ).val();
+
+ $( fieldId ).css( 'background-color', COLOR_YELLOW );
+
+ var valueSaver = new ValueSaver( dataElementId, optionComboId, organisationUnitId, value, COLOR_GREEN );
valueSaver.save();
}
@@ -213,13 +202,12 @@
// Saver objects
// -----------------------------------------------------------------------------
-function ValueSaver( dataElementId_, optionComboId_, organisationUnitId_, value_, resultColor_, selectedOption_ )
+function ValueSaver( dataElementId_, optionComboId_, organisationUnitId_, value_, resultColor_ )
{
var dataElementId = dataElementId_;
var optionComboId = optionComboId_;
var value = value_;
var resultColor = resultColor_;
- var selectedOption = selectedOption_;
var organisationUnitId = organisationUnitId_;
this.save = function()
=== 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-11 10:22:45 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2011-07-12 13:49:47 +0000
@@ -74,7 +74,7 @@
<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" )
- <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>
+ <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 #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>
<option value="false" #if( $dataValue.value == "false" ) selected="selected" #end>$i18n.getString( "no" )</option>