=== 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-08-18 17:44:21 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-08-19 08:39:08 +0000 @@ -51,13 +51,13 @@ * Page init. The order of events is: * * 1. Load ouwt - * 2. Load meta-data - * 3. Upload potential locally stored data values to server - * 4. Check and potentially download updated forms from server + * 2. Load meta-data (and notify ouwt) + * 3. Check and potentially download updated forms from server */ $( document ).ready( function() { selection.setListenerFunction( organisationUnitSelected ); + $( '#loaderSpan' ).show(); $( '#orgUnitTree' ).one( 'ouwtLoaded', function() { console.log( 'Ouwt loaded' ); @@ -120,7 +120,10 @@ dataSetAssociationSets = json.metaData.dataSetAssociationSets; organisationUnitAssociationSetMap = json.metaData.organisationUnitAssociationSetMap; - console.log( 'Meta-data loaded' ); + selection.responseReceived(); // Notify that meta data is loaded + $( '#loaderSpan' ).hide(); + console.log( 'Meta-data loaded' ); + updateForms(); } ); } @@ -358,46 +361,47 @@ currentOrganisationUnitId = orgUnits[0]; var organisationUnitName = orgUnitNames[0]; - $( '#selectedDataSetId' ).removeAttr( 'disabled' ); - - var dataSetId = $( '#selectedDataSetId' ).val(); - var periodId = $( '#selectedPeriodId' ).val(); - $( '#selectedOrganisationUnit' ).val( organisationUnitName ); $( '#currentOrganisationUnit' ).html( organisationUnitName ); - clearListById( 'selectedDataSetId' ); - - addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' ); - var dataSetList = getSortedDataSetList(); - var dataSetValid = false; - - for ( i in dataSetList ) - { - addOptionById( 'selectedDataSetId', dataSetList[i].id, dataSetList[i].name ); - - if ( dataSetId == dataSetList[i].id ) - { - dataSetValid = true; - } - } - - if ( dataSetValid && dataSetId != null ) - { - $( '#selectedDataSetId' ).val( dataSetId ); - - if ( periodId && periodId != -1 && dataEntryFormIsLoaded ) - { - showLoader(); - loadDataValues(); - } - } - else - { - clearPeriod(); - } + if ( dataSetList.length ) + { + $( '#selectedDataSetId' ).removeAttr( 'disabled' ); + clearListById( 'selectedDataSetId' ); + addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' ); + + var dataSetId = $( '#selectedDataSetId' ).val(); + var periodId = $( '#selectedPeriodId' ).val(); + + var dataSetValid = false; + + for ( i in dataSetList ) + { + addOptionById( 'selectedDataSetId', dataSetList[i].id, dataSetList[i].name ); + + if ( dataSetId == dataSetList[i].id ) + { + dataSetValid = true; + } + } + + if ( dataSetValid && dataSetId != null ) + { + $( '#selectedDataSetId' ).val( dataSetId ); + + if ( periodId && periodId != -1 && dataEntryFormIsLoaded ) + { + showLoader(); + loadDataValues(); + } + } + else + { + clearPeriod(); + } + } } // ----------------------------------------------------------------------------- === 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-08-18 12:59:54 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/select.vm 2011-08-19 08:39:08 +0000 @@ -51,7 +51,8 @@ - + +