cleanup a bit no need to observe the fake mapping for add line

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1452407 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-03-04 17:15:22 +00:00
parent 315f582577
commit 919c027674
2 changed files with 37 additions and 28 deletions

View File

@ -1724,7 +1724,9 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
} }
}); });
this.newLdapGroupMapping=ko.observable(new LdapGroupMapping("",[],false,self.modifyLdapGroupMapping)); this.newLdapGroupMapping=ko.observable(new LdapGroupMapping("",[],false,null));
this.ldapSelectOptionCaption = $.i18n.prop('redback.runtime.ldap.mapping.select.group');
addLdapGroupMapping=function(){ addLdapGroupMapping=function(){
// FIXME validate datas from ldapGroupMapping // FIXME validate datas from ldapGroupMapping
@ -1740,12 +1742,11 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
{ {
type: "PUT", type: "PUT",
contentType: 'application/json', contentType: 'application/json',
data:ko.toJSON(new LdapGroupMapping(self.newLdapGroupMapping().group(),self.newLdapGroupMapping().roleNames(),false,self.modifyLdapGroupMapping)), data:ko.toJSON(new LdapGroupMapping(self.newLdapGroupMapping().group(),self.newLdapGroupMapping().roleNames(),false,null)),
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
self.redbackRuntimeConfiguration().ldapGroupMappings self.redbackRuntimeConfiguration().ldapGroupMappings
.unshift(new LdapGroupMapping(self.newLdapGroupMapping().group(),self.newLdapGroupMapping().roleNames(),false,self.modifyLdapGroupMapping)); .unshift(new LdapGroupMapping(self.newLdapGroupMapping().group(),self.newLdapGroupMapping().roleNames(),false,self.modifyLdapGroupMapping));
self.newLdapGroupMapping=ko.observable(new LdapGroupMapping("",[],false,self.modifyLdapGroupMapping));
$.log("addLdapGroupMapping:"+self.redbackRuntimeConfiguration().ldapGroupMappings().length); $.log("addLdapGroupMapping:"+self.redbackRuntimeConfiguration().ldapGroupMappings().length);
$("#ldap-group-mappings-div select" ).select2({width: "element"}); $("#ldap-group-mappings-div select" ).select2({width: "element"});
var message=$.i18n.prop('redback-runtime-ldap-group-mapping.added'); var message=$.i18n.prop('redback-runtime-ldap-group-mapping.added');
@ -1759,6 +1760,10 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
).always( ).always(
function(){ function(){
removeMediumSpinnerImg(userMessages); removeMediumSpinnerImg(userMessages);
$.log("addLdapGroupMapping#always");
//self.newLdapGroupMapping().group("");
//self.newLdapGroupMapping().roleNames([]);
self.newLdapGroupMapping=ko.observable(new LdapGroupMapping("",[],false,null));
saveButton.button('reset'); saveButton.button('reset');
} }
); );

View File

@ -1247,30 +1247,6 @@
</script> </script>
<script id="redback-runtime-ldap-mapping-grid" type="text/html">
<thead>
<tr>
<th>${$.i18n.prop('redback.runtime.ldap.mapping.group.label')}</th>
<th>${$.i18n.prop('redback.runtime.ldap.mapping.roles.label')}</th>
</tr>
</thead>
<tbody id="ldap-group-mappings-tbody">
{{each(i, ldapGroupMapping) itemsOnCurrentPage()}}
<tr>
<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>
<select id="roles-group-mapping-${ldapGroupMapping.group()}" data-bind="options: $parent.allRoleNames, selectedOptions: ldapGroupMapping.roleNames"
size="5" multiple="true" ></select>
</td>
</tr>
{{/each}}
</tbody>
</script>
<script id="redback-runtime-ldap-mapping-tmpl" type="text/html"> <script id="redback-runtime-ldap-mapping-tmpl" type="text/html">
<div class="well" id="ldap-group-mappings-div"> <div class="well" id="ldap-group-mappings-div">
<table class="table table-condensed"> <table class="table table-condensed">
@ -1289,7 +1265,7 @@
</span> </span>
</td> </td>
<td> <td>
<select data-bind="options: ldapGroups, optionsCaption: 'Select a LDAP Group',value: $parent.newLdapGroupMapping().group" size="1"> <select data-bind="options: ldapGroups,value: $parent.newLdapGroupMapping().group" size="1">
</select> </select>
</td> </td>
<td> <td>
@ -1319,6 +1295,34 @@
</div> </div>
</script> </script>
<!-- doesn't with simple grid knockout binding -->
<!--
<script id="redback-runtime-ldap-mapping-grid" type="text/html">
<thead>
<tr>
<th>${$.i18n.prop('redback.runtime.ldap.mapping.group.label')}</th>
<th>${$.i18n.prop('redback.runtime.ldap.mapping.roles.label')}</th>
</tr>
</thead>
<tbody id="ldap-group-mappings-tbody">
{{each(i, ldapGroupMapping) itemsOnCurrentPage()}}
<tr>
<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>
<select id="roles-group-mapping-${ldapGroupMapping.group()}" data-bind="options: $parent.allRoleNames, selectedOptions: ldapGroupMapping.roleNames"
size="5" multiple="true" ></select>
</td>
</tr>
{{/each}}
</tbody>
</script>
-->
<script id="redback-runtime-general-content-impl-informations" type="text/html"> <script id="redback-runtime-general-content-impl-informations" type="text/html">
<div class="well draggable-item"> <div class="well draggable-item">
${$data.description} ${$data.description}