=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/criteria.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/criteria.js 2011-03-15 23:26:14 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/criteria.js 2011-06-23 14:38:00 +0000 @@ -1,37 +1,35 @@ - // ------------------------------------------------------------------------- // Public methods // ------------------------------------------------------------------------- function toggleDataType() -{ - $( "#indicatorGroupDiv" ).toggle(); - $( "#dataElementGroupDiv" ).toggle(); +{ + $( "#indicatorGroupDiv" ).toggle(); + $( "#dataElementGroupDiv" ).toggle(); } function showCriteria() { - $( "div#criteria" ).show( "fast" ); + $( "div#criteria" ).show( "fast" ); } function hideCriteria() { - $( "div#criteria" ).hide( "fast" ); + $( "div#criteria" ).hide( "fast" ); } function showPivot() { - $( "div#pivot" ).show( "fast" ); + $( "div#pivot" ).show( "fast" ); } function hidePivot() { - $( "div#pivot" ).hide( "fast" ); + $( "div#pivot" ).hide( "fast" ); } function hideDivs() { - hideCriteria(); - hidePivot(); + hideCriteria(); + hidePivot(); } - === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js 2011-03-19 22:30:32 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataCompleteness.js 2011-06-23 14:38:00 +0000 @@ -1,59 +1,59 @@ - var isOrganisationUnit = false; function organisationUnitSelected( units ) { - isOrganisationUnit = units && units.length > 0; + isOrganisationUnit = units && units.length > 0; } function getPeriods( periodTypeList, availableList, selectedList, timespan ) { - $( "#periodId" ).removeAttr( "disabled" ); - - getAvailablePeriods( periodTypeList, availableList, selectedList, timespan ); + $( "#periodId" ).removeAttr( "disabled" ); + + getAvailablePeriods( periodTypeList, availableList, selectedList, timespan ); } function displayCompleteness() { var criteria = $( "input[name='criteria']:checked" ).val(); var dataSetId = $( "#dataSetId" ).val(); - var periodList = byId( "periodId" ); + var periodList = byId( "periodId" ); var periodId = periodList.options.length > 0 ? $( "#periodId" ).val() : null; - - if ( !completenessIsValid( periodId ) ) - { - return false; - } - + + if ( !completenessIsValid( periodId ) ) + { + return false; + } + showLoader(); - - var url = "getDataCompleteness.action" + "?periodId=" + periodId + "&criteria=" + criteria + - "&dataSetId=" + dataSetId + "&type=html"; - - $( "#contentDiv" ).load( url, function() { - hideLoader(); + + var url = "getDataCompleteness.action" + "?periodId=" + periodId + "&criteria=" + criteria + "&dataSetId=" + + dataSetId + "&type=html"; + + $( "#contentDiv" ).load( url, function() + { + hideLoader(); pageInit(); } ); } function completenessIsValid( periodId ) { - if ( !isOrganisationUnit ) - { - setHeaderDelayMessage( i18n_please_select_org_unit ); - return false; - } - - if ( periodId == null ) - { - setHeaderDelayMessage( i18n_please_select_period ); - return false; - } - - return true; + if ( !isOrganisationUnit ) + { + setHeaderDelayMessage( i18n_please_select_org_unit ); + return false; + } + + if ( periodId == null ) + { + setHeaderDelayMessage( i18n_please_select_period ); + return false; + } + + return true; } function getCompleteness( type ) { - window.location.href = "getDataCompleteness.action?type=" + type; + window.location.href = "getDataCompleteness.action?type=" + type; } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2011-05-31 11:18:52 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2011-06-23 14:38:00 +0000 @@ -1,4 +1,3 @@ - // ----------------------------------------------------------------------------- // Validation // ---------------------------------------------------------------------------- @@ -10,16 +9,16 @@ selectedOrganisationUnitIds = ids; } -if ( typeof( selectionTreeSelection ) != "undefined" ) +if ( typeof ( selectionTreeSelection ) != "undefined" ) { selectionTreeSelection.setListenerFunction( setSelectedOrganisationUnitIds ); } function getPeriods( periodTypeList, availableList, selectedList, timespan ) { - $( "#periodId" ).removeAttr( "disabled" ); - - getAvailablePeriods( periodTypeList, availableList, selectedList, timespan ); + $( "#periodId" ).removeAttr( "disabled" ); + + getAvailablePeriods( periodTypeList, availableList, selectedList, timespan ); } function validateDataSetReport() @@ -39,12 +38,12 @@ setMessage( i18n_select_organisation_unit ); return false; } - - document.getElementById( "reportForm" ).submit(); + + document.getElementById( "reportForm" ).submit(); } function exportDataSetReport( type ) { - var url = "generateDataSetReport.action?useLast=true&dataSetId=" + $( "#dataSetId" ).val() + "&type=" + type; - window.location.href = url; + var url = "generateDataSetReport.action?useLast=true&dataSetId=" + $( "#dataSetId" ).val() + "&type=" + type; + window.location.href = url; } \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js 2010-09-16 09:43:15 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/document.js 2011-06-23 14:38:00 +0000 @@ -1,16 +1,15 @@ - function removeDocument( id ) { - removeItem( id, "", i18n_confirm_remove_report, "removeDocument.action" ); + removeItem( id, "", i18n_confirm_remove_report, "removeDocument.action" ); } function addDocumentToDashboard( id ) { var dialog = window.confirm( i18n_confirm_add_to_dashboard ); - + if ( dialog ) { - var request = new Request(); + var request = new Request(); request.send( "addDocumentToDashboard.action?id=" + id ); } } @@ -18,22 +17,21 @@ function toggleExternal() { var external = getListValue( "external" ); - + if ( external == "true" ) { document.getElementById( "fileDiv" ).style.display = "none"; document.getElementById( "urlDiv" ).style.display = "block"; - $('#url').attr('class','{validate:{required:true}}'); - $('#upload').attr('class',''); - } - else + $( '#url' ).attr( 'class', '{validate:{required:true}}' ); + $( '#upload' ).attr( 'class', '' ); + } else { document.getElementById( "fileDiv" ).style.display = "block"; document.getElementById( "urlDiv" ).style.display = "none"; - if( byId('id').value == "") - { - $('#upload').attr('class','{validate:{required:true}}'); - $('#url').attr('class',''); - } + if ( byId( 'id' ).value == "" ) + { + $( '#upload' ).attr( 'class', '{validate:{required:true}}' ); + $( '#url' ).attr( 'class', '' ); + } } } === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2011-03-10 10:22:31 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/generateReport.js 2011-06-23 14:38:00 +0000 @@ -1,4 +1,3 @@ - var MODE_REPORT = "report"; var MODE_TABLE = "table"; @@ -12,7 +11,7 @@ function paramOrganisationUnitSet( id ) { - paramOrganisationUnit = id; + paramOrganisationUnit = id; } // ----------------------------------------------------------------------------- @@ -21,14 +20,14 @@ function validationError() { - if ( $( "#selectionTree" ).length && paramOrganisationUnit == null ) - { - setMessage( i18n_please_select_unit ); - return true; - } - - return false; -} + if ( $( "#selectionTree" ).length && paramOrganisationUnit == null ) + { + setMessage( i18n_please_select_unit ); + return true; + } + + return false; +} // ----------------------------------------------------------------------------- // Report @@ -36,38 +35,37 @@ function generateReport( type ) { - reportType = type != null && type != "" ? type : "pdf"; - - if ( validationError() ) - { - return false; - } - + reportType = type != null && type != "" ? type : "pdf"; + + if ( validationError() ) + { + return false; + } + setWaitMessage( i18n_please_wait ); - + var doDataMart = ( $( "#doDataMart" ).length && $( "#doDataMart" ).val() == "true" ); - + if ( doDataMart ) - { - var url = "createTable.action?" + getUrlParams(); - - var request = new Request(); - request.setCallbackSuccess( getReportStatus ); - request.send( url ); - } - else - { - viewReport(); + { + var url = "createTable.action?" + getUrlParams(); + + var request = new Request(); + request.setCallbackSuccess( getReportStatus ); + request.send( url ); + } else + { + viewReport(); } } function getReportStatus() -{ +{ var url = "getStatus.action"; - + var request = new Request(); request.setResponseTypeXML( "status" ); - request.setCallbackSuccess( reportStatusReceived ); + request.setCallbackSuccess( reportStatusReceived ); request.send( url ); } @@ -75,13 +73,12 @@ { var statusMessage = getElementValue( xmlObject, "statusMessage" ); var finished = getElementValue( xmlObject, "finished" ); - + if ( finished == "true" ) { setMessage( i18n_process_completed ); - viewReport(); - } - else + viewReport(); + } else { setTimeout( "getReportStatus();", 1500 ); } @@ -89,35 +86,35 @@ function viewReport( urlParams ) { - var mode = $( "#mode" ).val(); - - setMessage( i18n_process_completed ); - + var mode = $( "#mode" ).val(); + + setMessage( i18n_process_completed ); + if ( mode == MODE_REPORT ) { - window.location.href = "renderReport.action?type=" + reportType + "&" + getUrlParams(); - } - else // MODE_TABLE + window.location.href = "renderReport.action?type=" + reportType + "&" + getUrlParams(); + } else + // MODE_TABLE { - window.location.href = "exportTable.action?type=html&" + getUrlParams(); + window.location.href = "exportTable.action?type=html&" + getUrlParams(); } } function getUrlParams() { - var url = "id=" + $( "#id" ).val() + "&mode=" + $( "#mode" ).val(); - + var url = "id=" + $( "#id" ).val() + "&mode=" + $( "#mode" ).val(); + if ( $( "#reportingPeriod" ).length ) { url += "&reportingPeriod=" + $( "#reportingPeriod" ).val(); } - + if ( paramOrganisationUnit != null ) { url += "&organisationUnitId=" + paramOrganisationUnit; } - - return url; + + return url; } // ----------------------------------------------------------------------------- @@ -126,9 +123,9 @@ function exportReport( type ) { - var url = "exportTable.action?type=" + type + "&useLast=true"; - - url += $( "#id" ).length ? ( "&id=" + $( "#id" ).val() ) : ""; - - window.location.href = url; + var url = "exportTable.action?type=" + type + "&useLast=true"; + + url += $( "#id" ).length ? ( "&id=" + $( "#id" ).val() ) : ""; + + window.location.href = url; } === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/lists.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/lists.js 2011-01-31 19:47:04 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/lists.js 2011-06-23 14:38:00 +0000 @@ -1,40 +1,39 @@ - // ------------------------------------------------------------------------- // Data retrieval methods // ------------------------------------------------------------------------- function getDataElements() { - var dataElementGroupList = document.getElementById( "dataElementGroupId" ); - var dataElementGroupId = dataElementGroupList.options[ dataElementGroupList.selectedIndex ].value; - - if ( dataElementGroupId != null ) - { - var url = "../dhis-web-commons-ajax/getDataElements.action?id=" + dataElementGroupId + "&aggregate=true"; - - var request = new Request(); - request.setResponseTypeXML( 'dataElement' ); - request.setCallbackSuccess( getDataElementsReceived ); - request.send( url ); - } + var dataElementGroupList = document.getElementById( "dataElementGroupId" ); + var dataElementGroupId = dataElementGroupList.options[dataElementGroupList.selectedIndex].value; + + if ( dataElementGroupId != null ) + { + var url = "../dhis-web-commons-ajax/getDataElements.action?id=" + dataElementGroupId + "&aggregate=true"; + + var request = new Request(); + request.setResponseTypeXML( 'dataElement' ); + request.setCallbackSuccess( getDataElementsReceived ); + request.send( url ); + } } function getDataElementsReceived( xmlObject ) -{ +{ var availableDataElements = document.getElementById( "availableDataElements" ); var selectedDataElements = document.getElementById( "selectedDataElements" ); - + clearList( availableDataElements ); - + var dataElements = xmlObject.getElementsByTagName( "dataElement" ); - + for ( var i = 0; i < dataElements.length; i++ ) { - var id = dataElements[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue; - var dataElementName = dataElements[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue; - + var id = dataElements[i].getElementsByTagName( "id" )[0].firstChild.nodeValue; + var dataElementName = dataElements[i].getElementsByTagName( "name" )[0].firstChild.nodeValue; + if ( listContains( selectedDataElements, id ) == false ) - { + { var option = document.createElement( "option" ); option.value = id; option.text = dataElementName; @@ -46,11 +45,11 @@ function getCategoryComboDataElements() { var categoryComboId = getListValue( "categoryComboId" ); - + if ( categoryComboId != null ) { var url = "getCategoryComboDataElements.action?categoryComboId=" + categoryComboId; - + var request = new Request(); request.setResponseTypeXML( 'dataElement' ); request.setCallbackSuccess( getCategoryComboDataElementsReceived ); @@ -59,20 +58,20 @@ } function getCategoryComboDataElementsReceived( xmlObject ) -{ +{ var availableDataElements = document.getElementById( "availableDataElements" ); var selectedDataElements = document.getElementById( "selectedDataElements" ); - + clearList( availableDataElements ); clearList( selectedDataElements ); - + var dataElements = xmlObject.getElementsByTagName( "dataElement" ); - + for ( var i = 0; i < dataElements.length; i++ ) { - var id = dataElements[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue; - var dataElementName = dataElements[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue; - + var id = dataElements[i].getElementsByTagName( "id" )[0].firstChild.nodeValue; + var dataElementName = dataElements[i].getElementsByTagName( "name" )[0].firstChild.nodeValue; + var option = document.createElement( "option" ); option.value = id; option.text = dataElementName; @@ -82,36 +81,36 @@ function getIndicators() { - var indicatorGroupList = document.getElementById( "indicatorGroupId" ); - var indicatorGroupId = indicatorGroupList.options[ indicatorGroupList.selectedIndex ].value; - - if ( indicatorGroupId != null ) - { - var url = "../dhis-web-commons-ajax/getIndicators.action?id=" + indicatorGroupId; - - var request = new Request(); - request.setResponseTypeXML( 'indicator' ); - request.setCallbackSuccess( getIndicatorsReceived ); - request.send( url ); - } + var indicatorGroupList = document.getElementById( "indicatorGroupId" ); + var indicatorGroupId = indicatorGroupList.options[indicatorGroupList.selectedIndex].value; + + if ( indicatorGroupId != null ) + { + var url = "../dhis-web-commons-ajax/getIndicators.action?id=" + indicatorGroupId; + + var request = new Request(); + request.setResponseTypeXML( 'indicator' ); + request.setCallbackSuccess( getIndicatorsReceived ); + request.send( url ); + } } function getIndicatorsReceived( xmlObject ) -{ +{ var availableIndicators = document.getElementById( "availableIndicators" ); var selectedIndicators = document.getElementById( "selectedIndicators" ); - + clearList( availableIndicators ); - + var indicators = xmlObject.getElementsByTagName( "indicator" ); - + for ( var i = 0; i < indicators.length; i++ ) { - var id = indicators[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue; - var indicatorName = indicators[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue; - + var id = indicators[i].getElementsByTagName( "id" )[0].firstChild.nodeValue; + var indicatorName = indicators[i].getElementsByTagName( "name" )[0].firstChild.nodeValue; + if ( listContains( selectedIndicators, id ) == false ) - { + { var option = document.createElement( "option" ); option.value = id; option.text = indicatorName; @@ -122,36 +121,36 @@ function getOrganisationUnits() { - var organisationUnitLevelList = document.getElementById( "organisationUnitLevel" ); - var organisationUnitLevel = organisationUnitLevelList.options[ organisationUnitLevelList.selectedIndex ].value; - - if ( organisationUnitLevel != null ) - { - var url = "../dhis-web-commons-ajax/getOrganisationUnits.action?level=" + organisationUnitLevel; - - var request = new Request(); - request.setResponseTypeXML( 'organisationUnit' ); - request.setCallbackSuccess( getOrganisationUnitsReceived ); - request.send( url ); - } + var organisationUnitLevelList = document.getElementById( "organisationUnitLevel" ); + var organisationUnitLevel = organisationUnitLevelList.options[organisationUnitLevelList.selectedIndex].value; + + if ( organisationUnitLevel != null ) + { + var url = "../dhis-web-commons-ajax/getOrganisationUnits.action?level=" + organisationUnitLevel; + + var request = new Request(); + request.setResponseTypeXML( 'organisationUnit' ); + request.setCallbackSuccess( getOrganisationUnitsReceived ); + request.send( url ); + } } function getOrganisationUnitsReceived( xmlObject ) -{ +{ var availableOrganisationUnits = document.getElementById( "availableOrganisationUnits" ); var selectedOrganisationUnits = document.getElementById( "selectedOrganisationUnits" ); - + clearList( availableOrganisationUnits ); - + var organisationUnits = xmlObject.getElementsByTagName( "organisationUnit" ); - + for ( var i = 0; i < organisationUnits.length; i++ ) { - var id = organisationUnits[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue; - var organisationUnitName = organisationUnits[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue; - + var id = organisationUnits[i].getElementsByTagName( "id" )[0].firstChild.nodeValue; + var organisationUnitName = organisationUnits[i].getElementsByTagName( "name" )[0].firstChild.nodeValue; + if ( listContains( selectedOrganisationUnits, id ) == false ) - { + { var option = document.createElement( "option" ); option.value = id; option.text = organisationUnitName; @@ -163,32 +162,32 @@ function getOrganisationUnitsToSelected() { var organisationUnitLevelList = document.getElementById( "organisationUnitLevel" ); - var organisationUnitLevel = organisationUnitLevelList.options[ organisationUnitLevelList.selectedIndex ].value; - + var organisationUnitLevel = organisationUnitLevelList.options[organisationUnitLevelList.selectedIndex].value; + if ( organisationUnitLevel != null ) { var url = "../dhis-web-commons-ajax/getOrganisationUnits.action?level=" + organisationUnitLevel; - + var request = new Request(); request.setResponseTypeXML( 'organisationUnit' ); request.setCallbackSuccess( getOrganisationUnitsToSelectedReceived ); - request.send( url ); + request.send( url ); } } function getOrganisationUnitsToSelectedReceived( xmlObject ) -{ +{ var selectedOrganisationUnits = document.getElementById( "selectedOrganisationUnits" ); - + clearList( selectedOrganisationUnits ); - + var organisationUnits = xmlObject.getElementsByTagName( "organisationUnit" ); - + for ( var i = 0; i < organisationUnits.length; i++ ) { - var id = organisationUnits[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue; - var organisationUnitName = organisationUnits[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue; - + var id = organisationUnits[i].getElementsByTagName( "id" )[0].firstChild.nodeValue; + var organisationUnitName = organisationUnits[i].getElementsByTagName( "name" )[0].firstChild.nodeValue; + var option = document.createElement( "option" ); option.value = id; option.text = organisationUnitName; @@ -198,32 +197,32 @@ function getOrganisationUnitChildren() { - var organisationUnitList = document.getElementById( "availableOrganisationUnits" ); - var organisationUnitId = organisationUnitList.options[ organisationUnitList.selectedIndex ].value; - - if ( organisationUnitId != null ) - { - var url = "../dhis-web-commons-ajax/getOrganisationUnitChildren.action?id=" + organisationUnitId; - - var request = new Request(); - request.setResponseTypeXML( 'organisationUnit' ); - request.setCallbackSuccess( getOrganisationUnitChildrenReceived ); - request.send( url ); - } + var organisationUnitList = document.getElementById( "availableOrganisationUnits" ); + var organisationUnitId = organisationUnitList.options[organisationUnitList.selectedIndex].value; + + if ( organisationUnitId != null ) + { + var url = "../dhis-web-commons-ajax/getOrganisationUnitChildren.action?id=" + organisationUnitId; + + var request = new Request(); + request.setResponseTypeXML( 'organisationUnit' ); + request.setCallbackSuccess( getOrganisationUnitChildrenReceived ); + request.send( url ); + } } function getOrganisationUnitChildrenReceived( xmlObject ) { var selectedOrganisationUnits = document.getElementById( "selectedOrganisationUnits" ); - + var organisationUnits = xmlObject.getElementsByTagName( "organisationUnit" ); - + for ( var i = 0; i < organisationUnits.length; i++ ) { - var id = organisationUnits[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue; - - var organisationUnitName = organisationUnits[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue; - + var id = organisationUnits[i].getElementsByTagName( "id" )[0].firstChild.nodeValue; + + var organisationUnitName = organisationUnits[i].getElementsByTagName( "name" )[0].firstChild.nodeValue; + if ( listContains( selectedOrganisationUnits, id ) == false ) { var option = document.createElement( "option" ); @@ -237,12 +236,12 @@ function getPeriodsToSelected() { var periodTypeList = document.getElementById( "periodTypeId" ); - var periodTypeId = periodTypeList.options[ periodTypeList.selectedIndex ].value; - + var periodTypeId = periodTypeList.options[periodTypeList.selectedIndex].value; + if ( periodTypeId != null ) - { + { var url = "../dhis-web-commons-ajax/getPeriods.action?name=" + periodTypeId; - + var request = new Request(); request.setResponseTypeXML( 'period' ); request.setCallbackSuccess( getPeriodsToSelectedReceived ); @@ -251,18 +250,18 @@ } function getPeriodsToSelectedReceived( xmlObject ) -{ +{ var selectedPeriods = document.getElementById( "selectedPeriods" ); - + clearList( selectedPeriods ); - + var periods = xmlObject.getElementsByTagName( "period" ); - - for ( var i = 0; i < periods.length; i++) + + for ( var i = 0; i < periods.length; i++ ) { - var id = periods[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue; - var periodName = periods[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue; - + var id = periods[i].getElementsByTagName( "id" )[0].firstChild.nodeValue; + var periodName = periods[i].getElementsByTagName( "name" )[0].firstChild.nodeValue; + var option = document.createElement( "option" ); option.value = id; option.text = periodName; === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js 2011-02-28 02:42:12 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/orgUnitDistribution.js 2011-06-23 14:38:00 +0000 @@ -1,66 +1,77 @@ - var selectedOrganisationUnit = null; -var distributionDivs = ["chartDiv","tableDiv","loaderDiv"]; - -function organisationUnitSelected( units ) { - if ( units && units[0] ) { - selectedOrganisationUnit = units[0]; - } - else { - selectedOrganisationUnit = null; - } -} - -function displayOrgUnitDistribution() { - if ( inputInvalid() ) { - return false; - } - - displayDiv( "loaderDiv", distributionDivs ); - - var groupSetId = $( "#groupSetId" ).val(); - var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=html&r=" + getRandomNumber(); - $( "#tableDiv" ).load( url, function() { - displayDiv( "tableDiv", distributionDivs ); - pageInit(); - } ); -} - -function getOrgUnitDistribution( type ) { - if ( inputInvalid() ) { - return false; - } - - var groupSetId = $( "#groupSetId" ).val(); - var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=" + type + "&r=" + getRandomNumber(); - window.location.href = url; -} - -function displayOrgUnitDistributionChart() { - if ( inputInvalid() ) { - return false; - } - - displayDiv( "chartDiv", distributionDivs ); - $( "#chartImg" ).attr( "src", "../images/ajax-loader-circle.gif" ); - var groupSetId = $( "#groupSetId" ).val(); - var source = "getOrgUnitDistributionChart.action?groupSetId=" + groupSetId + "&r=" + getRandomNumber(); - $( "#chartImg" ).attr( "src", source ); -} - -function inputInvalid() { - var groupSetId = $( "#groupSetId" ).val(); - - if ( groupSetId == null || groupSetId == 0 ) { - setHeaderDelayMessage( i18n_select_group_set ); - return true; - } - - if ( selectedOrganisationUnit == null || selectedOrganisationUnit == "" ) { - setHeaderDelayMessage( i18n_select_org_unit ); - return true; - } - - return false; +var distributionDivs = [ "chartDiv", "tableDiv", "loaderDiv" ]; + +function organisationUnitSelected( units ) +{ + if ( units && units[0] ) + { + selectedOrganisationUnit = units[0]; + } else + { + selectedOrganisationUnit = null; + } +} + +function displayOrgUnitDistribution() +{ + if ( inputInvalid() ) + { + return false; + } + + displayDiv( "loaderDiv", distributionDivs ); + + var groupSetId = $( "#groupSetId" ).val(); + var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=html&r=" + getRandomNumber(); + $( "#tableDiv" ).load( url, function() + { + displayDiv( "tableDiv", distributionDivs ); + pageInit(); + } ); +} + +function getOrgUnitDistribution( type ) +{ + if ( inputInvalid() ) + { + return false; + } + + var groupSetId = $( "#groupSetId" ).val(); + var url = "getOrgUnitDistribution.action?groupSetId=" + groupSetId + "&type=" + type + "&r=" + getRandomNumber(); + window.location.href = url; +} + +function displayOrgUnitDistributionChart() +{ + if ( inputInvalid() ) + { + return false; + } + + displayDiv( "chartDiv", distributionDivs ); + $( "#chartImg" ).attr( "src", "../images/ajax-loader-circle.gif" ); + var groupSetId = $( "#groupSetId" ).val(); + var source = "getOrgUnitDistributionChart.action?groupSetId=" + groupSetId + "&r=" + getRandomNumber(); + $( "#chartImg" ).attr( "src", source ); +} + +function inputInvalid() +{ + var groupSetId = $( "#groupSetId" ).val(); + + if ( groupSetId == null || groupSetId == 0 ) + { + setHeaderDelayMessage( i18n_select_group_set ); + return true; + } + + if ( selectedOrganisationUnit == null || selectedOrganisationUnit == "" ) + { + setHeaderDelayMessage( i18n_select_org_unit ); + return true; + } + + return false; } === modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js' --- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js 2011-06-17 17:53:38 +0000 +++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/pivot.js 2011-06-23 14:38:00 +0000 @@ -1,4 +1,3 @@ - // ----------------------------------------------------------------------------- // Global variables // ----------------------------------------------------------------------------- @@ -6,7 +5,8 @@ var indicators = []; // Array->associative array (id,name) var periods = []; // Array->associative array (id,name) var orgunits = []; // Array->associative array (id,name) -var data = []; // Associative array [(indicator-period-orgunit), (indicatorValue)] +var data = []; // Associative array [(indicator-period-orgunit), + // (indicatorValue)] var sizes = []; // Associative array (dimension, size) @@ -33,73 +33,68 @@ */ function organisationUnitSelected( orgunits ) { - organisationUnitId = orgunits ? orgunits[0] : null; + organisationUnitId = orgunits ? orgunits[0] : null; } /** - * This method is called from the UI and is responsible for retrieving data from + * This method is called from the UI and is responsible for retrieving data from * the server and setting the global variables. */ function getData() { - if ( organisationUnitId == -1 ) - { - setHeaderDelayMessage( i18n_selected_organisation_unit ); - } - else - { - clearGlobalVariables(); - - var dataType = $( "#dataType" ).val(); - var indicatorGroupId = $( "#indicatorGroup" ).val(); - var dataElementGroupId = $( "#dataElementGroup" ).val(); - var startDate = $( "#startDate" ).val(); - var endDate = $( "#endDate" ).val(); - var periodTypeName = $( "#periodType" ).val(); - - document.getElementById( "dataLabel" ).innerHTML = i18n_start_date + ": " + startDate + - ", " + i18n_end_date + ": " + endDate + ", " + i18n_period_type + ": " + periodTypeName; - - var url = "getPivotTable.action"; - - var groupId = dataType == DATA_TYPE_INDICATOR ? indicatorGroupId : dataElementGroupId; - - currentDataType = dataType; - - hideDivs(); - - showLoader(); - - $.getJSON( - url, - { - "dataType": dataType, - "groupId": groupId, - "periodTypeName": periodTypeName, - "startDate": startDate, - "endDate": endDate, - "organisationUnitId": organisationUnitId - }, - function( json ) - { - var pivot = json.pivotTable; - - indicators = pivot.indicators; - periods = pivot.periods; - orgunits = pivot.organisationUnits; - - sizes["indicator"] = pivot.sizeIndicators; - sizes["period"] = pivot.sizePeriods; - sizes["orgunit"] = pivot.sizeOrganisationUnits; - - data = pivot.indicatorValues[0]; - - hideLoader(); - - generateTable(); - } - ); - } + if ( organisationUnitId == -1 ) + { + setHeaderDelayMessage( i18n_selected_organisation_unit ); + } else + { + clearGlobalVariables(); + + var dataType = $( "#dataType" ).val(); + var indicatorGroupId = $( "#indicatorGroup" ).val(); + var dataElementGroupId = $( "#dataElementGroup" ).val(); + var startDate = $( "#startDate" ).val(); + var endDate = $( "#endDate" ).val(); + var periodTypeName = $( "#periodType" ).val(); + + document.getElementById( "dataLabel" ).innerHTML = i18n_start_date + ": " + startDate + ", " + i18n_end_date + + ": " + endDate + ", " + i18n_period_type + ": " + periodTypeName; + + var url = "getPivotTable.action"; + + var groupId = dataType == DATA_TYPE_INDICATOR ? indicatorGroupId : dataElementGroupId; + + currentDataType = dataType; + + hideDivs(); + + showLoader(); + + $.getJSON( url, { + "dataType" : dataType, + "groupId" : groupId, + "periodTypeName" : periodTypeName, + "startDate" : startDate, + "endDate" : endDate, + "organisationUnitId" : organisationUnitId + }, function( json ) + { + var pivot = json.pivotTable; + + indicators = pivot.indicators; + periods = pivot.periods; + orgunits = pivot.organisationUnits; + + sizes["indicator"] = pivot.sizeIndicators; + sizes["period"] = pivot.sizePeriods; + sizes["orgunit"] = pivot.sizeOrganisationUnits; + + data = pivot.indicatorValues[0]; + + hideLoader(); + + generateTable(); + } ); + } } /** @@ -107,13 +102,13 @@ */ function pivotData() { - pivotIndicator = document.getElementById( "indicatorBox" ).checked; - pivotPeriod = document.getElementById( "periodBox" ).checked; - pivotOrgunit = document.getElementById( "orgunitBox" ).checked; - - hideDivs(); - - generateTable(); + pivotIndicator = document.getElementById( "indicatorBox" ).checked; + pivotPeriod = document.getElementById( "periodBox" ).checked; + pivotOrgunit = document.getElementById( "orgunitBox" ).checked; + + hideDivs(); + + generateTable(); } /** @@ -121,64 +116,63 @@ */ function viewChart( chartIndicators, chartDimension ) { - var chartWidth = 750; - - var url = "generateChart.action"; - - if ( chartIndicators == "single" && chartDimension == "period" ) - { - url += "?indicatorId=" + currentIndicator + "&organisationUnitId=" + currentOrgunit + "&dimension=period®ression=true"; - - for ( p in periods ) - { - url += "&periodId=" + periods[p].id; - } - } - else if ( chartIndicators == "single" && chartDimension == "orgunit" ) - { - url += "?indicatorId=" + currentIndicator + "&periodId=" + currentPeriod + "&dimension=organisationUnit®ression=false"; - - for ( o in orgunits ) - { - url += "&organisationUnitId=" + orgunits[o].id; - } - } - else if ( chartIndicators == "all" && chartDimension == "period" ) - { - url += "?organisationUnitId=" + currentOrgunit + "&dimension=period®ression=false&chartWidth=950"; - - for ( i in indicators ) - { - url += "&indicatorId=" + indicators[i].id; - } - - for ( p in periods ) - { - url += "&periodId=" + periods[p].id; - } - - chartWidth = 1000; - } - else if ( chartIndicators == "all" && chartDimension == "orgunit" ) - { - url += "?periodId=" + currentPeriod + "&dimension=organisationUnit®ression=false&chartWidth=950"; - - for ( i in indicators ) - { - url += "&indicatorId=" + indicators[i].id; - } - - for ( o in orgunits ) - { - url += "&organisationUnitId=" + orgunits[o].id; - } - - chartWidth = 1000; - } - - hideDropDown(); - - openChartDialog( url, chartWidth ); + var chartWidth = 750; + + var url = "generateChart.action"; + + if ( chartIndicators == "single" && chartDimension == "period" ) + { + url += "?indicatorId=" + currentIndicator + "&organisationUnitId=" + currentOrgunit + + "&dimension=period®ression=true"; + + for ( p in periods ) + { + url += "&periodId=" + periods[p].id; + } + } else if ( chartIndicators == "single" && chartDimension == "orgunit" ) + { + url += "?indicatorId=" + currentIndicator + "&periodId=" + currentPeriod + + "&dimension=organisationUnit®ression=false"; + + for ( o in orgunits ) + { + url += "&organisationUnitId=" + orgunits[o].id; + } + } else if ( chartIndicators == "all" && chartDimension == "period" ) + { + url += "?organisationUnitId=" + currentOrgunit + "&dimension=period®ression=false&chartWidth=950"; + + for ( i in indicators ) + { + url += "&indicatorId=" + indicators[i].id; + } + + for ( p in periods ) + { + url += "&periodId=" + periods[p].id; + } + + chartWidth = 1000; + } else if ( chartIndicators == "all" && chartDimension == "orgunit" ) + { + url += "?periodId=" + currentPeriod + "&dimension=organisationUnit®ression=false&chartWidth=950"; + + for ( i in indicators ) + { + url += "&indicatorId=" + indicators[i].id; + } + + for ( o in orgunits ) + { + url += "&organisationUnitId=" + orgunits[o].id; + } + + chartWidth = 1000; + } + + hideDropDown(); + + openChartDialog( url, chartWidth ); } function openChartDialog( url, width ) @@ -203,14 +197,15 @@ */ function viewChartMenu( indicatorId, periodId, orgunitId ) { - if ( currentDataType == DATA_TYPE_INDICATOR ) // Currently indicators only supported - { - currentIndicator = indicatorId; - currentPeriod = periodId; - currentOrgunit = orgunitId; - - showDropDown( "pivotMenu" ); - } + if ( currentDataType == DATA_TYPE_INDICATOR ) // Currently indicators only + // supported + { + currentIndicator = indicatorId; + currentPeriod = periodId; + currentOrgunit = orgunitId; + + showDropDown( "pivotMenu" ); + } } /** @@ -218,8 +213,8 @@ */ function loadListeners() { - var table = document.getElementById( "pivotTable" ); - table.addEventListener( "click", setPosition, false ); + var table = document.getElementById( "pivotTable" ); + table.addEventListener( "click", setPosition, false ); } // ----------------------------------------------------------------------------- @@ -227,279 +222,283 @@ // ----------------------------------------------------------------------------- /** -* This method sets the position of the pivot menu, and is registered as a -* callback function for mouse click events. -*/ + * This method sets the position of the pivot menu, and is registered as a + * callback function for mouse click events. + */ function setPosition( e ) { - var left = e.pageX + "px"; - var top = e.pageY + "px"; - - var pivotMenu = document.getElementById( "pivotMenu" ); - - pivotMenu.style.left = left; - pivotMenu.style.top = top; + var left = e.pageX + "px"; + var top = e.pageY + "px"; + + var pivotMenu = document.getElementById( "pivotMenu" ); + + pivotMenu.style.left = left; + pivotMenu.style.top = top; } /** * This method is responsible for generating the pivot table. */ function generateTable() -{ - var columnIndicators = pivotIndicator ? indicators : [null]; - var columnPeriods = pivotPeriod ? periods : [null]; - var columnOrgunits = pivotOrgunit ? orgunits : [null]; - - var rowIndicators = pivotIndicator ? [null] : indicators; - var rowPeriods = pivotPeriod ? [null] : periods; - var rowOrgunits = pivotOrgunit ? [null] : orgunits; - - var table = document.getElementById( "pivotTable" ); - - clearTable( table ); - - var columns = getColumns( columnIndicators, columnPeriods, columnOrgunits ); - var rows = getRows( rowIndicators, rowPeriods, rowOrgunits ); - - var columnDimensions = getColumnDimensions(); - var rowDimensions = getRowDimensions(); - - var colSpans = getSpans( columnDimensions ); - var rowSpans = getSpans( rowDimensions ); - - var html = "