dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11595
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3340: WIP: validation rules
------------------------------------------------------------
revno: 3340
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-04-11 13:52:24 +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-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.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:36:18 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js 2011-04-11 11:52:24 +0000
@@ -118,24 +118,28 @@
/* dhis-web-maintenance-dataset */
"dataEntry" : {
"name" : {
+ "required" : true,
"rangelength" : [ 4, 100 ]
}
},
"section" : {
- "name" : {
+ "sectionName" : {
+ "required" : true,
"rangelength" : [ 2, 160 ]
},
"selectedList" : {
-
+ "required" : true
}
},
"dataSet" : {
"name" : {
+ "required" : true,
"alphanumericwithbasicpuncspaces" : true,
"firstletteralphabet" : false,
"rangelength" : [ 4, 150 ]
},
"shortName" : {
+ "required" : true,
"alphanumericwithbasicpuncspaces" : true,
"firstletteralphabet" : false,
"rangelength" : [ 2, 20 ]
@@ -144,6 +148,9 @@
"alphanumericwithbasicpuncspaces" : true,
"notOnlyDigits" : false,
"rangelength" : [ 4, 40 ]
+ },
+ "frequencySelect" : {
+ "required" : true
}
},
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js 2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addDataSet.js 2011-04-11 11:52:24 +0000
@@ -1,46 +1,14 @@
-jQuery( document ).ready( function()
-{
- var r = getValidationRules();
-
- var rules = {
- name : {
- required : true,
- alphanumericwithbasicpuncspaces : r.dataSet.name.alphanumericwithbasicpuncspaces,
- firstletteralphabet : r.dataSet.name.firstletteralphabet,
- rangelength : r.dataSet.name.rangelength
- },
- shortName : {
- required : true,
- alphanumericwithbasicpuncspaces : r.dataSet.shortName.alphanumericwithbasicpuncspaces,
- firstletteralphabet : r.dataSet.shortName.firstletteralphabet,
- rangelength : r.dataSet.shortName.rangelength
- },
- code : {
- alphanumericwithbasicpuncspaces : r.dataSet.code.alphanumericwithbasicpuncspaces,
- notOnlyDigits : r.dataSet.code.notOnlyDigits,
- rangelength : r.dataSet.code.rangelength
- },
- frequencySelect : {
- required : true
- }
- };
-
- validation2( 'addDataSetForm', function( form )
- {
+jQuery(document).ready(function() {
+ validation2('addDataSetForm', function(form) {
form.submit()
}, {
- 'beforeValidateHandler' : function()
- {
- selectAllById( 'selectedList' )
+ 'beforeValidateHandler' : function() {
+ selectAllById('selectedList')
},
- 'rules' : rules
- } );
-
- jQuery( "#name" ).attr( "maxlength", r.dataSet.name.rangelength[1] );
- jQuery( "#shortName" ).attr( "maxlength", r.dataSet.shortName.rangelength[1] );
- jQuery( "#code" ).attr( "maxlength", r.dataSet.code.rangelength[1] );
-
- checkValueIsExist( "name", "validateDataSet.action" );
- checkValueIsExist( "shortName", "validateDataSet.action" );
- checkValueIsExist( "code", "validateDataSet.action" );
-} );
+ 'rules' : getValidationRules("dataSet")
+ });
+
+ checkValueIsExist("name", "validateDataSet.action");
+ checkValueIsExist("shortName", "validateDataSet.action");
+ checkValueIsExist("code", "validateDataSet.action");
+});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js 2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/addSection.js 2011-04-11 11:52:24 +0000
@@ -1,38 +1,19 @@
-jQuery( document ).ready( function()
-{
- var r = getValidationRules();
-
- var rules = {
- sectionName : {
- required : true,
- rangelength : r.section.name.rangelength
- },
- selectedList : {
- required : true
- }
- };
-
- validation2( 'addSectionForm', function( form )
- {
+jQuery(document).ready(function() {
+ validation2('addSectionForm', function(form) {
form.submit()
}, {
- 'beforeValidateHandler' : function()
- {
- selectAllById( 'selectedList' );
- },
- 'rules' : rules
- } );
-
- jQuery( "#sectionName" ).attr( "maxlength", r.section.name.rangelength[1] );
-
- checkValueIsExist( "sectionName", "validateSection.action", {
- dataSetId : function()
- {
- return jQuery( "#dataSetId" ).val();
- },
- name : function()
- {
- return jQuery( "#sectionName" ).val();
+ 'beforeValidateHandler' : function() {
+ selectAllById('selectedList');
+ },
+ 'rules' : getValidationRules("section")
+ });
+
+ checkValueIsExist("sectionName", "validateSection.action", {
+ dataSetId : function() {
+ return jQuery("#dataSetId").val();
+ },
+ name : function() {
+ return jQuery("#sectionName").val();
}
- } );
-} );
+ });
+});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js 2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editDataSet.js 2011-04-11 11:52:24 +0000
@@ -1,63 +1,28 @@
-jQuery( document ).ready( function()
-{
- var r = getValidationRules();
-
- var rules = {
- name : {
- required : true,
- alphanumericwithbasicpuncspaces : r.dataSet.name.alphanumericwithbasicpuncspaces,
- firstletteralphabet : r.dataSet.name.firstletteralphabet,
- rangelength : r.dataSet.name.rangelength
- },
- shortName : {
- required : true,
- alphanumericwithbasicpuncspaces : r.dataSet.shortName.alphanumericwithbasicpuncspaces,
- firstletteralphabet : r.dataSet.shortName.firstletteralphabet,
- rangelength : r.dataSet.shortName.rangelength
- },
- code : {
- alphanumericwithbasicpuncspaces : r.dataSet.code.alphanumericwithbasicpuncspaces,
- notOnlyDigits : r.dataSet.code.notOnlyDigits,
- rangelength : r.dataSet.code.rangelength
- },
- frequencySelect : {
- required : true
- }
- };
-
- validation2( 'editDataSetForm', function( form )
- {
+jQuery(document).ready(function() {
+ validation2('editDataSetForm', function(form) {
form.submit()
}, {
- 'beforeValidateHandler' : function()
- {
- selectAllById( 'selectedList' )
+ 'beforeValidateHandler' : function() {
+ selectAllById('selectedList')
},
- 'rules' : rules
- } );
-
- jQuery( "#name" ).attr( "maxlength", r.dataSet.name.rangelength[1] );
- jQuery( "#shortName" ).attr( "maxlength", r.dataSet.shortName.rangelength[1] );
- jQuery( "#code" ).attr( "maxlength", r.dataSet.code.rangelength[1] );
-
- checkValueIsExist( "name", "validateDataSet.action", {
- dataSetId : function()
- {
- return jQuery( "#dataSetId" ).val();
- }
- } );
-
- checkValueIsExist( "shortName", "validateDataSet.action", {
- dataSetId : function()
- {
- return jQuery( "#dataSetId" ).val();
- }
- } );
-
- checkValueIsExist( "code", "validateDataSet.action", {
- dataSetId : function()
- {
- return jQuery( "#dataSetId" ).val();
- }
- } );
-} );
+ 'rules' : getValidationRules("dataSet")
+ });
+
+ checkValueIsExist("name", "validateDataSet.action", {
+ dataSetId : function() {
+ return jQuery("#dataSetId").val();
+ }
+ });
+
+ checkValueIsExist("shortName", "validateDataSet.action", {
+ dataSetId : function() {
+ return jQuery("#dataSetId").val();
+ }
+ });
+
+ checkValueIsExist("code", "validateDataSet.action", {
+ dataSetId : function() {
+ return jQuery("#dataSetId").val();
+ }
+ });
+});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js 2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/editSection.js 2011-04-11 11:52:24 +0000
@@ -1,39 +1,22 @@
-jQuery( document ).ready( function()
-{
- var r = getValidationRules();
-
- var rules = {
- sectionName : {
- required : true,
- rangelength : r.section.name.rangelength
- }
- };
-
- validation2( 'editDataSetForm', function( form )
- {
+jQuery(document).ready(function() {
+ validation2('editDataSetForm', function(form) {
form.submit()
}, {
- 'beforeValidateHandler' : function()
- {
- selectAllById( 'selectedList' )
- },
- 'rules' : rules
- } );
-
- jQuery( "#sectionName" ).attr( "maxlength", r.section.name.rangelength[1] );
-
- checkValueIsExist( "sectionName", "validateSection.action", {
- dataSetId : function()
- {
- return jQuery( "#dataSetId" ).val();
- },
- name : function()
- {
- return jQuery( "#sectionName" ).val();
- },
- sectionId : function()
- {
- return jQuery( "#sectionId" ).val();
+ 'beforeValidateHandler' : function() {
+ selectAllById('selectedList')
+ },
+ 'rules' : getValidationRules("section")
+ });
+
+ checkValueIsExist("sectionName", "validateSection.action", {
+ dataSetId : function() {
+ return jQuery("#dataSetId").val();
+ },
+ name : function() {
+ return jQuery("#sectionName").val();
+ },
+ sectionId : function() {
+ return jQuery("#sectionId").val();
}
- } );
-} );
+ });
+});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js 2011-03-23 08:45:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/javascript/viewDataEntryForm.js 2011-04-11 11:52:24 +0000
@@ -1,65 +1,49 @@
-jQuery( document ).ready( function()
-{
- var r = getValidationRules();
-
- var rules = {
- nameField : {
- required : true,
- rangelength : r.dataEntry.name.rangelength
- }
- };
-
- validation2( 'saveDataEntryForm', function()
- {
+jQuery(document).ready(function() {
+ validation2('saveDataEntryForm', function() {
autoSave = false;
validateDataEntryForm();
}, {
- 'rules' : rules
- } );
-
- jQuery( "#nameField" ).attr( "maxlength", r.dataEntry.name.rangelength[1] );
-
- jQuery( "#dataElementSelection" ).resizable( {
+ 'rules' : getValidationRules("dataEntry")
+ });
+
+ jQuery("#dataElementSelection").resizable({
minHeight : 210,
minWidth : 400,
width : 400,
alsoResize : "#dataElementList"
- } );
+ });
- jQuery( "#dataElementSelection" ).draggable( {
+ jQuery("#dataElementSelection").draggable({
handle : 'h3'
- } );
+ });
leftBar.hideAnimated();
- select( 1 );
-
-} );
-
-function timedCount()
-{
+ select(1);
+
+});
+
+function timedCount() {
validateDataEntryForm();
- t = setTimeout( "timedCount()", 20000 );// 1000 -> 1s
- byId( 'message' ).style.display = 'none';
+ t = setTimeout("timedCount()", 20000);// 1000 -> 1s
+ byId('message').style.display = 'none';
}
-function select( id )
-{
+function select(id) {
if (selected != null) {
- jQuery( "#tr" + selected ).removeClass( "selected" );
+ jQuery("#tr" + selected).removeClass("selected");
}
- jQuery( "#tr" + id ).addClass( "selected" );
+ jQuery("#tr" + id).addClass("selected");
selected = id;
}
-function insertDataElement()
-{
- var oEditor = FCKeditorAPI.GetInstance( 'designTextarea' );
- var viewByValue = getFieldValue( 'viewBySelector' );
+function insertDataElement() {
+ var oEditor = FCKeditorAPI.GetInstance('designTextarea');
+ var viewByValue = getFieldValue('viewBySelector');
- var json = JSON.parse( jQuery( "#json_" + selected ).val() );
+ var json = JSON.parse(jQuery("#json_" + selected).val());
var dataElementId = json.dataElement.id;
var dataElementName = json.dataElement.name;
@@ -74,12 +58,15 @@
else
dispName = "[ " + json.dataElement.name;
- var titleValue = "-- " + dataElementId + ". " + dataElementName + " " + optionComboId + ". " + optionComboName
- + " (" + dataElementType + ") --";
+ var titleValue = "-- " + dataElementId + ". " + dataElementName + " "
+ + optionComboId + ". " + optionComboName + " (" + dataElementType
+ + ") --";
var displayName = dispName + " - " + optionComboName + " ]";
- var dataEntryId = "value[" + dataElementId + "].value:value[" + optionComboId + "].value";
- var boolDataEntryId = "value[" + dataElementId + "].value:value[" + optionComboId + "].value";
+ var dataEntryId = "value[" + dataElementId + "].value:value["
+ + optionComboId + "].value";
+ var boolDataEntryId = "value[" + dataElementId + "].value:value["
+ + optionComboId + "].value";
viewByValue = "@@" + viewByValue + "@@";
@@ -88,35 +75,35 @@
if (dataElementType == "bool") {
id = boolDataEntryId;
- html = "<input title=\"" + titleValue + "\" view=\"" + viewByValue + "\" value=\"" + displayName + "\" id=\""
- + boolDataEntryId + "\" style=\"width:4em;text-align:center\"/>";
+ html = "<input title=\"" + titleValue + "\" view=\"" + viewByValue
+ + "\" value=\"" + displayName + "\" id=\"" + boolDataEntryId
+ + "\" style=\"width:4em;text-align:center\"/>";
} else {
id = dataEntryId;
- html = "<input title=\"" + titleValue + "\" view=\"" + viewByValue + "\" value=\"" + displayName + "\" id=\""
- + dataEntryId + "\" style=\"width:4em;text-align:center\"/>";
+ html = "<input title=\"" + titleValue + "\" view=\"" + viewByValue
+ + "\" value=\"" + displayName + "\" id=\"" + dataEntryId
+ + "\" style=\"width:4em;text-align:center\"/>";
}
- if (checkExisted( id )) {
- jQuery( "#message_" ).html( "<b>" + i18n_dataelement_is_inserted + "</b>" );
+ if (checkExisted(id)) {
+ jQuery("#message_").html("<b>" + i18n_dataelement_is_inserted + "</b>");
return;
} else {
- jQuery( "#message_" ).html( "" );
+ jQuery("#message_").html("");
}
- oEditor.InsertHtml( html );
+ oEditor.InsertHtml(html);
}
-function checkExisted( id )
-{
+function checkExisted(id) {
var result = false;
- var html = FCKeditorAPI.GetInstance( 'designTextarea' ).GetHTML();
- var input = jQuery( html ).find( "select, :text" );
- input.each( function( i, item )
- {
+ var html = FCKeditorAPI.GetInstance('designTextarea').GetHTML();
+ var input = jQuery(html).find("select, :text");
+ input.each(function(i, item) {
if (id == item.id)
result = true;
- } );
+ });
return result;
}