← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3339: WIP: validation rules

 

------------------------------------------------------------
revno: 3339
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-04-11 13:36:18 +0200
message:
  WIP: validation rules
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-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitGroupForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitGroupSetForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitGroupForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitGroupSetForm.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
=== 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-04-11 11:16:51 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2011-04-11 11:36:18 +0000
@@ -66,15 +66,22 @@
 	/* dhis-web-maintenance-organisationunit */
 	"organisationUnit" : {
 		"name" : {
+			"required" : true,
 			"rangelength" : [ 2, 160 ]
 		},
 		"shortName" : {
+			"required" : true,
 			"rangelength" : [ 2, 25 ]
 		},
 		"code" : {
+			"required" : true,
 			"rangelength" : [ 0, 25 ]
 		},
+		"openingDate" : {
+			"required" : true
+		},
 		"url" : {
+			"url" : true,
 			"rangelength" : [ 0, 255 ]
 		},
 		"contactPerson" : {
@@ -84,6 +91,7 @@
 			"rangelength" : [ 0, 255 ]
 		},
 		"email" : {
+			"email" : true,
 			"rangelength" : [ 0, 250 ]
 		},
 		"phoneNumber" : {
@@ -92,14 +100,17 @@
 	},
 	"organisationUnitGroup" : {
 		"name" : {
+			"required" : true,
 			"rangelength" : [ 2, 160 ]
 		}
 	},
 	"organisationUnitGroupSet" : {
 		"name" : {
+			"required" : true,
 			"rangelength" : [ 2, 230 ]
 		},
 		"description" : {
+			"required" : true,
 			"rangelength" : [ 2, 255 ]
 		}
 	},

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitForm.js	2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitForm.js	2011-04-11 11:36:18 +0000
@@ -1,74 +1,21 @@
-jQuery( document ).ready( function()
-{
-	var r = getValidationRules();
-
-	var rules = {
-		name : {
-			required : true,
-			rangelength : r.organisationUnit.name.rangelength
-		},
-		shortName : {
-			required : true,
-			rangelength : r.organisationUnit.shortName.rangelength
-		},
-		code : {
-			required : true,
-			rangelength : r.organisationUnit.code.rangelength
-		},
-		openingDate : {
-			required : true
-		},
-		comment : {
-
-		},
-		coordinates : {
-
-		},
-		featureType : {
-
-		},
-		url : {
-			url : true,
-			rangelength : r.organisationUnit.url.rangelength
-		},
-		contactPerson : {
-			rangelength : r.organisationUnit.contactPerson.rangelength
-		},
-		address : {
-			rangelength : r.organisationUnit.address.rangelength
-		},
-		email : {
-			email : true,
-			rangelength : r.organisationUnit.email.rangelength
-		},
-		phoneNumber : {
-			rangelength : r.organisationUnit.phoneNumber.rangelength
-		}
-	};
-
-	validation2( 'addOrganisationUnitForm', function(form) {
+jQuery(document).ready(function() {
+	validation2('addOrganisationUnitForm', function(form) {
 		selectAllById("dataSets");
 		form.submit();
 
-		/* if(validateFeatureType(this.coordinates, this.featureType)) { form.submit(); } */
-		/*  return false; */
+		/*
+		 * if(validateFeatureType(this.coordinates, this.featureType)) {
+		 * form.submit(); }
+		 */
+		/* return false; */
 	}, {
-		'rules' : rules
-	} );
-
-	jQuery( "#name" ).attr( "maxlength", r.organisationUnit.name.rangelength[1] );
-	jQuery( "#shortName" ).attr( "maxlength", r.organisationUnit.shortName.rangelength[1] );
-	jQuery( "#code" ).attr( "maxlength", r.organisationUnit.code.rangelength[1] );
-	jQuery( "#url" ).attr( "maxlength", r.organisationUnit.url.rangelength[1] );
-	jQuery( "#contactPerson" ).attr( "maxlength", r.organisationUnit.contactPerson.rangelength[1] );
-	jQuery( "#address" ).attr( "maxlength", r.organisationUnit.address.rangelength[1] );
-	jQuery( "#email" ).attr( "maxlength", r.organisationUnit.email.rangelength[1] );
-	jQuery( "#phoneNumber" ).attr( "maxlength", r.organisationUnit.phoneNumber.rangelength[1] );
-
-	checkValueIsExist( "name", "validateOrganisationUnit.action" );
-	datePickerValid( 'openingDate', false );
-
-	var nameField = document.getElementById( 'name' );
+		'rules' : getValidationRules("organisationUnit")
+	});
+
+	checkValueIsExist("name", "validateOrganisationUnit.action");
+	datePickerValid('openingDate', false);
+
+	var nameField = document.getElementById('name');
 	nameField.select();
 	nameField.focus();
-} );
+});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitGroupForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitGroupForm.js	2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitGroupForm.js	2011-04-11 11:36:18 +0000
@@ -1,22 +1,9 @@
-jQuery( document ).ready( function()
-{
-	var r = getValidationRules();
-
-	var rules = {
-		name : {
-			required : true,
-			rangelength : r.organisationUnitGroup.name.rangelength
-		}
-	};
-
-	validation2( 'addOrganisationUnitGroupForm', function( form )
-	{
+jQuery(document).ready(function() {
+	validation2('addOrganisationUnitGroupForm', function(form) {
 		form.submit()
 	}, {
-		'rules' : rules
-	} );
-
-	jQuery( "#name" ).attr( "maxlength", r.organisationUnitGroup.name.rangelength[1] );
-
-	checkValueIsExist( "name", "validateOrganisationUnitGroup.action" );
-} );
+		'rules' : getValidationRules("organisationUnitGroup")
+	});
+
+	checkValueIsExist("name", "validateOrganisationUnitGroup.action");
+});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitGroupSetForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitGroupSetForm.js	2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/addOrganisationUnitGroupSetForm.js	2011-04-11 11:36:18 +0000
@@ -1,33 +1,14 @@
-jQuery( document ).ready( function()
-{
-	var r = getValidationRules();
-
-	var rules = {
-		name : {
-			required : true,
-			rangelength : r.organisationUnitGroupSet.name.rangelength
-		},
-		description : {
-			required : true,
-			rangelength : r.organisationUnitGroupSet.description.rangelength
-		}
-	};
-
-	validation2( 'addOrganisationUnitGroupSetForm', function( form )
-	{
-		validateAddOrganisationGroupSet( form )
+jQuery(document).ready(function() {
+	validation2('addOrganisationUnitGroupSetForm', function(form) {
+		validateAddOrganisationGroupSet(form)
 	}, {
-		'beforeValidateHandler' : function()
-		{
-			selectAllById( 'selectedGroups' );
+		'beforeValidateHandler' : function() {
+			selectAllById('selectedGroups');
 		},
-		'rules' : rules
-	} );
-
-	jQuery( "#name" ).attr( "maxlength", r.organisationUnitGroupSet.name.rangelength[1] );
-	jQuery( "#description" ).attr( "maxlength", r.organisationUnitGroupSet.description.rangelength[1] );
-
-	checkValueIsExist( "name", "validateOrganisationUnitGroupSet.action" );
-
-	changeCompulsory( getFieldValue( 'compulsory' ) );
-} );
+		'rules' : getValidationRules("organisationUnitGroupSet")
+	});
+
+	checkValueIsExist("name", "validateOrganisationUnitGroupSet.action");
+
+	changeCompulsory(getFieldValue('compulsory'));
+});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitForm.js	2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitForm.js	2011-04-11 11:36:18 +0000
@@ -1,66 +1,13 @@
-jQuery( document ).ready( function()
-{
-	var r = getValidationRules();
-
-	var rules = {
-		name : {
-			required : true,
-			rangelength : r.organisationUnit.name.rangelength
-		},
-		shortName : {
-			required : true,
-			rangelength : r.organisationUnit.shortName.rangelength
-		},
-		code : {
-			required : true,
-			rangelength : r.organisationUnit.code.rangelength
-		},
-		openingDate : {
-			required : true
-		},
-		comment : {
-
-		},
-		coordinates : {
-
-		},
-		featureType : {
-
-		},
-		url : {
-			url : true,
-			rangelength : r.organisationUnit.url.rangelength
-		},
-		contactPerson : {
-			rangelength : r.organisationUnit.contactPerson.rangelength
-		},
-		address : {
-			rangelength : r.organisationUnit.address.rangelength
-		},
-		email : {
-			email : true,
-			rangelength : r.organisationUnit.email.rangelength
-		},
-		phoneNumber : {
-			rangelength : r.organisationUnit.phoneNumber.rangelength
-		}
-	};
-
-	validation2( 'updateOrganisationUnitForm', function(form) {
+jQuery(document).ready(function() {
+	validation2('updateOrganisationUnitForm', function(form) {
 		selectAllById("dataSets");
 		form.submit();
 
-		/* if(validateFeatureType(this.coordinates, this.featureType)) {form.submit();} */
+		/*
+		 * if(validateFeatureType(this.coordinates, this.featureType))
+		 * {form.submit();}
+		 */
 	}, {
-		'rules' : rules
-	} );
-
-	jQuery( "#name" ).attr( "maxlength", r.organisationUnit.name.rangelength[1] );
-	jQuery( "#shortName" ).attr( "maxlength", r.organisationUnit.shortName.rangelength[1] );
-	jQuery( "#code" ).attr( "maxlength", r.organisationUnit.code.rangelength[1] );
-	jQuery( "#url" ).attr( "maxlength", r.organisationUnit.url.rangelength[1] );
-	jQuery( "#contactPerson" ).attr( "maxlength", r.organisationUnit.contactPerson.rangelength[1] );
-	jQuery( "#address" ).attr( "maxlength", r.organisationUnit.address.rangelength[1] );
-	jQuery( "#email" ).attr( "maxlength", r.organisationUnit.email.rangelength[1] );
-	jQuery( "#phoneNumber" ).attr( "maxlength", r.organisationUnit.phoneNumber.rangelength[1] );
-} );
+		'rules' : getValidationRules("organisationUnit")
+	});
+});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitGroupForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitGroupForm.js	2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitGroupForm.js	2011-04-11 11:36:18 +0000
@@ -1,17 +1,7 @@
-jQuery(document).ready(	function(){
-	var r = getValidationRules();
-	
-	var rules = {
-		name: {
-			required:true,
-			rangelength : r.organisationUnitGroup.name.rangelength
-		}
-	};
-
-	validation2( 'updateOrganisationUnitGroupForm', function( form ) { form.submit() },
-	{
-		'rules': rules
-	});	
-
-	jQuery( "#name" ).attr( "maxlength", r.organisationUnitGroup.name.rangelength[1] );
-});	
+jQuery(document).ready(function() {
+	validation2('updateOrganisationUnitGroupForm', function(form) {
+		form.submit()
+	}, {
+		'rules' : getValidationRules("organisationUnitGroup")
+	});
+});

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitGroupSetForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitGroupSetForm.js	2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/updateOrganisationUnitGroupSetForm.js	2011-04-11 11:36:18 +0000
@@ -1,35 +1,16 @@
-jQuery( document ).ready( function()
-{
-	var r = getValidationRules();
-
-	var rules = {
-		name : {
-			required : true,
-			rangelength : r.organisationUnitGroupSet.name.rangelength
-		},
-		description : {
-			required : true,
-			rangelength : r.organisationUnitGroupSet.description.rangelength
-		}
-	};
-
-	validation2( 'updateOrganisationUnitGroupSetForm', function( form )
-	{
-		validateAddOrganisationGroupSet( form )
+jQuery(document).ready(function() {
+	validation2('updateOrganisationUnitGroupSetForm', function(form) {
+		validateAddOrganisationGroupSet(form)
 	}, {
-		'beforeValidateHandler' : function()
-		{
-			selectAllById( 'selectedGroups' );
+		'beforeValidateHandler' : function() {
+			selectAllById('selectedGroups');
 		},
-		'rules' : rules
-	} );
-
-	jQuery( "#name" ).attr( "maxlength", r.organisationUnitGroupSet.name.rangelength[1] );
-	jQuery( "#description" ).attr( "maxlength", r.organisationUnitGroupSet.description.rangelength[1] );
-
-	checkValueIsExist( "name", "validateOrganisationUnitGroupSet.action", {
+		'rules' : getValidationRules("organisationUnitGroupSet")
+	});
+
+	checkValueIsExist("name", "validateOrganisationUnitGroupSet.action", {
 		id : $organisationUnitGroupSet.id
-	} );
+	});
 
-	changeCompulsory( getFieldValue( 'compulsory' ) );
-} );
+	changeCompulsory(getFieldValue('compulsory'));
+});