]> source.dussan.org Git - archiva.git/commitdiff
add ldapgroup mapping UI part
authorOlivier Lamy <olamy@apache.org>
Wed, 27 Feb 2013 11:01:07 +0000 (11:01 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 27 Feb 2013 11:01:07 +0000 (11:01 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1450733 13f79535-47bb-0310-9956-ffa450edef68

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

index e63c42da197660b9f0a94de26159993257d39696..c3da4b6f6abe4bd6917a62375763c8b92311ab3d 100644 (file)
@@ -1698,6 +1698,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
       }
       self.modifiesLdapGroupMappings=ko.observableArray([]);
     }
+    this.modifiesLdapGroupMappings=ko.observableArray([]);
 
     this.modifyLdapGroupMapping=function(roleNames,ldapGroupMapping){
       var toAdd=true;
@@ -1711,6 +1712,13 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
       }
       $.log('modifyLdapGroupMapping:'+ldapGroupMapping.group()+','+self.modifiesLdapGroupMappings().length);
     };
+
+    addLdapGroupMapping=function(){
+      $.log("addLdapGroupMapping");
+      self.redbackRuntimeConfiguration().ldapGroupMappings.push(new LdapGroupMapping("",[],false,self.modifyLdapGroupMapping));
+      $("#ldap-group-mappings-div select" ).select2({width: "element"});
+    }
+
   }
 
   ManagerImplementationInformation=function(beanId,descriptionKey,readOnly){
@@ -1806,9 +1814,10 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
                 new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations,rbacManagerImplementationInformations);
 
             var groups=[];
-            $.log("before useLdap");
-            var useLdap = $.inArray("ldap",redbackRuntimeConfiguration.userManagerImpls())>0
-                    ||$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls())>0;
+            $.log("before useLdap:"+$.inArray("ldap",redbackRuntimeConfiguration.userManagerImpls())
+                          +','+$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls()));
+            var useLdap = $.inArray("ldap",redbackRuntimeConfiguration.userManagerImpls())>=0
+                    ||$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls())>=0;
             $.log("useLdap:"+useLdap);
             if(useLdap){
               // load ldap roles
@@ -1887,6 +1896,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
   }
 
   LdapGroupMapping=function(group,roleNames,automatic,subscribeFn){
+    $.log("new LdapGroupMapping");
     var self=this;
     this.modified=ko.observable(false);
     //private String group;
@@ -1894,7 +1904,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
     this.group.subscribe(function(newValue){
       self.modified(true);
       if(subscribeFn){
-        subscribeFn(newValue)
+        subscribeFn(newValue,self)
       }
     });
 
index 71cb94360ea253047cc68cb3a60f83cb460582bb..d9529948c2807e7a5216ec4a28bfd7ff10d586a7 100644 (file)
     <tbody id="ldap-group-mappings-tbody">
     {{each(i, ldapGroupMapping) ldapGroupMappings()}}
       <tr>
-        <td>${ldapGroupMapping.group()}</td>
+        <td>${ldapGroupMapping.group()}
+          <select id="roles-group-${ldapGroupMapping.group()}" data-bind="options: ldapGroups, value: ldapGroupMapping.group, optionsCaption: 'Select a LDAP Group'"
+                  size="1"></select>
+        </td>
         <td>
-          <div>
-            <select id="roles-group-${ldapGroupMapping.group()}" data-bind="options: $parent.allRoleNames, selectedOptions: ldapGroupMapping.roleNames"
-                    size="5" multiple="true" ></select>
-          </div>
-
+          <select id="roles-group-mapping-${ldapGroupMapping.group()}" data-bind="options: $parent.allRoleNames, selectedOptions: ldapGroupMapping.roleNames"
+                  size="5" multiple="true" ></select>
         </td>
       </tr>
     {{/each}}
     </tbody>
   </table>
+  <div>
+    <span class="btn btn-success">
+      <i class="icon-plus-sign icon-white" title="add mapping" data-bind="click: function(){ addLdapGroupMapping() }"/>
+    </span>
+    <table class="table table-condensed">
+      <tr>
+        <td></td>
+        <td></td>
+      </tr>
+    </table>
+  </div>
+
   </div>
 </script>