dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11312
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3202: validation in multidimensional / dhis-web-maintenance-datadictionary
------------------------------------------------------------
revno: 3202
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-03-29 12:07:14 +0200
message:
validation in multidimensional / dhis-web-maintenance-datadictionary
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/multidimensional/addConceptForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryComboForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateConceptForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryComboForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.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 08:15:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-03-29 10:07:14 +0000
@@ -140,5 +140,22 @@
"description" : {
"rangelength" : [ 2, 160 ]
}
+ },
+
+ /* dhis-web-maintenance-datadictionary */
+ "concept" : {
+ "name" : {
+ "rangelength" : [ 3, 10 ]
+ }
+ },
+ "dateElementCategoryCombo" : {
+ "name" : {
+ "rangelength" : [ 2, 160 ]
+ }
+ },
+ "dateElementCategory" : {
+ "name" : {
+ "rangelength" : [ 2, 160 ]
+ }
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addConceptForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addConceptForm.vm 2011-03-25 09:11:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addConceptForm.vm 2011-03-29 10:07:14 +0000
@@ -1,6 +1,21 @@
<script type="text/javascript">
jQuery(document).ready( function(){
- validation( 'addConceptForm', function( form ){ form.submit() } );
+ var r = getValidationRules();
+
+ var rules = {
+ name: {
+ required: true,
+ rangelength: r.concept.name.rangelength,
+ custome_regex:[/^[a-zA-Z][a-zA-Z0-9_]{0,9}$/,'$i18n.getString( 'regex_add_edit_concept' )']
+ }
+ };
+
+ validation2( 'addConceptForm', function( form ) { form.submit() }, {
+ 'rules': rules
+ } );
+
+ jQuery("#name").attr("maxlength", r.concept.name.rangelength[1]);
+
checkValueIsExist( "name", "validateAddUpdateConcept.action" );
});
</script>
@@ -15,8 +30,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="10"
- class="{validate:{required:true,rangelength:[3,10],custome_regex:[/^[a-zA-Z][a-zA-Z0-9_]{0,9}$/,'$i18n.getString( 'regex_add_edit_concept' )']}}"/></td>
+ <td><input type="text" id="name" name="name" style="width:20em"/></td>
</tr>
<tr>
<td></td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryComboForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryComboForm.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/multidimensional/addDataElementCategoryComboForm.vm 2011-03-29 10:07:14 +0000
@@ -1,10 +1,26 @@
<script type="text/javascript">
jQuery(document).ready( function(){
- validation( 'addDataElementCategoryComboForm', function( form ){
+ var r = getValidationRules();
+
+ var rules = {
+ name: {
+ required: true,
+ rangelength: r.dateElementCategoryCombo.name.rangelength
+ },
+ selectedCategories: {
+ required: true
+ }
+ };
+
+ validation2( 'addDataElementCategoryComboForm', function( form ){
validateSelectedCategories( form );
- }, function(){
- listValidator( 'selectedCategories', 'selectedList' );
- } );
+ }, {
+ 'beforeValidationHandler': function() { listValidator( 'selectedCategories', 'selectedList' ); },
+ 'rules': rules
+ });
+
+ jQuery("#name").attr("maxlength", r.dateElementCategoryCombo.name.rangelength[1]);
+
checkValueIsExist( "name", "validateDataElementCategoryCombo.action");
});
</script>
@@ -21,7 +37,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" style="width:20em" maxlength="160" class="{validate:{required:true,minlength:2}}"/></td>
+ <td><input type="text" id="name" name="name" style="width:20em"/></td>
</tr>
<tr>
<td colspan="2" style="height:15px"></td>
@@ -51,7 +67,7 @@
<input type="button" value=">" onclick="moveSelectedById('availableList', 'selectedList')" title="$i18n.getString( 'move_selected' )"/><br/>
<input type="button" value="<" onclick="moveSelectedById('selectedList', 'availableList')" title="$i18n.getString( 'remove_selected' )"/><br/><br/>
<a onclick="moveUpSelectedOption('selectedList')" title="$i18n.getString( 'move_up' )"><img src="../images/move_up.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_up' )"/></a><br/><br/>
- <a onclick="moveDownSelectedOption('selectedList')" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_down' )"/></a>
+ <a onclick="moveDownSelectedOption('selectedList')" title="$i18n.getString( 'move_down' )"><img src="../images/move_down.png" style="border:0;cursor:pointer" alt="$i18n.getString( 'move_down' )"/></a>
</td>
<td>
<select id="selectedList" name="selectedList" multiple="multiple" style="min-width:20em;height:20em" ondblclick="moveSelectedById(this.id, 'availableList')">
@@ -62,7 +78,7 @@
<td></td>
<td></td>
<td>
- <select id="selectedCategories" name="selectedCategories" class="{validate:{required:true}}" style="display:none"></select>
+ <select id="selectedCategories" name="selectedCategories" style="display:none"></select>
</td>
</tr>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/addDataElementCategoryForm.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/multidimensional/addDataElementCategoryForm.vm 2011-03-29 10:07:14 +0000
@@ -1,10 +1,28 @@
<script type="text/javascript">
- jQuery(document).ready( function(){
- validation( 'addDataElementCategoryForm', function( form ){ form.submit()}, function(){
- listValidator( 'memberValidator', 'categoryOptionNames' );
- } );
+ jQuery(document).ready( function() {
+ var r = getValidationRules();
+
+ var rules = {
+ name: {
+ required: true,
+ rangelength: r.dateElementCategory.name.rangelength
+ },
+ conceptId: {
+ required: true
+ },
+ memberValidator: {
+ required: true
+ }
+ };
+
+ validation2( 'addDataElementCategoryForm', function( form ){ form.submit() }, {
+ 'beforeValidationHandler': function() { listValidator( 'memberValidator', 'categoryOptionNames' ); },
+ 'rules': rules
+ });
+
+ jQuery("#name").attr("maxlength", r.dateElementCategory.name.rangelength[1]);
+
checkValueIsExist( "name", "validateDataElementCategory.action");
-
});
var i18n_specify_category_option_name = '$encoder.jsEscape( $i18n.getString( "specify_category_option_name" ) , "'")';
@@ -45,13 +63,13 @@
</tr>
<tr>
<td><label>$i18n.getString( "name" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
- <td colspan="3"><input type="text" id="name" name="name" style="width:25em" maxlength="160" class="{validate:{required:true,minlength:2}}"/></td>
+ <td colspan="3"><input type="text" id="name" name="name" style="width:25em"/></td>
</tr>
<tr>
<td><label>$i18n.getString( "concept_name" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td colspan="3">
<div style="inline">
- <select id="conceptId" name="conceptId" style="width:305px" class="{validate:{required:true}}">
+ <select id="conceptId" name="conceptId" style="width:305px">
#foreach( $concept in $concepts )
<option value="$concept.id">$concept.name</option>
#end
@@ -64,7 +82,7 @@
</tr>
<tr>
<th colspan="4">$i18n.getString( "category_options" )
- <select id="memberValidator" class="{validate:{required:true}}" style="display:none"/></th>
+ <select id="memberValidator" style="display:none"/></th>
</tr>
<tr>
<td><label>$i18n.getString( "name" )</label></td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateConceptForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateConceptForm.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/multidimensional/updateConceptForm.vm 2011-03-29 10:07:14 +0000
@@ -1,6 +1,21 @@
<script type="text/javascript">
jQuery(document).ready( function(){
- validation( 'updateConceptForm', function( form ){ form.submit() } );
+ var r = getValidationRules();
+
+ var rules = {
+ name: {
+ required: true,
+ rangelength: r.concept.name.rangelength,
+ custome_regex:[/^[a-zA-Z][a-zA-Z0-9_]{0,9}$/,'$i18n.getString( 'regex_add_edit_concept' )']
+ }
+ };
+
+ validation2( 'updateConceptForm', function( form ) { form.submit() }, {
+ 'rules': rules
+ } );
+
+ jQuery("#name").attr("maxlength", r.concept.name.rangelength[1]);
+
checkValueIsExist( "name", "validateAddUpdateConcept.action", {id: $concept.id});
});
</script>
@@ -19,8 +34,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( $concept.name )" style="width:20em" maxlength="10"
- class="{validate:{required:true,rangelength:[3,10],custome_regex:[/^[a-zA-Z][a-zA-Z0-9_]{0,9}$/,'$i18n.getString('regex_add_edit_concept')']}}"/></td>
+ <td><input type="text" id="name" name="name" value="$encoder.htmlEncode( $concept.name )" style="width:20em"/></td>
</tr>
<tr>
<td></td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryComboForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryComboForm.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/multidimensional/updateDataElementCategoryComboForm.vm 2011-03-29 10:07:14 +0000
@@ -1,10 +1,25 @@
<script type="text/javascript">
jQuery(document).ready( function(){
- validation( 'editDataElementCategoryComboForm', function( form ){
+ var r = getValidationRules();
+
+ var rules = {
+ name: {
+ required: true,
+ rangelength: r.dateElementCategoryCombo.name.rangelength
+ },
+ selectedCategories: {
+ required: true
+ }
+ };
+
+ validation2( 'editDataElementCategoryComboForm', function( form ) {
validateSelectedCategories( form );
- }, function(){
- listValidator( 'selectedCategories', 'selectedList' );
- } );
+ }, {
+ 'beforeValidationHandler': function() { listValidator( 'selectedCategories', 'selectedList' ); },
+ 'rules': rules
+ });
+
+ jQuery("#name").attr("maxlength", r.dateElementCategoryCombo.name.rangelength[1]);
checkValueIsExist( "name", "validateDataElementCategoryCombo.action", {id: $dataElementCategoryCombo.id});
});
@@ -24,7 +39,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" style="width:20em" value="$encoder.htmlEncode( $dataElementCategoryCombo.name )" maxlength="160" class="{validate:{required:true,minlength:2}}"/></td>
+ <td><input type="text" id="name" name="name" style="width:20em" value="$encoder.htmlEncode( $dataElementCategoryCombo.name )"/></td>
</tr>
<tr>
<td colspan="2" style="height:15px"></td>
@@ -73,7 +88,7 @@
<td></td>
<td></td>
<td>
- <select id="selectedCategories" name="selectedCategories" class="{validate:{required:true}}" style="display:none"></select>
+ <select id="selectedCategories" name="selectedCategories" style="display:none"></select>
</td>
</tr>
</tbody>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/multidimensional/updateDataElementCategoryForm.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/multidimensional/updateDataElementCategoryForm.vm 2011-03-29 10:07:14 +0000
@@ -1,10 +1,28 @@
<script type="text/javascript">
- jQuery(document).ready( function(){
- validation( 'editDataElementCategoryForm', function( form ){ form.submit()}, function(){
- listValidator( 'memberValidator', 'categoryOptions' );
- });
+ jQuery(document).ready( function() {
+ var r = getValidationRules();
+
+ var rules = {
+ name: {
+ required: true,
+ rangelength: r.dateElementCategory.name.rangelength
+ },
+ conceptId: {
+ required: true
+ },
+ memberValidator: {
+ required: true
+ }
+ };
+
+ validation2( 'editDataElementCategoryForm', function( form ){ form.submit()}, {
+ 'beforeValidationHandler': function() { listValidator( 'memberValidator', 'categoryOptions' ); },
+ 'rules': rules
+ });
+
+ jQuery("#name").attr("maxlength", r.dateElementCategory.name.rangelength[1]);
+
checkValueIsExist( "name", "validateDataElementCategory.action", {id: $dataElementCategory.id});
-
});
var i18n_specify_category_option_name = '$encoder.jsEscape( $i18n.getString( "specify_category_option_name" ) , "'")';
@@ -68,7 +86,7 @@
</tr>
<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( $dataElementCategory.name )" style="width:25em" maxlength="160" class="{validate:{required:true,minlength:2}}"/></td>
+ <td><input type="text" id="name" name="name" value="$!encoder.htmlEncode( $dataElementCategory.name )" style="width:25em"/></td>
<td></td>
</tr>
<tr>
@@ -76,7 +94,7 @@
<td>
<div style="inline">
#set ( $conceptId = $!dataElementCategory.concept.id )
- <select id="conceptId" name="conceptId" style="width:305px" class="{validate:{required:true}}">
+ <select id="conceptId" name="conceptId" style="width:305px">
#foreach( $concept in $concepts )
<option value="$concept.id" #if ( $concept.id == $conceptId ) selected #end>$concept.name</option>
#end
@@ -90,7 +108,7 @@
</tr>
<tr>
<th colspan="4">$i18n.getString( "category_options" )
- <select id="memberValidator" class="{validate:{required:true}}" style="display:none"/></th>
+ <select id="memberValidator" style="display:none"/></th>
</tr>
<tr>
<td><label>$i18n.getString( "selected_name" )</label></td>