dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21534
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10207: remove need for validateReport/TableAction, validate using js
------------------------------------------------------------
revno: 10207
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-14 17:27:27 +0700
message:
remove need for validateReport/TableAction, validate using js
removed:
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/ValidateReportAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ValidateTableAction.java
modified:
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.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
=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/ValidateReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/ValidateReportAction.java 2013-02-12 06:55:14 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/ValidateReportAction.java 1970-01-01 00:00:00 +0000
@@ -1,127 +0,0 @@
-package org.hisp.dhis.reporting.reportviewer.action;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.report.Report;
-import org.hisp.dhis.report.ReportService;
-
-/**
- * @author Lars Helge Overland
- */
-public class ValidateReportAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- public ReportService reportService;
-
- public void setReportService( ReportService reportService )
- {
- this.reportService = reportService;
- }
-
- private I18n i18n;
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private Integer id;
-
- public void setId( Integer id )
- {
- this.id = id;
- }
-
- private String name;
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private String message;
-
- public String getMessage()
- {
- return message;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- {
- if ( name == null )
- {
- message = i18n.getString( "specify_name" );
-
- return INPUT;
- }
- else
- {
- name = name.trim();
-
- if ( name.length() == 0 )
- {
- message = i18n.getString( "specify_name" );
-
- return INPUT;
- }
-
- /*
- Report match = reportService.getReportByName( name ).get( 0 );
-
- if ( match != null && (id == null || match.getId() != id) )
- {
- message = i18n.getString( "name_in_use" );
-
- return INPUT;
- }
- */
- }
-
- message = i18n.getString( "ok" );
-
- return SUCCESS;
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ValidateTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ValidateTableAction.java 2013-02-08 07:18:39 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/ValidateTableAction.java 1970-01-01 00:00:00 +0000
@@ -1,128 +0,0 @@
-package org.hisp.dhis.reporting.tablecreator.action;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.i18n.I18n;
-import org.hisp.dhis.reporttable.ReportTable;
-import org.hisp.dhis.reporttable.ReportTableService;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class ValidateTableAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private ReportTableService reportTableService;
-
- public void setReportTableService( ReportTableService reportTableService )
- {
- this.reportTableService = reportTableService;
- }
-
- private I18n i18n;
-
- public void setI18n( I18n i18n )
- {
- this.i18n = i18n;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private Integer id;
-
- public void setId( Integer id )
- {
- this.id = id;
- }
-
- private String name;
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private String message;
-
- public String getMessage()
- {
- return message;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- {
- if ( name == null )
- {
- message = i18n.getString( "specify_name" );
-
- return INPUT;
- }
- else
- {
- name = name.trim();
-
- if ( name.length() == 0 )
- {
- message = i18n.getString( "specify_name" );
-
- return INPUT;
- }
-
- /*
- ReportTable match = reportTableService.getReportTableByName( name ).get( 0 );
-
- if ( match != null && (id == null || match.getId() != id) )
- {
- message = i18n.getString( "name_in_use" );
-
- return INPUT;
- }
- */
- }
-
- message = i18n.getString( "ok" );
-
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-03-05 19:00:51 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-03-14 10:27:27 +0000
@@ -103,11 +103,6 @@
<property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
</bean>
- <bean id="org.hisp.dhis.reporting.tablecreator.action.ValidateTableAction" class="org.hisp.dhis.reporting.tablecreator.action.ValidateTableAction"
- scope="prototype">
- <property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService" />
- </bean>
-
<bean id="org.hisp.dhis.reporting.tablecreator.action.AddReportTableToDashboardAction" class="org.hisp.dhis.reporting.tablecreator.action.AddReportTableToDashboardAction"
scope="prototype">
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
@@ -169,11 +164,6 @@
<property name="reportService" ref="org.hisp.dhis.report.ReportService" />
</bean>
- <bean id="org.hisp.dhis.reporting.reportviewer.action.ValidateReportAction" class="org.hisp.dhis.reporting.reportviewer.action.ValidateReportAction"
- scope="prototype">
- <property name="reportService" ref="org.hisp.dhis.report.ReportService" />
- </bean>
-
<bean id="org.hisp.dhis.reporting.reportviewer.action.GetReportAndParamsAction" class="org.hisp.dhis.reporting.reportviewer.action.GetReportAndParamsAction"
scope="prototype">
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2013-03-14 04:50:21 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2013-03-14 10:27:27 +0000
@@ -113,12 +113,6 @@
<result name="success" type="outputStreamResult" />
</action>
- <action name="validateReport" class="org.hisp.dhis.reporting.reportviewer.action.ValidateReportAction">
- <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
- <result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm</result>
- <param name="onExceptionReturn">plainTextError</param>
- </action>
-
<action name="getReportTemplate" class="org.hisp.dhis.reporting.reportviewer.action.GetReportTemplateAction">
<result name="success" type="outputStreamResult" />
</action>
@@ -151,6 +145,7 @@
<action name="saveTable" class="org.hisp.dhis.reporting.tablecreator.action.SaveTableAction">
<result name="success" type="redirect">displayManageTableForm.action</result>
+ <param name="anyAuthorities">F_REPORTTABLE_PUBLIC_ADD,F_REPORTTABLE_PRIVATE_ADD</param>
</action>
<action name="getReportParams" class="org.hisp.dhis.reporting.tablecreator.action.GetReportParamsAction">
@@ -165,6 +160,7 @@
<param name="page">/dhis-web-reporting/addTableForm.vm</param>
<param name="menu">/dhis-web-reporting/menu.vm</param>
<param name="javascripts">../dhis-web-commons/oust/oust.js,javascript/table.js,javascript/lists.js</param>
+ <param name="anyAuthorities">F_REPORTTABLE_PUBLIC_ADD,F_REPORTTABLE_PRIVATE_ADD</param>
</action>
<action name="getTable" class="org.hisp.dhis.reporting.tablecreator.action.GetTableAction">
@@ -172,12 +168,6 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
- <action name="validateTable" class="org.hisp.dhis.reporting.tablecreator.action.ValidateTableAction">
- <result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
- <result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm</result>
- <param name="onExceptionReturn">plainTextError</param>
- </action>
-
<action name="addReportTableToDashboard" class="org.hisp.dhis.reporting.tablecreator.action.AddReportTableToDashboardAction">
<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
<param name="onExceptionReturn">plainTextError</param>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2013-01-25 15:24:37 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addReportForm.vm 2013-03-14 10:27:27 +0000
@@ -1,5 +1,7 @@
<script type="text/javascript">
var i18n_please_specify_file = '$encoder.jsEscape( $i18n.getString( "please_specify_file" ) , "'")';
+ var i18n_specify_name = '$encoder.jsEscape( $i18n.getString( "specify_name" ) , "'")';
+
jQuery( document ).ready( function() {
setReportType();
} );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm 2012-11-07 13:38:42 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/addTableForm.vm 2013-03-14 10:27:27 +0000
@@ -14,6 +14,7 @@
var i18n_must_select_at_least_one_unit = '$encoder.jsEscape( $i18n.getString( "must_select_at_least_one_unit" ), "'")';
var i18n_must_select_at_least_one_period = '$encoder.jsEscape( $i18n.getString( "must_select_at_least_one_period" ), "'")';
var i18n_cannot_select_orgunit_and_parent_orgunit_param = '$encoder.jsEscape( $i18n.getString( "cannot_select_orgunit_and_parent_orgunit_param" ), "'")';
+ var i18n_specify_name = '$encoder.jsEscape( $i18n.getString( "specify_name" ) , "'")';
</script>
<h3>$i18n.getString( "create_report_table" )</h3>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js 2013-01-25 15:24:37 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js 2013-03-14 10:27:27 +0000
@@ -1,23 +1,18 @@
function addReport()
{
- if ( $( "#id" ).val().length == 0 && !hasText( "upload" ) )
- {
- setMessage( i18n_please_specify_file );
- return false;
- }
-
- $.postJSON( "validateReport.action", { id:$( "#id" ).val(), "name":$( "#name" ).val() }, function( json )
- {
- if ( json.response == "input" )
- {
- setMessage( json.message );
- return false;
- }
- else if ( json.response == "success" )
- {
- $( "#reportForm" ).submit();
- }
- } );
+ if ( $( "#reportForm #name" ).val().trim().length == 0 )
+ {
+ setMessage( i18n_specify_name );
+ return false;
+ }
+
+ if ( $( "#reportForm #id" ).val().trim().length == 0 && !hasText( "upload" ) )
+ {
+ setMessage( i18n_please_specify_file );
+ return false;
+ }
+
+ $( "#reportForm" ).submit();
}
function removeReport( id )
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js 2013-02-08 07:18:39 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/table.js 2013-03-14 10:27:27 +0000
@@ -4,21 +4,16 @@
function saveTable()
{
+ if ( $( "#tableForm #tableName" ).val().trim().length == 0 )
+ {
+ setHeaderDelayMessage( i18n_specify_name );
+ return false;
+ }
+
if ( validateCollections() )
{
- $.postJSON( "validateTable.action", { id:getFieldValue( "tableId" ), "name":getFieldValue( "tableName" ) }, function( json )
- {
- if ( json.response == "input" )
- {
- setHeaderDelayMessage( json.message );
- return false;
- }
- else if ( json.response == "success" )
- {
- selectTableForm();
- $( "#tableForm" ).submit();
- }
- } );
+ selectTableForm();
+ $( "#tableForm" ).submit();
}
}