From: Olivier Lamy Date: Mon, 29 Apr 2013 12:22:01 +0000 (+0000) Subject: use the new bulk update mode X-Git-Tag: archiva-1.4-M4~46 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bc9e7a49e641b9158f163843b6cd07884d8cfba0;p=archiva.git use the new bulk update mode git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1476990 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js index 184cbb263..c27fd2580 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js @@ -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){