]> source.dussan.org Git - archiva.git/commitdiff
call REST to un/assign users to a role
authorOlivier Lamy <olamy@apache.org>
Wed, 4 Jan 2012 08:50:43 +0000 (08:50 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 4 Jan 2012 08:50:43 +0000 (08:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1227082 13f79535-47bb-0310-9956-ffa450edef68

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

index c72a93a0ed35ef32131492820292b33392fc11e0..ec1b22e7264c4b6ce5d2c74751dbd2ee9dad6887 100644 (file)
@@ -29,6 +29,7 @@ $(function() {
     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.updateDescription=function(){
       var url = "restServices/redbackServices/roleManagementService/updateRoleDescription?";
@@ -49,6 +50,23 @@ $(function() {
         }
       );
     }
+    this.updateUsers=function(){
+      var url = "restServices/redbackServices/roleManagementService/updateRoleUsers";
+      $.ajax(url,
+        {
+          type: "POST",
+          dataType: 'json',
+          contentType: 'application/json',
+          data: "{\"role\": " +  ko.toJSON(this)+"}",
+          success: function(data) {
+            displaySuccessMessage($.i18n.prop("role.users.updated",this.name));
+          },
+          error: function(data){
+            displayErrorMessage("error updating users role");
+          }
+        }
+      );
+    }
   }
 
   /**
@@ -145,13 +163,18 @@ $(function() {
       var added = currentRole.users.removeAll(selectedUsers());
       for (var i = 0; i < added.length; i++) {
         currentRole.otherUsers.push(added[i]);
+        currentRole.removedUsers.push(added[i]);
       }
       selectedUsers([]);
+
     }
     saveRoleDescription=function(){
       $.log("saveRoleDescription:"+currentRole.description());
       currentRole.updateDescription();
     }
+    saveUsers=function(){
+      currentRole.updateUsers();
+    }
   }
 
   /**
index 103443ba899edb770124eab688a1b1e447c620df..79e3841decf35f997adbc6bd92e60f629fec2848 100644 (file)
     <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>
   </div>
 
 </script>