=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java 2011-02-22 23:17:50 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/DefaultSelectionTreeManager.java 2011-04-07 12:42:11 +0000 @@ -35,6 +35,8 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.User; import com.opensymphony.xwork2.ActionContext; @@ -60,6 +62,13 @@ { this.organisationUnitService = organisationUnitService; } + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } // ------------------------------------------------------------------------- // SelectionTreeManager implementation @@ -199,6 +208,19 @@ setSelectedOrganisationUnits( set ); } + public boolean setCurrentUserOrganisationUnitAsSelected() + { + User user = currentUserService.getCurrentUser(); + + if ( user != null && user.getOrganisationUnit() != null ) + { + setSelectedOrganisationUnit( user.getOrganisationUnit() ); + return true; + } + + return false; + } + // ------------------------------------------------------------------------- // Session methods // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/SelectionTreeManager.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/SelectionTreeManager.java 2010-08-31 11:40:23 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/manager/SelectionTreeManager.java 2011-04-07 12:42:11 +0000 @@ -148,4 +148,14 @@ * if the argument is null */ void setSelectedOrganisationUnit( OrganisationUnit unit ); + + /** + * Sets the current user's organisation unit as selected. If the user is + * associated with more than one organisation unit, it is undefined which one + * is selected. + * + * @return true if the operation was successful, ie. if a current users exists + * and if the current user is associated with one or more organisation units. + */ + boolean setCurrentUserOrganisationUnitAsSelected(); } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-04-06 11:39:06 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-04-07 12:42:11 +0000 @@ -180,13 +180,11 @@ - - - - + + === modified file 'labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetReportParamsAction.java' --- labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetReportParamsAction.java 2011-04-07 11:55:24 +0000 +++ labs/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetReportParamsAction.java 2011-04-07 12:42:11 +0000 @@ -32,6 +32,7 @@ import java.util.TreeMap; import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.oust.manager.SelectionTreeManager; import org.hisp.dhis.period.MonthlyPeriodType; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; @@ -60,6 +61,13 @@ { this.reportTableService = reportTableService; } + + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } private I18nFormat format; @@ -115,6 +123,8 @@ public String execute() { + selectionTreeManager.setCurrentUserOrganisationUnitAsSelected(); + if ( id != null ) { ReportTable reportTable = reportTableService.getReportTable( id, ReportTableService.MODE_REPORT_TABLE ); === modified file 'labs/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml' --- labs/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2011-04-07 11:55:24 +0000 +++ labs/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml 2011-04-07 12:42:11 +0000 @@ -24,6 +24,7 @@ + \ No newline at end of file === modified file 'labs/dhis-web-light/src/main/webapp/dhis-web-light/inputReportParamsForm.vm' --- labs/dhis-web-light/src/main/webapp/dhis-web-light/inputReportParamsForm.vm 2011-04-07 11:55:24 +0000 +++ labs/dhis-web-light/src/main/webapp/dhis-web-light/inputReportParamsForm.vm 2011-04-07 12:42:11 +0000 @@ -40,8 +40,6 @@
=== modified file 'labs/dhis-web-light/src/main/webapp/dhis-web-light/javascript/dhis-web-light.js' --- labs/dhis-web-light/src/main/webapp/dhis-web-light/javascript/dhis-web-light.js 2011-04-07 11:55:24 +0000 +++ labs/dhis-web-light/src/main/webapp/dhis-web-light/javascript/dhis-web-light.js 2011-04-07 12:42:11 +0000 @@ -8,16 +8,9 @@ window.location.href = "getReportParams.action?id=" + id; } -var paramOrganisationUnit = null; - -function paramOrganisationUnitSet( id ) -{ - paramOrganisationUnit = id; -} - function validationError() { - if ( $( "#selectionTree" ).length && paramOrganisationUnit == null ) + if ( $( "#selectionTree" ).length && selectionTreeSelection.getSelected().length == 0 ) { setMessage( i18n_please_select_unit ); return true; @@ -40,9 +33,9 @@ url += "&reportingPeriod=" + $( "#reportingPeriod" ).val(); } - if ( paramOrganisationUnit != null ) + if ( $( "#selectionTree" ).length ) { - url += "&organisationUnitId=" + paramOrganisationUnit; + url += "&organisationUnitId=" + selectionTreeSelection.getSelected()[0]; } window.location.href = "getReport.action?" + url;