add validation for ldap form

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1425383 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-23 00:23:33 +00:00
parent b4b64ec49f
commit 82147d6b4a
2 changed files with 49 additions and 10 deletions

View File

@ -1414,6 +1414,23 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
if (valid==false) {
return;
}
var useLdap = false;
for(var i=0;i<self.usedUserManagerImpls().length;i++){
var beanId=self.usedUserManagerImpls()[i].beanId;
$.log("beanId:"+beanId);
if(beanId=='ldap'){
useLdap=true;
}
}
$.log("useLdap:"+useLdap);
if(useLdap==true) {
valid = mainContent.find("#redback-runtime-ldap-form-id").valid();
$.log("ldap valid:"+valid);
if (valid==false) {
return;
}
}
$.log("saveRedbackRuntimeConfiguration");
var saveButton = mainContent.find("#redback-runtime-configuration-save" );
saveButton.button('loading');
@ -1495,6 +1512,27 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
});
}
activateLdapConfigurationFormValidation=function(){
var formSelector=$("#main-content" ).find("#redback-runtime-ldap-form-id");
var validator = formSelector.validate({
rules: {
ldapHost : {
digits: true,
min: 1,
required: true
},
ldapPort : {
digits: true,
min: 1,
required: true
}
},
showErrors: function(validator, errorMap, errorList) {
customShowError(formSelector,validator,errorMap,errorMap);
}
});
}
displayRuntimeConfiguration=function(){
$.log("displayRuntimeConfiguration");
var mainContent = $("#main-content");
@ -1516,6 +1554,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
mainContent.html( $("#redback-runtime-configuration-main" ).tmpl() );
ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0));
activateRedbackRuntimeGeneralFormValidation();
activateLdapConfigurationFormValidation();
}
});

View File

@ -928,38 +928,38 @@
<form class="form-horizontal" id="redback-runtime-ldap-form-id">
<div class="control-group">
<label for="ldap-host" class="control-label">
<label for="ldapHost" class="control-label">
${$.i18n.prop('redback.runtime.ldap.host.label')}
</label>
<div class="controls">
<input type="text" id="ldap-host" name="ldap-host" class="input-xlarge"
<input type="text" id="ldapHost" name="ldapHost" class="input-xlarge"
data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().hostName"/>
</div>
</div>
<div class="control-group">
<label for="ldap-port" class="control-label">
<label for="ldapPort" class="control-label">
${$.i18n.prop('redback.runtime.ldap.port.label')}
</label>
<div class="controls">
<input type="text" id="ldap-port" name="ldap-port" class="input-large"
<input type="text" id="ldapPort" name="ldapPort" class="input-large"
data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().port"/>
</div>
</div>
<div class="control-group">
<label for="ldap-baseDn" class="control-label">
<label for="ldapBaseDn" class="control-label">
${$.i18n.prop('redback.runtime.ldap.baseDn.label')}
</label>
<div class="controls">
<input type="text" id="ldap-baseDn" name="ldap-baseDn" class="input-xxlarge"
<input type="text" id="ldapBaseDn" name="ldapBaseDn" class="input-xxlarge"
data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().baseDn"/>
</div>
</div>
<div class="control-group">
<label for="ldap-bindDn" class="control-label">
<label for="ldapBindDn" class="control-label">
${$.i18n.prop('redback.runtime.ldap.bindDn.label')}
</label>
<div class="controls">
<input type="text" id="ldap-bindDn" name="ldap-bindDn" class="input-xxlarge"
<input type="text" id="ldapBindDn" name="ldapBindDn" class="input-xxlarge"
data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().bindDn"/>
</div>
</div>
@ -973,11 +973,11 @@
</div>
</div>
<div class="control-group">
<label for="ldap-password" class="control-label">
<label for="ldapPassword" class="control-label">
${$.i18n.prop('redback.runtime.ldap.password.label')}
</label>
<div class="controls">
<input type="password" id="ldap-password" name="ldap-password" class="input-xlarge"
<input type="password" id="ldapPassword" name="ldapPassword" class="input-xlarge"
data-bind="value: redbackRuntimeConfiguration().ldapConfiguration().password"/>
</div>
</div>