dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13726
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4479: Fixed bug. Data set list was not being cleared when selecting an orgunit with no datasets assigned.
------------------------------------------------------------
revno: 4479
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-08-29 21:29:19 +0200
message:
Fixed bug. Data set list was not being cleared when selecting an orgunit with no datasets assigned.
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 2011-08-29 19:28:09 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-08-29 19:29:19 +0000
@@ -25,6 +25,9 @@
// Indicates whether any data entry form has been loaded
var dataEntryFormIsLoaded = false;
+// Indicates whether meta data is loaded
+var metaDataIsLoaded = false;
+
// Currently selected organisation unit identifier
var currentOrganisationUnitId = null;
@@ -155,6 +158,7 @@
dataSetAssociationSets = metaData.dataSetAssociationSets;
organisationUnitAssociationSetMap = metaData.organisationUnitAssociationSetMap;
+ metaDataIsLoaded = true;
selection.responseReceived(); // Notify that meta data is loaded
$( '#loaderSpan' ).hide();
log( 'Meta-data loaded' );
@@ -437,6 +441,11 @@
function organisationUnitSelected( orgUnits, orgUnitNames )
{
+ if ( metaDataIsLoaded == false )
+ {
+ return false;
+ }
+
currentOrganisationUnitId = orgUnits[0];
var organisationUnitName = orgUnitNames[0];
@@ -445,42 +454,39 @@
var dataSetList = getSortedDataSetList();
- if ( dataSetList.length )
- {
- $( '#selectedDataSetId' ).removeAttr( 'disabled' );
-
- var dataSetId = $( '#selectedDataSetId' ).val();
- var periodId = $( '#selectedPeriodId' ).val();
+ $( '#selectedDataSetId' ).removeAttr( 'disabled' );
- clearListById( 'selectedDataSetId' );
- addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
-
- 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();
- }
+ var dataSetId = $( '#selectedDataSetId' ).val();
+ var periodId = $( '#selectedPeriodId' ).val();
+
+ clearListById( 'selectedDataSetId' );
+ addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
+
+ 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();
}
}