=== 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 2013-12-23 15:39:16 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2013-12-23 16:16:42 +0000 @@ -848,6 +848,7 @@ clearSectionFilters(); clearPeriod(); + dhis2.de.clearAttributes(); } } @@ -984,6 +985,7 @@ else { clearEntryForm(); + dhis2.de.clearAttributes(); } } @@ -1071,6 +1073,35 @@ */ dhis2.de.getCategories = function( dataSetId ) { + /** + * Returns markup for drop down boxes to be put in the selection box for the + * given categories. The empty string is returned if no categories are given. + */ + dhis2.de.getAttributesMarkup = function() + { + var html = ''; + + if ( !dhis2.de.currentCategories || dhis2.de.currentCategories.length == 0 ) { + return html; + } + + $.safeEach( dhis2.de.currentCategories, function( idx, category ) { + html += '
'; + html += '
' + category.name + '
 '; + html += ''; + html += '
'; + } ); + + return html; + }; + var dataSet = dhis2.de.dataSets[dataSetId]; if ( !dataSet || !dataSet.categoryCombo || dhis2.de.defaultCategoryCombo === dataSet.categoryCombo ) { @@ -1187,7 +1218,7 @@ $.safeEach( dhis2.de.currentCategories, function( idx, category ) { html += '
'; html += '
' + category.name + '
 '; - html += ''; html += ''; $.safeEach( category.options, function( idx, option ) { @@ -1201,6 +1232,31 @@ return html; }; +/** + * Clears the markup for attribute select lists. + */ +dhis2.de.clearAttributes = function() +{ + $( '#attributeComboDiv' ).html( '' ); +}; + +/** + * Callback for changes in attribute select lists. + */ +dhis2.de.attributeSelected = function( categoryId ) +{ + if ( dhis2.de.inputSelected() ) { + showLoader(); + + if ( dhis2.de.dataEntryFormIsLoaded ) { + loadDataValues(); + } + else { + loadForm(); + } + } +}; + // ----------------------------------------------------------------------------- // Form // -----------------------------------------------------------------------------