From dbc43a4e3cc7df19bc21c5248718965fb29d89a8 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 5 Jan 2012 15:45:09 +0000 Subject: [PATCH] fix issue with webkit for users role assignement double list git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1227643 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 2 ++ .../src/main/webapp/js/knockout-debug.js | 2 +- .../src/main/webapp/js/redback/roles.js | 34 +++++++++++-------- .../js/redback/templates/roles-tmpl.html | 12 ++++--- .../web/test/parent/AbstractSeleniumTest.java | 1 + 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 7264fc516..f1743db1d 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -160,6 +160,8 @@ $(function() { hideElementWithKarma(); checkSecurityLinks(); + + }) }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-debug.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-debug.js index 56ce31566..416a6818a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-debug.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-debug.js @@ -1021,7 +1021,7 @@ ko.observableArray['fn'] = { // Populate ko.observableArray.fn with read/write functions from native arrays ko.utils.arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function (methodName) { - ko.observableArray['fn'][methodName] = function () { + ko.observableArray['fn'][methodName] = function () { var underlyingArray = this(); this.valueWillMutate(); var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js index f5bd67b28..40af9865f 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js @@ -18,7 +18,7 @@ */ $(function() { - role = function(name,description,assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers){ + Role = function(name,description,assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers){ this.name = ko.observable(name); this.description = ko.observable(description); this.assignable = ko.observable(assignable); @@ -28,8 +28,8 @@ $(function() { this.parentsRolesUsers = ko.observableArray(parentsRolesUsers);//read only this.permissions = ko.observableArray(permissions);//read only // when editing a role other users not assign to this role are populated - this.otherUsers = ko.observableArray(otherUsers); - this.removedUsers=ko.observableArray([]); + this.otherUsers = ko.observableArray(otherUsers?otherUsers:new Array()); + this.removedUsers= ko.observableArray(new Array()); this.updateDescription=function(){ var url = "restServices/redbackServices/roleManagementService/updateRoleDescription?"; @@ -50,6 +50,7 @@ $(function() { } ); } + var self=this; this.updateUsers=function(){ var url = "restServices/redbackServices/roleManagementService/updateRoleUsers"; $.ajax(url, @@ -57,7 +58,7 @@ $(function() { type: "POST", dataType: 'json', contentType: 'application/json', - data: "{\"role\": " + ko.toJSON(this)+"}", + data: "{\"role\": " + ko.toJSON(self)+"}", success: function(data) { displaySuccessMessage($.i18n.prop("role.users.updated",this.name)); }, @@ -68,14 +69,6 @@ $(function() { ); } - this.updateMode=function(){ - $("#main-content #role-list-users").hide(); - $("#main-content #role-edit-users").show(); - } - this.viewMode=function(){ - $("#main-content #role-edit-users").hide(); - $("#main-content #role-list-users").show(); - } } /** @@ -156,13 +149,15 @@ $(function() { } RoleViewModel=function(role){ - selectedOtherUsers=new ko.observableArray(); - selectedUsers=new ko.observableArray(); + selectedOtherUsers= ko.observableArray(); + selectedUsers= ko.observableArray(); currentRole=role; var self=this; addUser=function(){ + $.log("addUser"); var removed = currentRole.otherUsers.removeAll(selectedOtherUsers()); for (var i = 0; i < removed.length; i++) { + $.log("add user:"+removed[i].username()); currentRole.users.push(removed[i]); } selectedOtherUsers([]); @@ -184,6 +179,15 @@ $(function() { saveUsers=function(){ currentRole.updateUsers(); } + + updateMode=function(){ + $("#main-content #role-list-users").hide(); + $("#main-content #role-edit-users").show(); + } + viewMode=function(){ + $("#main-content #role-edit-users").hide(); + $("#main-content #role-list-users").show(); + } } /** @@ -212,7 +216,7 @@ $(function() { return mapUser(item); }):new Array(mapUser(data.otherUsers)):null; - return new role(data.name, data.description?data.description:"",data.assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers); + return new Role(data.name, data.description?data.description:"",data.assignable,childRoleNames,parentRoleNames,users,parentsRolesUsers,permissions,otherUsers); } activateRolesGridTab=function(){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html index 9b630d5ed..b6c9c506f 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html @@ -130,7 +130,7 @@ ${$.i18n.prop('role.edit.no.user.defined')} {{/if}} - + @@ -141,21 +141,23 @@
- +
- + + +