=== 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-22 10:11:38 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2013-12-22 13:10:39 +0000 @@ -70,7 +70,7 @@ // Instance of the StorageManager dhis2.de.storageManager = new StorageManager(); -// Is this form a multiOrg form? +// Indicates whether current form is multi org unit dhis2.de.multiOrganisationUnit = false; // "organisationUnits" object inherited from ouwt.js @@ -589,7 +589,7 @@ $( '#contentDiv' ).html( html ); - dhis2.de.multiOrganisationUnit = !!$('.formSection').data('multiorg'); + dhis2.de.multiOrganisationUnit = !!$( '.formSection' ).data( 'multiorg' ); if ( !dhis2.de.multiOrganisationUnit ) { @@ -614,7 +614,7 @@ }, function() { - dhis2.de.multiOrganisationUnit = !!$( '.formSection').data('multiorg' ); + dhis2.de.multiOrganisationUnit = !!$( '.formSection' ).data( 'multiorg' ); if ( !dhis2.de.multiOrganisationUnit ) { @@ -783,69 +783,6 @@ // OrganisationUnit Selection // ----------------------------------------------------------------------------- -/** - * Returns an array containing associative array elements with id and name - * properties. The array is sorted on the element name property. - */ -function getSortedDataSetList( orgUnit ) -{ - var associationSet = orgUnit !== undefined ? dhis2.de.organisationUnitAssociationSetMap[orgUnit] : dhis2.de.organisationUnitAssociationSetMap[getCurrentOrganisationUnit()]; - var orgUnitDataSets = dhis2.de.dataSetAssociationSets[associationSet]; - - var dataSetList = []; - - $.safeEach( orgUnitDataSets, function( idx, item ) - { - var dataSetId = orgUnitDataSets[idx]; - var dataSetName = dhis2.de.dataSets[dataSetId].name; - - var row = []; - row['id'] = dataSetId; - row['name'] = dataSetName; - dataSetList[idx] = row; - } ); - - dataSetList.sort( function( a, b ) - { - return a.name > b.name ? 1 : a.name < b.name ? -1 : 0; - } ); - - return dataSetList; -} - -function getSortedDataSetListForOrgUnits( orgUnits ) -{ - var dataSetList = []; - - $.safeEach( orgUnits, function( idx, item ) - { - dataSetList.push.apply( dataSetList, getSortedDataSetList(item) ) - } ); - - var filteredDataSetList = []; - - $.safeEach( dataSetList, function( idx, item ) - { - var formType = dhis2.de.dataSets[item.id].type; - var found = false; - - $.safeEach( filteredDataSetList, function( i, el ) - { - if( item.name == el.name ) - { - found = true; - } - } ); - - if ( !found && ( formType == FORMTYPE_SECTION || formType == FORMTYPE_DEFAULT ) ) - { - filteredDataSetList.push(item); - } - } ); - - return filteredDataSetList; -} - function organisationUnitSelected( orgUnits, orgUnitNames, children ) { if ( dhis2.de.metaDataIsLoaded == false ) @@ -897,7 +834,7 @@ multiDataSetValid = true; } - $( '