move user edition to tab too

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1220290 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-12-17 22:43:40 +00:00
parent 413430a449
commit 5c94157a44
3 changed files with 29 additions and 16 deletions

View File

@ -94,7 +94,7 @@
<li class="active" id="users-view-tabs-li-users-grid">
<a href="#users-view">Users</a>
</li>
<li>
<li id="users-view-tabs-li-user-edit">
<a href="#createUserForm">Add User</a>
</li>
</ul>

View File

@ -65,12 +65,7 @@ $(function() {
window.redbackModel.usersViewModel.users.push(currentUser);
clearForm("#main-content #user-create");
$("#main-content #user-create").hide();
$("#main-content #users-view-tabs li").removeClass("active");
$("#main-content #users-view-tabs-content div").removeClass("active");
// activate users grid tab
$("#main-content #users-view-tabs-content #users-view").addClass("active");
$("#users-view-tabs-li-users-grid").addClass("active");
activateUsersGridTab();
return this;
} else {
displayErrorMessage("user cannot created");
@ -152,7 +147,7 @@ $(function() {
if (created == true) {
displaySuccessMessage("user updated:"+currentUser.username());
clearForm("#main-content #user-create");
$("#main-content #user-create").hide();
activateUsersGridTab();
return this;
} else {
displayErrorMessage("user cannot be updated");
@ -168,7 +163,7 @@ $(function() {
this.save=function(){
$.log("user.save create:"+window.redbackModel.createUser);
if (window.redbackModel.createUser==true){
var valid = $("#main-content #createUserForm #user-create").valid();
var valid = $("#main-content #user-create").valid();
if (valid==false) {
$.log("user#save valid:false");

View File

@ -62,7 +62,7 @@ $(function() {
ko.renderTemplate("redback/user-edit-tmpl", new user(), null, $("#createUserForm").get(0),"replaceChildren");
$("#main-content #createUserForm #user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
e.preventDefault();
$('#user-create').hide();
activateUsersGridTab();
});
$("#user-create").validate({
rules: {
@ -110,20 +110,23 @@ $(function() {
this.editUserBox=function(user) {
window.redbackModel.createUser=false;
clearUserMessages();
$("#main-content #user-edit").remove();
//$("#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}');
$("#main-content #user-create").remove();
$("#main-content #user-edit").show();
//$("#main-content #user-edit").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}');
$("#main-content #createUserForm").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}');
//$("#main-content #user-create").remove();
//$("#main-content #user-edit").show();
var viewModel = new userViewModel(user);
ko.applyBindings(viewModel,$("#main-content #user-edit").get(0));
ko.applyBindings(viewModel,$("#main-content #createUserForm").get(0));
activateUsersEditTab();
$("#main-content #user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
e.preventDefault();
$('#main-content #user-create').remove();
activateUsersGridTab();
});
$("#main-content #user-create").validate({
@ -173,6 +176,21 @@ $(function() {
this.user=user;
}
activateUsersGridTab=function(){
$("#main-content #users-view-tabs li").removeClass("active");
$("#main-content #users-view-tabs-content div").removeClass("active");
// activate users grid tab
$("#main-content #users-view-tabs-content #users-view").addClass("active");
$("#users-view-tabs-li-users-grid").addClass("active");
}
activateUsersEditTab=function(){
$("#main-content #users-view-tabs li").removeClass("active");
$("#main-content #users-view-tabs-content div").removeClass("active");
// activate users edit tab
$("#main-content #users-view-tabs-content #createUserForm").addClass("active");
$("#users-view-tabs-li-user-edit").addClass("active");
}
$(document).ready(function() {