← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3229: WIP: more js / validation in datadictionary

 

------------------------------------------------------------
revno: 3229
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-03-31 13:17:07 +0200
message:
  WIP: more js / validation in datadictionary
added:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataElementGroupForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataElementGroupSet.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateDataElementGroupForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateDataElementGroupSet.js
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.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
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2011-03-29 10:07:14 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2011-03-31 11:17:07 +0000
@@ -157,5 +157,15 @@
 		"name" : {
 			"rangelength" : [ 2, 160 ]
 		}
+	},
+	"dataElementGroup" : {
+		"name" : {
+			"rangelength" : [ 3, 150 ]
+		}
+	},
+	"dataElementGroupSet" : {
+		"name" : {
+			"rangelength" : [ 2, 230 ]
+		}
 	}
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupForm.vm	2011-03-18 14:14:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupForm.vm	2011-03-31 11:17:07 +0000
@@ -1,9 +1,4 @@
-<script type="text/javascript">
-	jQuery(document).ready(	function(){
-		validation( 'addDataElementGroupForm', function( form ){ form.submit()}, beforeSubmit );	
-		checkValueIsExist( "name", "validateDataElementGroup.action");	
-	});
-</script>
+<script type="text/javascript" src="javascript/addDataElementGroupForm.js"></script>
 
 <h3>$i18n.getString( "create_new_data_element_group" )</h3>
 
@@ -15,7 +10,7 @@
 	</tr>
 	<tr>
 		<td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-		<td><input type="text" id="name" name="name" style="width:20em" maxlength="150" class="{validate:{required:true,minlength:3,alphanumericwithbasicpuncspaces:true,notOnlyDigits:true}}"/></td>
+		<td><input type="text" id="name" name="name" style="width:20em"/></td>
 	</tr>
 	<tr>
 		<td colspan="2" height="15px"></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm	2011-03-18 14:14:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementGroupSet.vm	2011-03-31 11:17:07 +0000
@@ -1,9 +1,4 @@
-<script type="text/javascript">
-	jQuery(document).ready(	function(){
-		validation( 'addDataElementGroupSet', function( form ){ form.submit()}, beforeSubmit );	
-		checkValueIsExist( "name", "validateDataElementGroupSet.action");	
-	});
-</script>
+<script type="text/javascript" src="javascript/addDataElementGroupSet.js"></script>
 
 <h3>$i18n.getString( "add_dataelementgroupset" )</h3>
 
@@ -15,7 +10,7 @@
 	</tr>
 	<tr>
 		<td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-		<td><input type="text" id="name" name="name" style="width:20em" maxlength="230" class="{validate:{required:true,minlength:2}}"/></td>
+		<td><input type="text" id="name" name="name" style="width:20em"/></td>
 	</tr>
 	<tr>
 		<td colspan="2" height="15px"></td>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataElementGroupForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataElementGroupForm.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataElementGroupForm.js	2011-03-31 11:17:07 +0000
@@ -0,0 +1,24 @@
+jQuery(document).ready(function() {
+	var r = getValidationRules();
+
+	var rules = {
+		name : {
+			required : true,
+			rangelength : r.dataElementGroup.name.rangelength,
+			alphanumericwithbasicpuncspaces : true,
+			notOnlyDigits : true,
+			firstletteralphabet : true
+		}
+	};
+
+	validation2('addDataElementGroupForm', function(form) {
+		form.submit()
+	}, {
+		'beforeValidateHandler' : beforeSubmit,
+		'rules' : rules
+	});
+
+	jQuery("#name").attr("maxlength", r.dataElementGroup.name.rangelength[1]);
+
+	checkValueIsExist("name", "validateDataElementGroup.action");
+});

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataElementGroupSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataElementGroupSet.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/addDataElementGroupSet.js	2011-03-31 11:17:07 +0000
@@ -0,0 +1,21 @@
+jQuery(document).ready(function() {
+	var r = getValidationRules();
+
+	var rules = {
+		name : {
+			required : true,
+			rangelength : r.dataElementGroupSet.name.rangelength
+		}
+	};
+
+	validation2('addDataElementGroupSet', function(form) {
+		form.submit()
+	}, {
+		'beforeValidateHandler' : beforeSubmit,
+		'rules' : rules
+	});
+
+	jQuery("#name").attr("maxlength", r.dataElementGroupSet.name.rangelength[1]);
+
+	checkValueIsExist("name", "validateDataElementGroupSet.action");
+});

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateDataElementGroupForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateDataElementGroupForm.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateDataElementGroupForm.js	2011-03-31 11:17:07 +0000
@@ -0,0 +1,26 @@
+jQuery(document).ready(function() {
+	var r = getValidationRules();
+
+	var rules = {
+		name : {
+			required : true,
+			rangelength : r.dataElementGroup.name.rangelength,
+			alphanumericwithbasicpuncspaces : true,
+			notOnlyDigits : true,
+			firstletteralphabet : true
+		}
+	};
+
+	validation2('updateDataElementGroupForm', function(form) {
+		form.submit()
+	}, {
+		'beforeValidateHandler' : beforeSubmit,
+		'rules' : rules
+	});
+
+	jQuery("#name").attr("maxlength", r.dataElementGroup.name.rangelength[1]);
+
+	checkValueIsExist("name", "validateDataElementGroup.action", {
+		id : getFieldValue('id')
+	});
+});

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateDataElementGroupSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateDataElementGroupSet.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/updateDataElementGroupSet.js	2011-03-31 11:17:07 +0000
@@ -0,0 +1,27 @@
+jQuery(document).ready(function() {
+	var r = getValidationRules();
+
+	var rules = {
+		name : {
+			required : true,
+			rangelength : r.dataElementGroupSet.name.rangelength
+		}
+	};
+
+	validation2('updateDataElementGroupSet', function(form) {
+		form.submit()
+	}, {
+		'beforeValidateHandler' : beforeSubmit,
+		'rules' : rules
+	});
+
+	jQuery("#name").attr("maxlength", r.dataElementGroupSet.name.rangelength[1]);
+
+	checkValueIsExist("name", "validateDataElementGroupSet.action", {
+		id : getFieldValue('id')
+	});
+
+	var nameField = document.getElementById('name');
+	nameField.select();
+	nameField.focus();
+});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupForm.vm	2011-03-18 14:14:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupForm.vm	2011-03-31 11:17:07 +0000
@@ -1,9 +1,4 @@
-<script type="text/javascript">
-	jQuery(document).ready(	function(){
-		validation( 'updateDataElementGroupForm', function( form ){ form.submit()}, beforeSubmit );	
-		checkValueIsExist( "name", "validateDataElementGroup.action", {id: getFieldValue( 'id' )});		
-	});
-</script>
+<script type="text/javascript" src="javascript/updateDataElementGroupForm.js"></script>
 
 <h3>$i18n.getString( "edit_data_element_group" )</h3>
 
@@ -19,7 +14,7 @@
 	</tr>
 	<tr>
 		<td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-		<td><input type="text" id="name" name="name" value="$encoder.htmlEncode( $dataElementGroup.name )" style="width:20em" class="{validate:{required:true,rangelength:[3,150],alphanumericwithbasicpuncspaces:true,firstletteralphabet:true}}"/>	
+		<td><input type="text" id="name" name="name" value="$encoder.htmlEncode( $dataElementGroup.name )" style="width:20em"/>	
 		</td>
 	</tr>
 	<tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm	2011-03-18 14:14:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementGroupSet.vm	2011-03-31 11:17:07 +0000
@@ -1,13 +1,4 @@
-<script type="text/javascript">
-	jQuery(document).ready(	function(){
-		validation( 'updateDataElementGroupSet', function( form ){ form.submit()}, beforeSubmit );	
-		checkValueIsExist( "name", "validateDataElementGroupSet.action", {id: getFieldValue('id')});	
-
-		var nameField = document.getElementById( 'name' );
-		nameField.select();
-		nameField.focus();
-	});
-</script>
+<script type="text/javascript" src="javascript/updateDataElementGroupSet.js"></script>
 
 <h3>$i18n.getString( "update_dataelementgroupset" ) : $dataElementGroupSet.name</h3>
 
@@ -19,7 +10,7 @@
 	</tr>
 	<tr>
 		<td><label for="name">$i18n.getString( "name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-		<td><input type="text" id="name" name="name" style="width:20em" value="$encoder.htmlEncode( $dataElementGroupSet.name )" maxlength="230" class="{validate:{required:true,minlength:2}}"/></td>
+		<td><input type="text" id="name" name="name" style="width:20em" value="$encoder.htmlEncode( $dataElementGroupSet.name )"/></td>
 	</tr>
 	<tr>
 		<td colspan="2" height="15px"></td>