dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37287
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19086: add a limit of 200 users (collected from selected orgUnits) to send messsage, adds new action to ...
------------------------------------------------------------
revno: 19086
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-05-05 10:23:07 +0600
message:
add a limit of 200 users (collected from selected orgUnits) to send messsage, adds new action to oust called 'userCount.action'
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/userCount.vm
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/GetUserCountAction.java
modified:
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/dhis-web-commons.xml
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/sendMessage.vm
--
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
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/userCount.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/userCount.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/userCount.vm 2015-05-05 04:23:07 +0000
@@ -0,0 +1,3 @@
+{
+ "userCount": $userCount
+}
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/GetUserCountAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/GetUserCountAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/GetUserCountAction.java 2015-05-05 04:23:07 +0000
@@ -0,0 +1,74 @@
+package org.hisp.dhis.oust.action;
+
+/*
+ * Copyright (c) 2004-2015, 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.organisationunit.OrganisationUnit;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class GetUserCountAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ @Autowired
+ private SelectionTreeManager selectionTreeManager;
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private int userCount = 0;
+
+ public int getUserCount()
+ {
+ return userCount;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute() throws Exception
+ {
+ for ( OrganisationUnit organisationUnit : selectionTreeManager.getReloadedSelectedOrganisationUnits() )
+ {
+ userCount += organisationUnit.getUsers().size();
+ }
+
+ return SUCCESS;
+ }
+}
=== 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 2015-04-16 08:35:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2015-05-05 04:23:07 +0000
@@ -255,6 +255,8 @@
</property>
</bean>
+ <bean id="org.hisp.dhis.oust.action.GetUserCountAction" class="org.hisp.dhis.oust.action.GetUserCountAction" scope="prototype"></bean>
+
<!-- Security import -->
<import resource="security.xml" />
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2014-11-16 12:45:55 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2015-05-05 04:23:07 +0000
@@ -211,6 +211,13 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <action name="usercount" class="org.hisp.dhis.oust.action.GetUserCountAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ouwt/userCount.vm
+ </result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
</package>
<!-- Organisation Unit Web Tree -->
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2015-03-23 08:15:51 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties 2015-05-05 04:23:07 +0000
@@ -68,6 +68,7 @@
generate_pivot_table_click_share=generate a pivot table and click 'Share' on the top menu
share_interpretation=Share interpretation
select_users_and_user_groups=Select users and user groups
+selected_more_than_200_user=You have {userCount} recipients, please reduce to 200 or less
generate_data_set_report_click_share=generate a data set report and click 'Share' on the top menu
data_visualizer=Data visualizer
data_set_report=Data set report
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js 2015-01-07 13:02:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/message.js 2015-05-05 04:23:07 +0000
@@ -1,6 +1,13 @@
function submitMessage()
{
- $( "#messageForm" ).submit();
+ userCount().done(function(o) {
+ if( o.userCount > 200 ) {
+ i18n_selected_more_than_200_user = i18n_selected_more_than_200_user.replace("{userCount}", o.userCount);
+ setHeaderDelayMessage(i18n_selected_more_than_200_user)
+ } else {
+ $( "#messageForm" ).submit();
+ }
+ });
}
function removeMessage( id )
@@ -18,6 +25,12 @@
window.location.href = "readMessage.action?id=" + id;
}
+function userCount() {
+ return $.ajax({
+ url: '../dhis-web-commons/oust/usercount.action'
+ });
+}
+
function validateMessage()
{
var subject = $( "#subject" ).val();
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/sendMessage.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/sendMessage.vm 2015-04-30 06:14:45 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/sendMessage.vm 2015-05-05 04:23:07 +0000
@@ -3,6 +3,7 @@
var i18n_enter_text = '$encoder.jsEscape( $i18n.getString( "enter_text" ), "'")';
var i18n_select_one_or_more_recipients = '$encoder.jsEscape( $i18n.getString( "select_one_or_more_recipients" ), "'")';
var i18n_select_users_and_user_groups = '$encoder.jsEscape( $i18n.getString( "select_users_and_user_groups" ), "'")';
+var i18n_selected_more_than_200_user = '$encoder.jsEscape( $i18n.getString( "selected_more_than_200_user" ), "'")';
jQuery(function() {
#if( !${recipient} )