]> source.dussan.org Git - archiva.git/commitdiff
use the new bulk update mode
authorOlivier Lamy <olamy@apache.org>
Mon, 29 Apr 2013 12:22:01 +0000 (12:22 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 29 Apr 2013 12:22:01 +0000 (12:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1476990 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js

index 184cbb263f41350292afc2a82ec05b95fadd01da..c27fd258084c6b0d662e8b22e0c308d7e1d40f20 100644 (file)
@@ -1643,39 +1643,44 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
         $.log("save modifiesLdapGroupMappings");
         var message=$.i18n.prop('redback-runtime-ldap-group-mapping.updated');
         var userMessages=$("#user-messages");
+        var ldapGroupMappings=[];
         $.each(self.modifiesLdapGroupMappings(),function(idx,item){
-          if(!(item.automatic&item.roleNames().length<2)){
 
-            userMessages.empty();
+          if(!(item.automatic&item.roleNames().length<2)){
             $.log("update mapping for group:"+item.group());
-            var mainContent=$("#main-content");
-            var saveButton = mainContent.find("#redback-runtime-configuration-save" );
-            saveButton.button('loading');
-            userMessages.html(mediumSpinnerImg());
-            $.ajax("restServices/redbackServices/ldapGroupMappingService",
-                   {
-                     type: "POST",
-                     contentType: 'application/json',
-                     data:ko.toJSON(item),
-                     dataType: 'json',
-                     success: function(data) {
-                       userMessages.html($.tmpl($("#alert-message-success").html(), { "message" : message }));
-                     },
-                     error: function(data) {
-                       var res = $.parseJSON(data.responseText);
-                       displayRestError(res);
-                     },
-                     complete:function(data){
-                       removeMediumSpinnerImg(userMessages);
-                       saveButton.button('reset');
-                       self.redbackRuntimeConfiguration().modified(false);
-                       self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
-                     }
-                   }
-            );
+            ldapGroupMappings.push(item);
           }
         });
 
+        if (ldapGroupMappings.length>0){
+
+          var mainContent=$("#main-content");
+          var saveButton = mainContent.find("#redback-runtime-configuration-save" );
+          saveButton.button('loading');
+          userMessages.html(mediumSpinnerImg());
+          $.ajax("restServices/redbackServices/ldapGroupMappingService",
+                 {
+                   type: "POST",
+                   contentType: 'application/json',
+                   data:ko.toJSON(new LdapGroupMappingUpdateRequest(ldapGroupMappings)),
+                   dataType: 'json',
+                   success: function(data) {
+                     displaySuccessMessage(message);
+                   },
+                   error: function(data) {
+                     var res = $.parseJSON(data.responseText);
+                     displayRestError(res);
+                   },
+                   complete:function(data){
+                     removeMediumSpinnerImg(userMessages);
+                     saveButton.button('reset');
+                     self.redbackRuntimeConfiguration().modified(false);
+                     self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
+                   }
+                 }
+          );
+        }
+
 
       } else {
         $.log("not save modifiesLdapGroupMappings");
@@ -2013,6 +2018,10 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
     this.update=true;
   }
 
+  LdapGroupMappingUpdateRequest=function(ldapGroupMappings){
+    this.ldapGroupMappings=ko.observableArray(ldapGroupMappings?ldapGroupMappings:[]);
+  }
+
   mapLdapGroupMappings=function(data,modifyLdapGroupMapping){
     if(data!=null){
       return $.map(data,function(item){