mirror of https://github.com/apache/archiva.git
fix user edit/creation form in admin part
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1213293 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
af14aada38
commit
36be4202da
|
@ -4,7 +4,7 @@
|
|||
<div class="clearfix">
|
||||
<label for="username">${i18n('username')}</label>
|
||||
<div class="input" id="username-div">
|
||||
{{if $data.username}}
|
||||
{{if $data.username.length>0}}
|
||||
<span class="uneditable-input">${$data.username}</span>
|
||||
{{else}}
|
||||
<input type="text" id="username" name="username" size="30" class="required" data-bind="value: username"/>
|
||||
|
@ -55,6 +55,6 @@
|
|||
</div>
|
||||
</fieldset>
|
||||
<button data-bind="click: save" class="btn" id="user-create-form-register-button">${i18n('save')}</button>
|
||||
<button onclick="$('#user-create').hide()" class="btn" id="user-create-form-cancel-button">${i18n('cancel')}</button>
|
||||
<button class="btn" id="user-create-form-cancel-button">${i18n('cancel')}</button>
|
||||
</form>
|
||||
</script>
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
|
||||
</script>
|
||||
|
||||
<script id="ko_usersGrid_pageLinks" type="text/x-jquery-tmpl">
|
||||
|
|
|
@ -47,6 +47,11 @@ $(function() {
|
|||
}
|
||||
};
|
||||
this.createUser = function() {
|
||||
$.log("user#createUser");
|
||||
var valid = $("#user-create").valid();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
var currentUser = this;
|
||||
$.ajax("restServices/redbackServices/userService/createUser", {
|
||||
data: "{\"user\": " + ko.toJSON(this)+"}",
|
||||
|
@ -158,7 +163,15 @@ $(function() {
|
|||
this.save=function(){
|
||||
$.log("user.save create:"+window.redbackModel.createUser);
|
||||
if (window.redbackModel.createUser==true){
|
||||
return this.create();
|
||||
var valid = $("#main-content #createUserForm #user-create").valid();
|
||||
|
||||
if (valid==false) {
|
||||
$.log("user#save valid:false");
|
||||
return;
|
||||
} else {
|
||||
$.log("user#save valid:true");
|
||||
return this.create();
|
||||
}
|
||||
} else {
|
||||
return this.update();
|
||||
}
|
||||
|
|
|
@ -54,12 +54,12 @@ $(function() {
|
|||
});
|
||||
|
||||
this.addUser=function() {
|
||||
screenChange();
|
||||
clearUserMessages();
|
||||
window.redbackModel.createUser=true;
|
||||
$("#main-content #user-edit").remove();
|
||||
$('#main-content #user-create').show();
|
||||
ko.renderTemplate("redback/user-edit-tmpl", new user(), null, $("#createUserForm").get(0),"replaceChildren");
|
||||
$("#user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
|
||||
$("#main-content #createUserForm #user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
|
||||
e.preventDefault();
|
||||
$('#user-create').hide();
|
||||
});
|
||||
|
@ -73,13 +73,8 @@ $(function() {
|
|||
customShowError(validator,errorMap,errorMap);
|
||||
}
|
||||
});
|
||||
$("#createUserForm #user-create").delegate("#user-create-form-save-button", "click keydown", function(e) {
|
||||
$("#main-content #createUserForm #user-create").delegate("#user-create-form-register-button", "click keydown", function(e) {
|
||||
e.preventDefault();
|
||||
var valid = $("#user-create").valid();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
user.createUser();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -110,7 +105,7 @@ $(function() {
|
|||
|
||||
this.editUserBox=function(user) {
|
||||
window.redbackModel.createUser=false;
|
||||
screenChange();
|
||||
clearUserMessages();
|
||||
$("#main-content #user-edit").remove();
|
||||
$("#main-content").append("<div id='user-edit'></div>");
|
||||
$("#main-content #user-edit").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}');
|
||||
|
@ -120,20 +115,13 @@ $(function() {
|
|||
var viewModel = new userViewModel(user);
|
||||
|
||||
ko.applyBindings(viewModel,$("#main-content #user-edit").get(0));
|
||||
jQuery("#main-content #user-create").validate({
|
||||
rules: {
|
||||
confirmPassword: {
|
||||
equalTo: "#password"
|
||||
}
|
||||
},
|
||||
showErrors: function(validator, errorMap, errorList) {
|
||||
customShowError(validator,errorMap,errorMap);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#main-content #user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
|
||||
e.preventDefault();
|
||||
$('#main-content #user-create').remove();
|
||||
});
|
||||
|
||||
$("#main-content #user-create").validate({
|
||||
rules: {
|
||||
confirmPassword: {
|
||||
|
@ -152,6 +140,7 @@ $(function() {
|
|||
}
|
||||
user.update();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue