------------------------------------------------------------ revno: 13407 committer: Lars Helge Ă˜verland <larshe...@gmail.com> branch nick: dhis2 timestamp: Mon 2013-12-23 17:16:42 +0100 message: Data entry, impl selection of attributes 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 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 += '<div class="selectionBoxRow">'; + html += '<div class="selectionLabel">' + category.name + '</div> '; + html += '<select id="category-' + category.id + '" class="selectionBoxSelect" onchange="dhis2.de.attributeSelected(\'' + category.id + '\')">'; + html += '<option value="-1">[ ' + i18n_select_option + ' ]</option>'; + + $.safeEach( category.options, function( idx, option ) { + html += '<option value="' + option.id + '">' + option.name + '</option>'; + } ); + + html += '</select>'; + html += '</div>'; + } ); + + 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 += '<div class="selectionBoxRow">'; html += '<div class="selectionLabel">' + category.name + '</div> '; - html += '<select id="category-' + category.id + '" class="selectionBoxSelect">'; + html += '<select id="category-' + category.id + '" class="selectionBoxSelect" onchange="dhis2.de.attributeSelected(\'' + category.id + '\')">'; html += '<option value="-1">[ ' + i18n_select_option + ' ]</option>'; $.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 // -----------------------------------------------------------------------------
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp