dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11001
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3042: externalized validation rules for dhis-web-maintenance-user (WIP)
------------------------------------------------------------
revno: 3042
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-03-15 15:49:49 +0100
message:
externalized validation rules for dhis-web-maintenance-user (WIP)
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/validationRules.json
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/useraccount/updateUserAccountForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addRoleForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserGroupForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateRoleForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserForm.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserGroupForm.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/commons.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2011-03-15 13:37:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.js 2011-03-15 14:49:49 +0000
@@ -8,8 +8,10 @@
/**
* Redirects to the translate GUI.
*
- * @param className the name of the object class.
- * @param objectId the identifier of the object.
+ * @param className
+ * the name of the object class.
+ * @param objectId
+ * the identifier of the object.
*/
function translate( className, objectId )
{
@@ -22,7 +24,8 @@
* Gets help content for the given id. Opens the right bar and puts the content
* inside. Reads data from an underlying docbook file.
*
- * @param id the content id, refers to the section id in the docbook file.
+ * @param id
+ * the content id, refers to the section id in the docbook file.
*/
function getHelpContent( id )
{
@@ -47,7 +50,8 @@
/**
* Filters values in a html table with tbody id "list".
*
- * @param filter the filter.
+ * @param filter
+ * the filter.
*/
function filterValues( filter, columnIndex )
{
@@ -75,9 +79,11 @@
}
/**
- * Returns the value of the selected option in the list with the given identifier.
+ * Returns the value of the selected option in the list with the given
+ * identifier.
*
- * @param listId the list identifier.
+ * @param listId
+ * the list identifier.
*/
function getListValue( listId )
{
@@ -90,7 +96,8 @@
/**
* Hides the document element with the given identifier.
*
- * @param id the element identifier.
+ * @param id
+ * the element identifier.
*/
function hideById( id )
{
@@ -100,7 +107,8 @@
/**
* Shows the document element with the given identifier.
*
- * @param id the element identifier.
+ * @param id
+ * the element identifier.
*/
function showById( id )
{
@@ -110,7 +118,8 @@
/**
* Returns true if the element with the given identifier has text, false if not.
*
- * @param inputId the identifier of the input element.
+ * @param inputId
+ * the identifier of the input element.
*/
function hasText( inputId )
{
@@ -123,10 +132,11 @@
}
/**
- * Returns true if the element with the given identifier is checked, false if not
- * or if it does not exist.
+ * Returns true if the element with the given identifier is checked, false if
+ * not or if it does not exist.
*
- * @param checkboxId the identifier of the checkbox element.
+ * @param checkboxId
+ * the identifier of the checkbox element.
*/
function isChecked( checkboxId )
{
@@ -134,7 +144,8 @@
}
/**
- * Checks the checkbox with the given jQuery Selector String if the checkbox exists.
+ * Checks the checkbox with the given jQuery Selector String if the checkbox
+ * exists.
*/
function checkALL( jQuerySelectorString )
{
@@ -165,7 +176,8 @@
}
/**
- * unChecks the checkbox with the given jQuery Selector String if the checkbox exists.
+ * unChecks the checkbox with the given jQuery Selector String if the checkbox
+ * exists.
*/
function unCheckALL( jQuerySelectorString )
{
@@ -204,7 +216,8 @@
});
}
/**
- * Enables the element with the given identifier if the element exists in parent window of frame.
+ * Enables the element with the given identifier if the element exists in parent
+ * window of frame.
*/
function enableParent( elementId )
{
@@ -217,7 +230,8 @@
}
/**
- * Disables the element with the given identifier if the element exists in parent window of frame.
+ * Disables the element with the given identifier if the element exists in
+ * parent window of frame.
*/
function disableParent( elementId )
{
@@ -233,7 +247,8 @@
* Returns true if the element with the given identifier has selected elements
* associated with it, false if not.
*
- * @param listId the identifier of the list element.
+ * @param listId
+ * the identifier of the list element.
*/
function hasElements( listId )
{
@@ -243,7 +258,8 @@
/**
* Returns true if the element with the given identifier exists, false if not.
*
- * @param elementId the identifier of the element.
+ * @param elementId
+ * the identifier of the element.
*/
function isNotNull( elementId )
{
@@ -253,12 +269,14 @@
/**
* HTML encodes the given string.
*
- * @param str the input string.
+ * @param str
+ * the input string.
* @return the HTML encoded string.
*/
function htmlEncode( str )
{
- str = str.replace( /\%/g, "%25" ); //This line must come first so the % doesn't get overwritten later
+ str = str.replace( /\%/g, "%25" ); // This line must come first so the %
+ // doesn't get overwritten later
str = str.replace( /\ /g, "%20" );
str = str.replace( /\!/g, "%21" );
str = str.replace( /\"/g, "%22" );
@@ -288,8 +306,10 @@
/**
* Gets the value for the element with the given name from the DOM object.
*
- * @param parentElement the DOM object.
- * @param childElementName the name of the element.
+ * @param parentElement
+ * the DOM object.
+ * @param childElementName
+ * the name of the element.
*/
function getElementValue( parentElement, childElementName )
{
@@ -301,8 +321,10 @@
/**
* Gets the attribute value from the given DOM element.
*
- * @param parentElement the DOM object.
- * @param attributeName the name of the attribute.
+ * @param parentElement
+ * the DOM object.
+ * @param attributeName
+ * the name of the attribute.
*/
function getElementAttribute( parentElement, childElementName, childAttributeName )
{
@@ -314,7 +336,8 @@
/**
* Gets the value from the given DOM element.
*
- * @param rootElement the DOM object.
+ * @param rootElement
+ * the DOM object.
*/
function getRootElementValue( rootElement )
{
@@ -324,10 +347,13 @@
}
/**
- * Gets the value of the attribute with the given name from the given DOM element.
+ * Gets the value of the attribute with the given name from the given DOM
+ * element.
*
- * @param rootElement the DOM object.
- * @param attributeName the name of the attribute.
+ * @param rootElement
+ * the DOM object.
+ * @param attributeName
+ * the name of the attribute.
*/
function getRootElementAttribute( rootElement, attributeName )
{
@@ -337,8 +363,10 @@
/**
* Sets a value on the given element.
*
- * @param fieldId the identifier of the element.
- * @param value the value to set.
+ * @param fieldId
+ * the identifier of the element.
+ * @param value
+ * the value to set.
*/
function setInnerHTML( fieldId, value )
{
@@ -348,7 +376,8 @@
/**
* Gets a value from the given element and HTML encodes it.
*
- * @param fieldId the identifier of the element.
+ * @param fieldId
+ * the identifier of the element.
* @return the HTML encoded value of the element with the given identifier.
*/
function getInnerHTML( fieldId )
@@ -359,8 +388,10 @@
/**
* Sets a value on the given element.
*
- * @param fieldId the identifier of the element.
- * @param value the value to set.
+ * @param fieldId
+ * the identifier of the element.
+ * @param value
+ * the value to set.
*/
function setFieldValue( fieldId, value )
{
@@ -370,7 +401,8 @@
/**
* Gets a value from the given element and HTML encodes it.
*
- * @param fieldId the identifier of the element.
+ * @param fieldId
+ * the identifier of the element.
* @return the HTML encoded value of the element with the given identifier.
*/
function getFieldValue( fieldId )
@@ -386,7 +418,8 @@
/**
* Gets a value from the given element and HTML encodes it.
*
- * @param fieldId the identifier of the element.
+ * @param fieldId
+ * the identifier of the element.
* @return the type of the element with the given identifier.
*/
function getTypeById( fieldId, attribute )
@@ -397,7 +430,8 @@
/**
* get value of input radio with name
*
- * @param radioName name of input radio
+ * @param radioName
+ * name of input radio
*/
function getRadioValue( radioName )
{
@@ -411,8 +445,10 @@
}
/**
- * set value for input radio with name
- * @param radioName name of input radio
+ * set value for input radio with name
+ *
+ * @param radioName
+ * name of input radio
*/
function setRadioValue( radioName, value )
{
@@ -429,7 +465,8 @@
/**
* Shows the message span and sets the message as text.
*
- * @param message the message.
+ * @param message
+ * the message.
*/
function setMessage( message )
{
@@ -441,9 +478,11 @@
}
/**
- * Shows the message span and sets the message as text together with a wait animation.
+ * Shows the message span and sets the message as text together with a wait
+ * animation.
*
- * @param message the message.
+ * @param message
+ * the message.
*/
function setWaitMessage( message )
{
@@ -461,7 +500,8 @@
/**
* Slides down the header message div and sets the message as text.
*
- * @param message the message.
+ * @param message
+ * the message.
*/
function setHeaderMessage( message )
{
@@ -472,7 +512,8 @@
/**
* Updates the text in the header message div with the message.
*
- * @param message the message.
+ * @param message
+ * the message.
*/
function updateHeaderMessage( message )
{
@@ -480,9 +521,11 @@
}
/**
- * Slides down the header message div and sets the message as text together with a wait animation.
+ * Slides down the header message div and sets the message as text together with
+ * a wait animation.
*
- * @param message the message.
+ * @param message
+ * the message.
*/
function setHeaderWaitMessage( message )
{
@@ -493,7 +536,8 @@
/**
* Updates the text in the header message div with the message.
*
- * @param message the message.
+ * @param message
+ * the message.
*/
function updateHeaderWaitMessage( message )
{
@@ -537,7 +581,8 @@
/**
* Slides down the info message div and sets the message as text.
*
- * @param message the message.
+ * @param message
+ * the message.
*/
function setInfo( message )
{
@@ -591,7 +636,8 @@
/**
* Convenience method for getting a document element.
*
- * @param id id of the element to get.
+ * @param id
+ * id of the element to get.
*/
function byId( elementId )
{
@@ -601,8 +647,10 @@
/**
* Toggles visibility for an element.
*
- * @param id the identifier of the element.
- * @param display boolean indicator.
+ * @param id
+ * the identifier of the element.
+ * @param display
+ * boolean indicator.
*/
function toggleByIdAndFlag( id, display )
{
@@ -619,7 +667,8 @@
/**
* Toggles visibility for an element.
*
- * @param id the identifier of the element.
+ * @param id
+ * the identifier of the element.
*/
function toggleById( id )
{
@@ -651,8 +700,8 @@
}
/**
- * Returns a query string with all element values in the select list and
- * the specified param.
+ * Returns a query string with all element values in the select list and the
+ * specified param.
*/
function getParamString( elementId, param )
{
@@ -670,9 +719,12 @@
/**
* Creates an option and adds it to the list.
*
- * @param list the list.
- * @param optionValue the option value.
- * @param optionText the option text.
+ * @param list
+ * the list.
+ * @param optionValue
+ * the option value.
+ * @param optionText
+ * the option text.
*/
function addOptionToList( list, optionValue, optionText )
{
@@ -683,11 +735,13 @@
}
/**
- * Returns a query string on the form <paramName>=<listValue> based on the options
- * in the list with the given identifier.
+ * Returns a query string on the form <paramName>=<listValue> based on the
+ * options in the list with the given identifier.
*
- * @param listId the list identifier.
- * @param paramName the name of the query param.
+ * @param listId
+ * the list identifier.
+ * @param paramName
+ * the name of the query param.
* @return a query string.
*/
function getQueryStringFromList( listId, paramName )
@@ -724,13 +778,17 @@
}
/**
- * Deletes and removes an item from a table. The table row to be removed must have
- * an identifier on the form "tr[itemId]".
+ * Deletes and removes an item from a table. The table row to be removed must
+ * have an identifier on the form "tr[itemId]".
*
- * @param itemId the item identifier.
- * @param itemName the item name.
- * @param message the confirmation message.
- * @param action the server action url for deleting the item.
+ * @param itemId
+ * the item identifier.
+ * @param itemName
+ * the item name.
+ * @param message
+ * the confirmation message.
+ * @param action
+ * the server action url for deleting the item.
*/
function removeItem( itemId, itemName, confirmation, action )
{
@@ -767,8 +825,10 @@
/**
- * Create jQuery datepicker for input text with id * *
- * @param id the id of input field which you want enter date *
+ * Create jQuery datepicker for input text with id * *
+ *
+ * @param id
+ * the id of input field which you want enter date *
*/
function datePicker( id )
{
@@ -832,8 +892,10 @@
}
/**
- * Create jQuery datepicker for input text with id * *
- * @param id the id of input field which you want enter date *
+ * Create jQuery datepicker for input text with id * *
+ *
+ * @param id
+ * the id of input field which you want enter date *
*/
function datePickerValid( id, today )
{
@@ -861,9 +923,12 @@
}
/**
- * Create jQuery datepicker for start date and end ate text with id * *
- * @param startdate the id of input field which you want enter start date *
- * @param enddate the id of input field which you want enter end date *
+ * Create jQuery datepicker for start date and end ate text with id * *
+ *
+ * @param startdate
+ * the id of input field which you want enter start date *
+ * @param enddate
+ * the id of input field which you want enter end date *
*/
function datePickerInRange ( startdate, enddate, setCurrentStartDate, setCurrentEndDate )
@@ -907,8 +972,10 @@
}
/**
- * Create input table id become sortable table * *
- * @param tableId the id of table you want to sort * *
+ * Create input table id become sortable table * *
+ *
+ * @param tableId
+ * the id of table you want to sort * *
*/
function tableSorter( tableId, sortList )
@@ -979,25 +1046,24 @@
setCaretToPos( inputArea, inputArea.value.length );
}
-//==============================================================================
-// FORM VALIDATION
-//==============================================================================
+// ==============================================================================
+// FORM VALIDATION
+// ==============================================================================
/**
- * Create validator for fileds in form *
+ * Create validator for fileds in form *
*/
-/* this should replace validation() at some point, but theres just to much code
+/*
+ * this should replace validation() at some point, but theres just to much code
* depending on the old version for now.
*
- * See http://bassistance.de/jquery-plugins/jquery-plugin-validation/ for more
+ * 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)
{
@@ -1022,6 +1088,21 @@
return validator;
}
+function getValidationRules() {
+ var validationRules;
+
+ jQuery.ajax({
+ 'url': '../dhis-web-commons/validationRules.json',
+ async: false,
+ cache: false,
+ success: function(data) {
+ validationRules = jQuery.parseJSON(data);
+ }
+ });
+
+ return validationRules;
+}
+
function validation( formId, submitHandler, beforeValidateHandler )
{
var nameField = jQuery('#' + formId + ' :input')[0];
@@ -1043,9 +1124,13 @@
/**
* Add validation rule remote for input field
-* @param inputId is id for input field
-* @param url is ajax request url
-* @param params is array of param will send to server by ajax request
+ *
+ * @param inputId
+ * is id for input field
+ * @param url
+ * is ajax request url
+ * @param params
+ * is array of param will send to server by ajax request
*/
function checkValueIsExist( inputId, url, params )
{
@@ -1081,11 +1166,14 @@
}
/**
-* Add any validator Rules for input
-* @param inputId is id for input field
-* @param rules is array of rule
-* @note: input field must have name same with id
-*/
+ * Add any validator Rules for input
+ *
+ * @param inputId
+ * is id for input field
+ * @param rules
+ * is array of rule
+ * @note: input field must have name same with id
+ */
function addValidatorRulesById( inputId, rules )
{
addValidatorRules( jQuery("#" + inputId), rules );
@@ -1097,11 +1185,14 @@
}
/**
-* Remove validator Rules for input
-* @param inputId is id for input field
-* @param rules is array of rule you want to remove
-* @note: input field must have name same with id
-*/
+ * Remove validator Rules for input
+ *
+ * @param inputId
+ * is id for input field
+ * @param rules
+ * is array of rule you want to remove
+ * @note: input field must have name same with id
+ */
function removeValidatorRulesById( inputId, rules )
{
removeValidatorRules( jQuery("#" + inputId), rules );
@@ -1125,35 +1216,50 @@
});
}
-//==============================================================================
-// MESSAGE
-//==============================================================================
+// ==============================================================================
+// MESSAGE
+// ==============================================================================
/**
-* Show message at the top-right of screen, this message will hide automatic after 3 second if you don't set time
-* @param message is message
-* @param time is time the message will hide after showed. Default is 3 second, set time is 0 if you don't want to hide this message
-*/
+ * Show message at the top-right of screen, this message will hide automatic
+ * after 3 second if you don't set time
+ *
+ * @param message
+ * is message
+ * @param time
+ * is time the message will hide after showed. Default is 3 second,
+ * set time is 0 if you don't want to hide this message
+ */
function showErrorMessage( message, time )
{
jQuery.growlUI( i18n_error, message, 'error', time );
}
/**
-* Show message at the top-right of screen, this message will hide automatic after 3 second if you don't set time
-* @param message is message
-* @param time is time the message will hide after showed. Default is 3 second, set time is 0 if you don't want to hide this message
-*/
+ * Show message at the top-right of screen, this message will hide automatic
+ * after 3 second if you don't set time
+ *
+ * @param message
+ * is message
+ * @param time
+ * is time the message will hide after showed. Default is 3 second,
+ * set time is 0 if you don't want to hide this message
+ */
function showSuccessMessage( message, time )
{
jQuery.growlUI( i18n_success, message, 'success', time );
}
/**
-* Show message at the top-right of screen, this message will hide automatic after 3 second if you don't set time
-* @param message is message
-* @param time is time the message will hide after showed. Default is 3 second, set time is 0 if you don't want to hide this message
-*/
+ * Show message at the top-right of screen, this message will hide automatic
+ * after 3 second if you don't set time
+ *
+ * @param message
+ * is message
+ * @param time
+ * is time the message will hide after showed. Default is 3 second,
+ * set time is 0 if you don't want to hide this message
+ */
function showWarningMessage( message, time )
{
jQuery.growlUI( i18n_warning, message, 'warning', time );
@@ -1183,12 +1289,12 @@
}
-//=================================================================================
-// GUI
-//=================================================================================
+// =================================================================================
+// GUI
+// =================================================================================
/**
- * Clock screen by mask *
+ * Clock screen by mask *
*/
function lockScreen()
{
@@ -1203,7 +1309,7 @@
} });
}
/**
- * unClock screen *
+ * unClock screen *
*/
function unLockScreen()
{
@@ -1249,8 +1355,7 @@
unLockScreen();
}
/**
- * Removes the opacity div from the document.
-function deleteDivEffect()
+ * Removes the opacity div from the document. function deleteDivEffect()
*/
function deleteDivEffect()
{
@@ -1280,8 +1385,7 @@
}
/**
- * Used to export PDF file by the given type and
- * the active items in table
+ * Used to export PDF file by the given type and the active items in table
*/
function exportPdfByType( type )
{
@@ -1290,8 +1394,8 @@
}
/**
- * Displays the div with the first argument id, and hides the divs with ids in
- * the second array argument, except the id given in the first argument.
+ * Displays the div with the first argument id, and hides the divs with ids in
+ * the second array argument, except the id given in the first argument.
*/
function displayDiv( divId, divIds ) {
$( "#" + divId ).show();
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserAccountForm.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserAccountForm.js 2011-03-14 09:46:14 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/useraccount/updateUserAccountForm.js 2011-03-15 14:49:49 +0000
@@ -1,5 +1,7 @@
-jQuery(document).ready(function()
+jQuery( document ).ready( function()
{
+ var r = getValidationRules();
+
/* validation */
var rules = {
oldPassword : {
@@ -8,7 +10,7 @@
rawPassword : {
required : false,
password : true,
- rangelength : [ 8, 35 ],
+ rangelength : r.user.password.length,
notequalto : '#username'
},
retypePassword : {
@@ -17,54 +19,57 @@
},
surname : {
required : true,
- minlength : 2
+ rangelength : r.user.name.length
},
firstName : {
required : true,
- minlength : 2
+ rangelength : r.user.name.length
},
email : {
- email : true
+ email : true,
+ rangelength : r.user.email.length
},
- phoneNumber : {}
+ phoneNumber : {
+ rangelength : r.user.phone.length
+ }
}
- validation2('updateUserinforForm', updateUser, {
+ validation2( 'updateUserinforForm', updateUser, {
'rules' : rules
- });
+ } );
- jQuery("#rawPassword").attr("maxlength", "35");
- jQuery("#retypePassword").attr("maxlength", jQuery("#rawPassword").attr("maxlength"));
- jQuery("#surname").attr("maxlength", "140");
- jQuery("#firstName").attr("maxlength", "140");
- jQuery("#email").attr("maxlength", "160");
- jQuery("#phoneNumber").attr("maxlength", "80");
+ jQuery( "#rawPassword" ).attr( "maxlength", r.user.password.length[1] );
+ jQuery( "#retypePassword" ).attr( "maxlength", r.user.password.length[1] );
+ jQuery( "#surname" ).attr( "maxlength", r.user.name.length[1] );
+ jQuery( "#firstName" ).attr( "maxlength", r.user.name.length[1] );
+ jQuery( "#email" ).attr( "maxlength", r.user.email.length[1] );
+ jQuery( "#phoneNumber" ).attr( "maxlength", r.user.phone.length[1] );
/* end validation */
- var oldPassword = byId('oldPassword');
+ var oldPassword = byId( 'oldPassword' );
oldPassword.select();
oldPassword.focus();
-});
+} );
function updateUser()
{
var request = new Request();
- request.setResponseTypeXML('xmlObject');
- request.setCallbackSuccess(updateUserReceived);
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( updateUserReceived );
- var params = "id=" + byId('id').value;
- params += "&oldPassword=" + byId('oldPassword').value;
- params += "&rawPassword=" + byId('rawPassword').value;
- params += "&retypePassword=" + byId('retypePassword').value;
- params += "&surname=" + byId('surname').value;
- params += "&firstName=" + byId('firstName').value;
- params += "&email=" + byId('email').value;
- params += "&phoneNumber=" + byId('phoneNumber').value;
- request.sendAsPost(params);
- request.send('updateUserAccount.action');
+ var params = "id=" + byId( 'id' ).value;
+ params += "&oldPassword=" + byId( 'oldPassword' ).value;
+ params += "&rawPassword=" + byId( 'rawPassword' ).value;
+ params += "&retypePassword=" + byId( 'retypePassword' ).value;
+ params += "&surname=" + byId( 'surname' ).value;
+ params += "&firstName=" + byId( 'firstName' ).value;
+ params += "&email=" + byId( 'email' ).value;
+ params += "&phoneNumber=" + byId( 'phoneNumber' ).value;
+ request.sendAsPost( params );
+ request.send( 'updateUserAccount.action' );
}
function updateUserReceived( xmlObject )
{
- setMessage(xmlObject.firstChild.nodeValue);
+ setMessage( xmlObject.firstChild.nodeValue );
}
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/validationRules.json'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/validationRules.json 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/validationRules.json 2011-03-15 14:49:49 +0000
@@ -0,0 +1,36 @@
+{
+ "user": {
+ "name": {
+ "length": [2,140]
+ },
+ "username": {
+ "length": [2,140],
+ "firstletteralphabet" : true,
+ "alphanumeric" : true
+ },
+ "password": {
+ "length": [8,35]
+ },
+ "email": {
+ "length": [0,160]
+ },
+ "phone": {
+ "length": [0,80]
+ }
+ },
+ "role": {
+ "name": {
+ "length": [2,140]
+ },
+ "description": {
+ "length": [2,210]
+ }
+ },
+ "userGroup": {
+ "name": {
+ "length": [2,210],
+ "alphanumericwithbasicpuncspaces" : true,
+ "firstletteralphabet" : true
+ }
+ }
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addRoleForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addRoleForm.js 2011-03-14 21:10:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addRoleForm.js 2011-03-15 14:49:49 +0000
@@ -2,13 +2,16 @@
{
jQuery( "#name" ).focus();
+ var r = getValidationRules();
+
var rules = {
name : {
required : true,
- minlength : 2
+ rangelength : r.role.name.length
},
description : {
- required : true
+ required : true,
+ rangelength : r.role.description.length
}
}
@@ -21,10 +24,11 @@
'rules' : rules
} );
- jQuery( "#name" ).attr( "maxlength", "140" );
+ jQuery( "#name" ).attr( "maxlength", r.role.name.length[1] );
+ jQuery( "#description" ).attr( "maxlength", r.role.description.length[1] );
/* remote validation */
checkValueIsExist( "name", "validateRole.action" );
- sortList('availableListAuthority','ASC');
+ sortList( 'availableListAuthority', 'ASC' );
} );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserForm.js 2011-03-14 21:10:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserForm.js 2011-03-15 14:49:49 +0000
@@ -1,17 +1,19 @@
jQuery( document ).ready( function()
{
+ var r = getValidationRules();
+
var rules = {
username : {
required : true,
- firstletteralphabet : true,
- minlength : 2,
- alphanumeric : true
+ firstletteralphabet : r.user.username.firstletteralphabet,
+ alphanumeric : r.user.username.alphanumeric,
+ rangelength : r.user.username.length
},
rawPassword : {
- required : false,
+ required : true,
password : true,
- rangelength : [ 8, 35 ],
- notequalto : '#username'
+ notequalto : '#username',
+ rangelength : r.user.password.length
},
retypePassword : {
required : true,
@@ -19,16 +21,19 @@
},
surname : {
required : true,
- minlength : 2
+ rangelength : r.user.name.length
},
firstName : {
required : true,
- minlength : 2
+ rangelength : r.user.name.length
},
email : {
- email : true
- },
- phoneNumber : {},
+ email : true,
+ rangelength : r.user.email.length
+ },
+ phoneNumber : {
+ rangelength : r.user.phone.length
+ },
roleValidator : {
required : true
}
@@ -45,13 +50,13 @@
'rules' : rules
} );
- jQuery( "#username" ).attr( "maxlength", "140" );
- jQuery( "#rawPassword" ).attr( "maxlength", "35" );
- jQuery( "#retypePassword" ).attr( "maxlength", jQuery( "#rawPassword" ).attr( "maxlength" ) );
- jQuery( "#surname" ).attr( "maxlength", "140" );
- jQuery( "#firstName" ).attr( "maxlength", "140" );
- jQuery( "#email" ).attr( "maxlength", "160" );
- jQuery( "#phoneNumber" ).attr( "maxlength", "80" );
+ jQuery( "#username" ).attr( "maxlength", r.user.username.length[1] );
+ jQuery( "#rawPassword" ).attr( "maxlength", r.user.password.length[1] );
+ jQuery( "#retypePassword" ).attr( "maxlength", r.user.password.length[1] );
+ jQuery( "#surname" ).attr( "maxlength", r.user.name.length[1] );
+ jQuery( "#firstName" ).attr( "maxlength", r.user.name.length[1] );
+ jQuery( "#email" ).attr( "maxlength", r.user.email.length[1] );
+ jQuery( "#phoneNumber" ).attr( "maxlength", r.user.phone.length[1] );
/* remote validation */
checkValueIsExist( "username", "validateUser.action" );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserGroupForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserGroupForm.js 2011-03-14 21:10:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/addUserGroupForm.js 2011-03-15 14:49:49 +0000
@@ -1,11 +1,13 @@
jQuery( document ).ready( function()
{
+ var r = getValidationRules();
+
var rules = {
name : {
required : true,
- minlength : 2,
- alphanumericwithbasicpuncspaces : true,
- firstletteralphabet : true
+ alphanumericwithbasicpuncspaces : r.userGroup.name.alphanumericwithbasicpuncspaces,
+ firstletteralphabet : r.userGroup.name.firstletteralphabet,
+ rangelength : r.userGroup.name.length
},
memberValidator : {
required : true
@@ -23,7 +25,7 @@
'rules' : rules
} );
- jQuery( "#name" ).attr( "maxlength", "210" );
+ jQuery( "#name" ).attr( "maxlength", r.userGroup.name.length[1] );
/* remote validation */
checkValueIsExist( "name", "validateUserGroup.action" );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateRoleForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateRoleForm.js 2011-03-14 21:10:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateRoleForm.js 2011-03-15 14:49:49 +0000
@@ -2,13 +2,16 @@
{
jQuery( "#name" ).focus();
+ var r = getValidationRules();
+
var rules = {
name : {
required : true,
- minlength : 2
+ rangelength : r.role.name.length
},
description : {
- required : true
+ required : true,
+ rangelength : r.role.description.length
}
};
@@ -21,7 +24,8 @@
'rules' : rules
} );
- jQuery( "#name" ).attr( "maxlength", "140" );
+ jQuery( "#name" ).attr( "maxlength", r.role.name.length[1] );
+ jQuery( "#description" ).attr( "maxlength", r.role.description.length[1] );
/* remote validation */
checkValueIsExist( "name", "validateRole.action", {
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserForm.js 2011-03-14 21:10:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserForm.js 2011-03-15 14:49:49 +0000
@@ -1,27 +1,33 @@
jQuery( document ).ready( function()
{
+ var r = getValidationRules();
+
var rules = {
rawPassword : {
- rangelength : [ 8, 35 ],
password : true,
- notequalto : '#username'
+ notequalto : '#username',
+ rangelength : r.user.password.length
},
retypePassword : {
- rangelength : [ 8, 35 ],
- equalTo : '#rawPassword'
+ required : false,
+ equalTo : '#rawPassword',
+ rangelength : r.user.password.length
},
surname : {
required : true,
- minlength : 2
+ rangelength : r.user.name.length
},
firstName : {
required : true,
- minlength : 2
+ rangelength : r.user.name.length
},
email : {
- email : true
- },
- phoneNumber : {},
+ email : true,
+ rangelength : r.user.email.length
+ },
+ phoneNumber : {
+ rangelength : r.user.phone.length
+ },
roleValidator : {
required : true
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserGroupForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserGroupForm.js 2011-03-14 21:10:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/webapp/dhis-web-maintenance-user/javascript/updateUserGroupForm.js 2011-03-15 14:49:49 +0000
@@ -1,13 +1,15 @@
jQuery( document ).ready( function()
{
+ var r = getValidationRules();
+
var rules = {
- 'name' : {
+ name : {
required : true,
- minlength : 2,
- alphanumericwithbasicpuncspaces : true,
- firstletteralphabet : true
+ alphanumericwithbasicpuncspaces : r.userGroup.name.alphanumericwithbasicpuncspaces,
+ firstletteralphabet : r.userGroup.name.firstletteralphabet,
+ rangelength : r.userGroup.name.length
},
- 'memberValidator' : {
+ memberValidator : {
required : true
}
};
@@ -23,5 +25,5 @@
'rules' : rules
} );
- jQuery( "#name" ).attr( "maxlength", "210" );
+ jQuery( "#name" ).attr( "maxlength", r.userGroup.name.length[1] );
} );