dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18985
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8106: WIP dynamic fields
------------------------------------------------------------
revno: 8106
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-09-16 17:38:31 +0200
message:
WIP dynamic fields
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-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 2012-09-16 15:21:25 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2012-09-16 15:38:31 +0000
@@ -249,7 +249,7 @@
var key = array[0];
var value = dataValues[key];
- if( value.value.length > 254 )
+ if ( value.value.length > 254 )
{
value.value = value.value.slice(0, 254);
}
@@ -300,7 +300,6 @@
{
var dataSetId = $( '#selectedDataSetId' ).val();
var formType = dataSets[dataSetId].type;
- var optionMarkup = $( '#dynselect' ).html();
$( '[name="entryfield"]' ).each( function( i )
{
@@ -387,11 +386,6 @@
keyPress( event, this );
} );
} );
-
- $( '[name="dynselect"]' ).each( function( i ) // Custom only
- {
- $( this ).append( optionMarkup );
- } );
}
function clearPeriod()
@@ -400,6 +394,21 @@
clearEntryForm();
}
+function insertDynamicOptions()
+{
+ var optionMarkup = $( '#dynselect' ).html();
+
+ if ( !isDefined( optionMarkup ) )
+ {
+ return;
+ }
+
+ $( '[name="dynselect"]' ).each( function( i )
+ {
+ $( this ).append( optionMarkup );
+ } );
+}
+
function clearEntryForm()
{
$( '#contentDiv' ).html( '' );
@@ -423,16 +432,21 @@
$( '#contentDiv' ).html( html );
enableSectionFilter();
+ insertDynamicOptions();
loadDataValues();
}
else
{
log( 'Loading form remotely: ' + dataSetId );
- $( '#contentDiv' ).load( 'loadForm.action', {
+ $( '#contentDiv' ).load( 'loadForm.action',
+ {
dataSetId : dataSetId
- }, function() {
+ },
+ function()
+ {
enableSectionFilter();
+ insertDynamicOptions();
loadDataValues()
} );
}
@@ -450,7 +464,7 @@
$sectionsHeaders.each(function(idx, value) {
$( '#filterDataSetSection' ).append( "<option value='" + idx + "'>" + value.innerHTML + "</option>" );
- });
+ } );
$( '#filterDataSetSectionTr' ).show();
}