← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1953: added validation in User Group Management

 

------------------------------------------------------------
revno: 1953
committer: dev ratan <dev-hisp@xxxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-10-25 18:25:15 +0530
message:
  added validation in User Group Management 
added:
  dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/user/action/ValidateUserGroupAction.java
  dhis-mobile/dhis-web-mobile/src/main/resources/org/
  dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/
  dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/dhis/
  dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/dhis/mobile/
  dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties
modified:
  dhis-mobile/dhis-web-mobile/src/main/resources/struts.xml
  dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/addUserGroupForm.vm
  dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/editUserGroupForm.vm
  dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/javascript/user.js
  dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/responseUserGroup.vm
  dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/userGroupList.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-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/user/action/ValidateUserGroupAction.java'
--- dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/user/action/ValidateUserGroupAction.java	1970-01-01 00:00:00 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/java/org/hisp/dhis/mobile/user/action/ValidateUserGroupAction.java	2010-10-25 12:55:15 +0000
@@ -0,0 +1,48 @@
+package org.hisp.dhis.mobile.user.action;
+
+import java.util.ArrayList;
+
+import org.hisp.dhis.user.UserGroup;
+import org.hisp.dhis.user.UserGroupService;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+public class ValidateUserGroupAction
+    extends ActionSupport
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private UserGroupService userGroupService;
+
+    public void setUserGroupService( UserGroupService userGroupService )
+    {
+        this.userGroupService = userGroupService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Parameters
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    private String name;
+
+    // -------------------------------------------------------------------------
+    // Action Implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        UserGroup group = userGroupService.getUserGroupByName( name );
+        
+        if( (id==null && group!= null ) || ( id!= null && id!= group.getId())){
+            
+            return INPUT;
+        }
+        return SUCCESS;
+    }
+
+}

=== added directory 'dhis-mobile/dhis-web-mobile/src/main/resources/org'
=== added directory 'dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp'
=== added directory 'dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/dhis'
=== added directory 'dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/dhis/mobile'
=== added file 'dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties'
--- dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	1970-01-01 00:00:00 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2010-10-25 12:55:15 +0000
@@ -0,0 +1,9 @@
+usergroup_management = User Group Management 
+filter_by_name   =  Filter By Name
+edit_usergroup  = Edit UserGroup 
+usergroup_details = UserGroup Details
+confirm_delete = Confirm Delete 
+add_usergroup = Add UserGroup 
+available_users = Available USers
+group_members  = Group Members
+no_of_Users    = No Of Users
\ No newline at end of file

=== modified file 'dhis-mobile/dhis-web-mobile/src/main/resources/struts.xml'
--- dhis-mobile/dhis-web-mobile/src/main/resources/struts.xml	2010-10-25 05:35:48 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/resources/struts.xml	2010-10-25 12:55:15 +0000
@@ -73,11 +73,13 @@
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">/dhis-web-mobile/addUserGroupForm.vm</param>
 			<param name="menu">/dhis-web-mobile/menu.vm</param>
+			<param name="javascripts">javascript/user.js</param>
 			<param name="stylesheets">css/receiveImportPage.css</param>
 		</action>
 		
 		<action name="addUserGroup"
 			class="org.hisp.dhis.mobile.user.action.AddUserGroupAction">
+			<param name="javascripts">javascript/user.js</param>
 			<result name="success" type="redirect">
 				getAllUserGroups.action</result>
 		</action>

=== modified file 'dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/addUserGroupForm.vm'
--- dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/addUserGroupForm.vm	2010-10-21 06:32:42 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/addUserGroupForm.vm	2010-10-25 12:55:15 +0000
@@ -1,6 +1,6 @@
 <h3>$i18n.getString( "add_usergroup" )</h3>
 
-<form id="addUserGroupForm" name="addUserGroupForm" action="addUserGroup.action" method="post" >
+<form id="addUserGroupForm" name="addUserGroupForm" action = " addUserGroup.action"  method="post" onSubmit=" return addValidation()" >
   <table id="detailsList">
     <col/> ## Labels
     <col/> ## Input
@@ -61,4 +61,31 @@
 
 <p><input type="submit" value="$i18n.getString( 'add' )" style="width:10em"/><input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='getAllUserGroups.action'" style="width:10em"/></p>
 
-</form>
\ No newline at end of file
+</form>
+
+<script type="text/javascript">
+	
+	
+
+	
+	
+    var i18n_select_dataelement_group = '$encoder.jsEscape( $i18n.getString( "select_User_group" ) , "'")';
+    var i18n_confirm_delete = '$encoder.jsEscape( $i18n.getString( "confirm_delete_data_element_group" ) , "'")';
+    var i18n_member_of = '$encoder.jsEscape( $i18n.getString( "member_of" ) , "'")';
+    var i18n_update_success = '$encoder.jsEscape( $i18n.getString( "update_success" ) , "'")';
+
+    var dataElementGroups = new Object();
+    #foreach( $dataElementGroup in $dataElementGroups )
+        dataElementGroups['$dataElementGroup.id'] = '$encoder.jsEscape( $dataElementGroup.name, "'" )';
+    #end
+
+    var availableDataElements = new Object();
+    #foreach( $dataElement in $dataElements )
+        availableDataElements['$dataElement.id'] = '$encoder.jsEscape( $dataElement.name, "'" )';
+    #end
+    var selectedDataElements = new Object();
+
+    initAllList();
+</script>
+
+

=== modified file 'dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/editUserGroupForm.vm'
--- dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/editUserGroupForm.vm	2010-10-25 05:35:48 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/editUserGroupForm.vm	2010-10-25 12:55:15 +0000
@@ -1,6 +1,8 @@
+
 <h3>$i18n.getString( "edit_usergroup" )</h3>
 
-<form id="addUserGroupForm" name="addUserGroupForm" action="updateUserGroup.action" method="post" >
+<form id="editUserGroupForm" name="editUserGroupForm" action="updateUserGroup.action" method="post" onsubmit="return editValidation();" >
+	
   <input type="hidden" name="userGroupId" id="userGroupId" value="$userGroupId" />
   <table id="detailsList">
     <col/> ## Labels
@@ -13,8 +15,7 @@
     <tbody>
       <tr>
         <td><label>$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td><input type="text" id="name" name="name" value ="$encoder.htmlEncode( $group.name )" onchange="nameChanged()" style="width:20em" maxlength="150" 
-            class="{validate:{required:true,minlength:4,alphanumericwithbasicpuncspaces:true,firstletteralphabet:false}}"/>
+        <td><input type="text" id="name" name="name" value ="$encoder.htmlEncode( $group.name )" onchange="nameChanged()" style="width:20em" maxlength="150" />
         </td>
       </tr>
       <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
@@ -25,7 +26,7 @@
     <tr>
         <th>$i18n.getString( "available_users" )</th><td></td>
         <th>$i18n.getString( "group_members" )
-            <select id="memberValidator" multiple="multiple" style="display:none" class="{validate:{required:true}}"/>
+            <select id="memberValidator" multiple="multiple" style="display:none"/>
         </th>
     </tr>
     <tr>        
@@ -66,4 +67,36 @@
 
 <p><input type="submit" value="$i18n.getString( 'save' )" style="width:10em"/><input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='getAllUserGroups.action'" style="width:10em"/></p>
 
-</form>
\ No newline at end of file
+</form>
+<script type="text/javascript">
+   function editValidation ()
+{
+    var k =0 ;
+    var xyz=document.getElementById("name");
+    var abc =document.getElementById("groupMembers");
+    var c  = abc.length ;
+	
+    if( xyz.value == "") {
+    	alert ("please select name ");alert(' xyz.value is empty');
+		return false;
+    }
+    else if ( c <=0 ){
+		alert("please select at least one member");
+		return false ;
+    }else{
+    	if (c >0 )
+		{
+			/* for( k =0;k<=c;k++)
+			{alert('k : ' + k);
+			alert('abc.options[k] : ' + abc.options[k]);
+				abc.options[k].selected = true ;    
+			}*/
+			
+			selectAllById("groupMembers");
+		}
+	}
+   
+    return true;
+}
+
+</script>

=== modified file 'dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/javascript/user.js'
--- dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/javascript/user.js	2010-10-25 05:35:48 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/javascript/user.js	2010-10-25 12:55:15 +0000
@@ -18,7 +18,40 @@
 {
     setInnerHTML( 'nameField', getElementValue( userGroupElement, 'name' ) );
     setInnerHTML( 'idField', getElementValue( userGroupElement, 'id' ) );
-    setInnerHTML( 'noOfGroupField', getElementValue( userGroupElement, 'noOfGroup' ) );
+    setInnerHTML( 'noOfGroupField', getElementValue( userGroupElement, 'noOfUsers' ) );
 
     showDetails();
-}
\ No newline at end of file
+}
+
+function addValidation ()
+{
+    var k =0 ;
+	var xyz=document.getElementById("name");
+	var abc =document.getElementById("groupMembers");
+	var c  = abc.length ;
+	if( xyz.value == "") {
+    alert ("please select name ");
+    return false;
+    }
+	else if ( c <=0 ){
+    alert("please select at least one member");
+    return false ;
+    }else
+	if (c >0 )
+	{
+		for( k =0;k<=c;k++)
+		{
+		abc.options[k].selected = true ;	
+			
+		}
+	}
+	
+	return true;
+}
+
+function editValidation ()
+{
+alert("dev");
+}
+
+

=== modified file 'dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/responseUserGroup.vm'
--- dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/responseUserGroup.vm	2010-10-25 05:35:48 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/responseUserGroup.vm	2010-10-25 12:55:15 +0000
@@ -2,5 +2,5 @@
 <userGroup>
   <name>$group.name</name>
   <id>$group.id</id>
-  <noOfGroup>$memberCount</noOfGroup>
+  <noOfUsers>$memberCount</noOfUsers>
 </userGroup>
\ No newline at end of file

=== modified file 'dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/userGroupList.vm'
--- dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/userGroupList.vm	2010-10-25 05:35:48 +0000
+++ dhis-mobile/dhis-web-mobile/src/main/webapp/dhis-web-mobile/userGroupList.vm	2010-10-25 12:55:15 +0000
@@ -48,7 +48,7 @@
                 </div>
                 <p><label>$i18n.getString( "name" ):</label><br/><span id="nameField"></span></p>
                 <p><label>$i18n.getString( "id" ):</label><br/><span id="idField"></span></p>
-                <p><label>$i18n.getString( "no_of_group" ):</label><br/><span id="noOfGroupField"></span></p>
+                <p><label>$i18n.getString( "no_of_Users" ):</label><br/><span id="noOfGroupField"></span></p>
             </div>
             
             <div id="warningArea" style="position:fixed;right:10px;top:200px;display:none">