← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3193: fixed validation in dhis-web-maintenance-dataadmin

 

------------------------------------------------------------
revno: 3193
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-03-28 19:46:09 +0200
message:
  fixed validation in dhis-web-maintenance-dataadmin
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js
  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-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addSqlViewForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/collectiveDataLockingForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/minMaxValidation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateSqlViewForm.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/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-03-28 13:52:32 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js	2011-03-28 17:46:09 +0000
@@ -1086,9 +1086,11 @@
  * See http://bassistance.de/jquery-plugins/jquery-plugin-validation/ for more
  * information about jquery.validate.
  * 
- * @param formId form to validate @param submitHandler the submitHandler to use
+ * @param formId form to validate 
+ * @param submitHandler the submitHandler to use
  * @param kwargs A dictionary of optional arguments, currently supported are:
- * beforeValidateHandler rules
+ * 		beforeValidateHandler
+ * 		rules
  */
 function validation2(formId, submitHandler, kwargs)
 {

=== 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-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2011-03-28 17:46:09 +0000
@@ -106,5 +106,21 @@
 			"notOnlyDigits": false,
 			"rangelength": [4, 40]
 		}
-	}
+	},
+	
+	/* dhis-web-maintenance-dataadmin */
+	"sqlView": {
+		"name": {
+			"rangelength": [2, 50]
+		},
+		"description": {
+			"rangelength": [2, 255]
+		},
+		"sqlquery": {
+			"rangelength": [1, 255]
+		}
+	},
+	"dataLocking": { },
+	"dataBrowser": { },
+	"minMax": { }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addSqlViewForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addSqlViewForm.vm	2011-03-28 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addSqlViewForm.vm	2011-03-28 17:46:09 +0000
@@ -1,7 +1,26 @@
 <script type="text/javascript">
 	jQuery(document).ready(function() {
-		validation( 'addSqlViewForm', function() {
+		var r = getValidationRules();
+
+		var rules = {
+			name: {
+				required: true,
+				rangelength: r.sqlView.name.rangelength
+			},
+			description: {
+				required: true,
+				rangelength: r.sqlView.description.rangelength
+			},
+			sqlquery: {
+				required: true,
+				rangelength: r.sqlView.sqlquery.rangelength
+			}
+		};
+
+		validation2( 'addSqlViewForm', function() {
 			validateAddUpdateSqlView( 'add' );
+		}, {
+			'rules': rules
 		});
 	});
 </script>
@@ -18,15 +37,15 @@
 		</tr>
 		<tr>
 			<td><label for="name">$encoder.htmlEncode( $i18n.getString( "name" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td><input type="text" id="name" name="name" style="width:25em" maxlength="50" class="{validate:{required:true,minlength:2}}"/></td>
+			<td><input type="text" id="name" name="name" style="width:25em" /></td>
 		</tr>
 		<tr>
 			<td><label for="description">$encoder.htmlEncode( $i18n.getString( "description" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td><textarea id="description" name="description" style="width:25em; height:6em" maxlength="255" class="{validate:{required:true,minlength:2}}"></textarea></td>
+			<td><textarea id="description" name="description" style="width:25em; height:6em"></textarea></td>
 		</tr>
 		<tr>
 			<td><label for="sql_statement">$encoder.htmlEncode( $i18n.getString( "sql_statement" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td><textarea type="text" id="sqlquery" name="sqlquery" style="width:80em;height:20em" class="{validate:{required:false,minlength:1}}">SELECT </textarea></td>
+			<td><textarea type="text" id="sqlquery" name="sqlquery" style="width:80em;height:20em">SELECT </textarea></td>
 		</tr>
 		<tr>
 			<td></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/collectiveDataLockingForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/collectiveDataLockingForm.vm	2011-03-28 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/collectiveDataLockingForm.vm	2011-03-28 17:46:09 +0000
@@ -1,8 +1,21 @@
 <script type="text/javascript">
 	jQuery(document).ready( function() {
-		validation( 'lockingForm', function( form )
+		var r = getValidationRules();
+		
+		var rules = {
+			selectedPeriods: {
+				required: true
+			},
+			selectedDataSets: {
+				required: true
+			}
+		};
+	
+		validation2( 'lockingForm', function( form )
 		{
 			validateCollectiveDataLockingForm( form );
+		}, {
+			'rules': rules
 		});
 	});
 
@@ -49,8 +62,7 @@
 							<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'selectedPeriods', 'availablePeriods' )"/>			
 						</td>	
 						<td>
-							<select id="selectedPeriods" name="selectedPeriods" size="2" multiple="multiple" style="min-width:325px;height:11.25em" ondblclick="moveSelectedById( this.id, 'availablePeriods' )" class="{validate:{required:true}}">
-							</select>
+							<select id="selectedPeriods" name="selectedPeriods" size="2" multiple="multiple" style="min-width:325px;height:11.25em" ondblclick="moveSelectedById( this.id, 'availablePeriods' )"></select>
 						</td>
 					</tr>
 						
@@ -68,8 +80,7 @@
 							<input type="button" value="&lt;&lt;" title="$i18n.getString('remove_all')" style="width:50px" onclick="moveAllById( 'selectedDataSets', 'availableDataSets' )"/>			
 						</td>	
 						<td>
-							<select id="selectedDataSets" name="selectedDataSets" size="2" multiple="multiple" style="min-width:325px;height:11.25em" ondblclick="moveSelectedById( this.id, 'availableDataSets' )" class="{validate:{required:true}}">
-							</select>
+							<select id="selectedDataSets" name="selectedDataSets" size="2" multiple="multiple" style="min-width:325px;height:11.25em" ondblclick="moveSelectedById( this.id, 'availableDataSets' )"></select>
 						</td>
 					</tr>
 				</table>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserForm.vm	2011-03-17 14:42:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataBrowserForm.vm	2011-03-28 17:46:09 +0000
@@ -1,14 +1,27 @@
 <script type="text/javascript">
-	var flag;
-	window.onload = modeHandler;
-
 	jQuery(document).ready(function() {
 		datePickerInRange( 'fromDate' , 'toDate' );
+
+		var r = getValidationRules();
 		
-		validation( 'databrowser', function( form ){ 			
+		var rules = {
+			periodTypeId: {
+				required: true
+			},
+			mode: {
+				required: true
+			}
+		};
+
+		validation2( 'databrowser', function( form ){ 			
 			form.submit();
+		}, {
+			'rules': rules
 		});		
 	});
+
+	var flag;
+	window.onload = modeHandler;
 	
 	var i18n_drilldown_earliest_selected = '$encoder.jsEscape( $i18n.getString("earliest_date_used_if_no_date_selected"), "'" )';
 	var i18n_drilldown_latest_selected = '$encoder.jsEscape( $i18n.getString("latest_date_used_if_no_date_selected"), "'" )';
@@ -26,7 +39,7 @@
 		<tr>
 			<td>$i18n.getString( "period_type" )</td>
 			<td>
-				<select id="periodTypeId" name="periodTypeId" style="min-width:200px" class="{validate:{required:true}}">
+				<select id="periodTypeId" name="periodTypeId" style="min-width:200px">
 					<option value="">[ $i18n.getString( "select_period_type" ) ]</option>
 					#foreach ( $type in $periodTypes )
 						<option value="$type.name" #if( $currentPeriodTypeId == $type.name ) selected="selected"#end>$type.name</option>
@@ -58,7 +71,7 @@
 		<tr>
 			<td>$i18n.getString( "browse_by" )</td>
 			<td>
-				<select id="mode" name="mode" style="min-width:200px" onchange="modeHandler()" class="{validate:{required:true}}">
+				<select id="mode" name="mode" style="min-width:200px" onchange="modeHandler()">
 					<option value ="">[ $i18n.getString( "select_mode" ) ]</option>
 					<option value ="DS">$i18n.getString( "data_sets" )</option>
 					<option value ="DEG">$i18n.getString( "data_element_groups" )</option>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/minMaxValidation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/minMaxValidation.vm	2011-03-28 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/minMaxValidation.vm	2011-03-28 17:46:09 +0000
@@ -1,25 +1,27 @@
 <script type="text/javascript">
-	var isGenerate = true;
-	var numberOfSelects = 0;
-
-	//-----------------------------------------------------------------------
-	//init jQuery validation for reportAssociation
-	//-----------------------------------------------------------------------
 	jQuery(document).ready(function() {
-		jQuery("#minMaxGeneratingForm").validate({
-			 meta:"validate"
-			,errorElement:"td"
-			,submitHandler: function(form)
-				{
-					if(isGenerate){
-						generateMinMaxValue();
-					}else{
-						removeMinMaxValue();
-					}
-				}
+		var r = getValidationRules();
+		
+		var rules = {
+			dataSetIds: {
+				required: true
+			}
+		};
+		
+		validation2( "minMaxGeneratingForm", function() {
+			if(isGenerate) {
+				generateMinMaxValue();
+			} else {
+				removeMinMaxValue();
+			}
+		}, {
+			'rules': rules
 		});
 	});
 
+	var isGenerate = true;
+	var numberOfSelects = 0;
+
 	var i18n_loading = '$encoder.jsEncode( $i18n.getString( "loading" ) )';
 	var levelMustBeInt = '$encoder.jsEncode( $i18n.getString( "level_must_be_int" ) )';
 	var i18n_not_choose_dataset = '$encoder.jsEncode( $i18n.getString( "not_choose_dataset" ) )';
@@ -28,15 +30,15 @@
 
 <h3>$i18n.getString( "min_max_value_generation" )</h3>
 
-<form id="minMaxGeneratingForm" method="POST">
+<form id="minMaxGeneratingForm" method="post">
 <table>
   <tr>
     <th colspan="2">$i18n.getString('available_dataset')</th>
     <td rowspan="2">#organisationUnitSelectionTree( false, true, false ) </td>
   </tr>
   <tr>
-    <td colspan="2" rowspan="2">	
-		<select size="26px" multiple style="width:30em" id='dataSetIds' name='dataSetIds'  class="{validate:{required:true}}">
+    <td colspan="2" rowspan="2">
+		<select size="26px" multiple style="width:30em" id="dataSetIds" name="dataSetIds">
 			#foreach( $dataSet in $dataSets )
 			  <option value="$dataSet.id">$encoder.htmlEncode( $dataSet.name )</option>
 			#end
@@ -55,3 +57,5 @@
 </form>
 
 <span id="info" style="display:none;top:70px;right:5px;position:fixed;" onclick="hideById(this.id)"></span>
+
+<span id="message"></span>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateSqlViewForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateSqlViewForm.vm	2011-03-28 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateSqlViewForm.vm	2011-03-28 17:46:09 +0000
@@ -1,7 +1,26 @@
 <script type="text/javascript">
 	jQuery(document).ready(function() {
-		validation( 'updateSqlViewForm', function() {
+		var r = getValidationRules();
+		
+		var rules = {
+			name: {
+				required: true,
+				rangelength: r.sqlView.name.rangelength
+			},
+			description: {
+				required: true,
+				rangelength: r.sqlView.description.rangelength
+			},
+			sqlquery: {
+				required: true,
+				rangelength: r.sqlView.sqlquery.rangelength
+			}
+		};
+
+		validation2( 'updateSqlViewForm', function() {
 			validateAddUpdateSqlView( 'update' );
+		}, {
+			'rules': rules
 		});
 	});
 </script>
@@ -24,19 +43,19 @@
 		<tr>
 			<td><label for="name">$encoder.htmlEncode( $i18n.getString( "name" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 			<td>
-				<input type="text" id="nameField" name="nameField" value="$!encoder.htmlEncode( $!sqlViewObject.name )" style="width:20em" maxlength="50" disabled />
+				<input type="text" id="name" name="name" value="$!encoder.htmlEncode( $!sqlViewObject.name )" style="width:20em" disabled="disabled" />
 			</td>
 		</tr>
 		<tr>
 			<td><label for="description">$encoder.htmlEncode( $i18n.getString( "description" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 			<td>
-				<textarea id="description" name="description" style="width:20em; height:6em" maxlength="255" class="{validate:{required:true,minlength:2}}">$!encoder.htmlEncode( $!sqlViewObject.description )</textarea>
+				<textarea id="description" name="description" style="width:20em; height:6em">$!encoder.htmlEncode( $!sqlViewObject.description )</textarea>
 			</td>
 		</tr>
 		<tr>
 			<td><label for="sql_statement">$encoder.htmlEncode( $i18n.getString( "sql_statement" ) ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
 			<td>
-				<textarea type="text" id="sqlquery" name="sqlquery" style="width:80em;height:20em" class="{validate:{required:true,minlength:14}}">$!encoder.htmlEncode( $!sqlViewObject.sqlQuery )</textarea>
+				<textarea type="text" id="sqlquery" name="sqlquery" style="width:80em;height:20em">$!encoder.htmlEncode( $!sqlViewObject.sqlQuery )</textarea>
 			</td>
 		</tr>