]> source.dussan.org Git - archiva.git/commitdiff
fix issue with webkit for users role assignement double list
authorOlivier Lamy <olamy@apache.org>
Thu, 5 Jan 2012 15:45:09 +0000 (15:45 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 5 Jan 2012 15:45:09 +0000 (15:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1227643 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-debug.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/roles.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java

index 7264fc5164e67ca9b298b4b0e7132b46461b0f60..f1743db1d83dcf3ea6272085846a6ddfec35f59e 100644 (file)
@@ -160,6 +160,8 @@ $(function() {
   hideElementWithKarma();
   checkSecurityLinks();
 
+
+
 })
 });
 
index 56ce31566d8a5117d71e804272c851fdb56d26f8..416a6818a756a8d3e9e5f1a1444abc7c457d7976 100644 (file)
@@ -1021,7 +1021,7 @@ ko.observableArray['fn'] = {
 \r
 // Populate ko.observableArray.fn with read/write functions from native arrays\r
 ko.utils.arrayForEach(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function (methodName) {\r
-    ko.observableArray['fn'][methodName] = function () { \r
+    ko.observableArray['fn'][methodName] = function () {\r
         var underlyingArray = this();\r
         this.valueWillMutate();\r
         var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);\r
index f5bd67b285a08792a0aa2c68152fa5a51f924629..40af9865faf3e0cdcf489a38d3bfa0cda2d72af7 100644 (file)
@@ -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(){
index 9b630d5ed690ca6cc9287e3b884c101cd0d8f097..b6c9c506f86c8e5cbabf03c92816f2c6e4561c39 100644 (file)
       ${$.i18n.prop('role.edit.no.user.defined')}
     {{/if}}
 
-    <button class="btn" data-bind="click:updateMode">${$.i18n.prop('role.update.mode')}</button>
+    <input class="btn" type="button" id="role-list-users-update-mode" data-bind="click: updateMode" value="${$.i18n.prop('role.update.mode')}"/>
 
   </div>
 
     </div>
     <div class="ar-multiselect-column ar-multiselect-center">
     <ul style="list-style: none">
-      <li><button class="btn" data-bind="click: addUser">&gt;</button></li>
-      <li><button class="btn" data-bind="click: removeUser">&lt;</button></li>
+      <li><input class="btn" id="role-edit-users-add-user" type="button" data-bind="click: addUser" value="&gt;"/></li>
+      <li><input class="btn" id="role-edit-users-remove-user" type="button" data-bind="click: removeUser" value="&lt;"/></li>
     </ul>
     </div>
     <div class="ar-multiselect-column ar-multiselect-right">
       <select data-bind="options: users ,optionsText: 'username',selectedOptions:selectedUsers" multiple="true" id="role-edit-affected-users"></select>
     </div>
-    <button class="btn" data-bind="click: saveUsers">${$.i18n.prop('save')}</button>
+    <button class="btn" id="role-edit-users-save" data-bind="click: saveUsers">${$.i18n.prop('save')}</button>
     <br/>
-    <button class="btn" data-bind="click:viewMode">${$.i18n.prop('role.view.mode')}</button>
+    <input class="btn" id="role-edit-users-view-mode" type="button" data-bind="click: viewMode" value="${$.i18n.prop('role.view.mode')}"/>
   </div>
 
 </script>
 
 
+
+
 <script id='ko_rolesGrid' type='text/x-jquery-tmpl'>
   <thead>
       <tr>
index 03d88395d48e44519eccd8d6a8c30c3561427d3b..c0d7e409eabbf9c6ce2074166a3dd0cce565454f 100644 (file)
@@ -73,6 +73,7 @@ public abstract class AbstractSeleniumTest
             if ( getSelenium() == null )
             {
                 DefaultSelenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
+
                 s.start();
                 s.setTimeout( maxWaitTimeInMs );
                 selenium.set( s );