in case of long list repositories configuring group can be a pain with drag&drop

so add a button on repos to setup group.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1411156 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-11-19 12:50:07 +00:00
parent 322cf7dc30
commit d412df4dd2
3 changed files with 85 additions and 18 deletions

View File

@ -62,6 +62,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
self.repositoryGroup.repositories(repositories);
self.repositoryGroup.modified(true);
}
this.saveRepositoryGroup=function(repositoryGroup){
if (self.update){
self.repositoryGroupsViewModel.saveRepositoryGroup(repositoryGroup);
@ -73,6 +74,43 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
this.removeRepository=function(id){
$.log("removeRepository:"+id);
}
this.renderSortableAvailables=function(){
$.log("renderSortableAvailables");
//$("#main-content").find("#repository-groups-edit-available-repositories" ).find(".icon-minus-sign" ).hide();
}
this.removeChoosed=function(id){
$.log("removeChoosed:"+id);
}
this.renderSortableChoosed=function(repositoryGroupsViewModel){
$("#main-content").find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).on("click",function(){
var idVal = $(this).attr("id");
idVal=idVal.substringAfterFirst("minus-");
$.log("renderSortableChoosed:"+idVal);
for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
self.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
}
}
$.log("size before:"+self.repositoryGroup.repositories().length+","+self.repositoryGroup.managedRepositories().length);
var repositories=[];
for(var i= 0;i<self.repositoryGroup.repositories().length;i++){
if(self.repositoryGroup.repositories()[i]==idVal){
$.log("find repo to remove");
self.repositoryGroup.repositories.remove(self.repositoryGroup.repositories()[i]);
self.repositoryGroup.managedRepositories.remove(findManagedRepository(idVal,self.repositoryGroupsViewModel.managedRepositories()));
} else {
repositories.push(self.repositoryGroup.managedRepositories()[i].id());
}
}
//self.repositoryGroup.repositories(repositories);
//self.repositoryGroup.modified(true);
$.log("size after:"+self.repositoryGroup.repositories().length+","+self.repositoryGroup.managedRepositories().length);
});
}
}
RepositoryGroupsViewModel=function(){
@ -81,6 +119,10 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
this.managedRepositories=ko.observableArray([]);
this.applicationUrl="";
this.removeFromList=function(managedRepository){
$.log("removeFromList");
}
this.findManagedRepository=function(id){
return findManagedRepository(id,self.managedRepositories());
}
@ -122,6 +164,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
repositoryGroupViewModel.applicationUrl=applicationUrl;
activateRepositoryGroupEditTab();
ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
repositoryGroupViewModel.renderSortableChoosed(self);
mainContent.find("#repository-groups-view-tabs-li-edit" ).find("a").html($.i18n.prop("edit"));
}
});
@ -230,7 +273,6 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
ko.applyBindings(self.repositoryGroupsViewModel,mainContent.find("#repository-groups-view" ).get(0));
$.log("displayRepositoryGroups#applyBindings after");
mainContent.find("#repository-groups-view-tabs").on('show', function (e) {
if ($(e.target).attr("href")=="#repository-groups-edit") {
var repositoryGroup = new RepositoryGroup();
@ -238,6 +280,7 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
activateRepositoryGroupEditTab();
ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
repositoryGroupViewModel.renderSortableChoosed();
}
if ($(e.target).attr("href")=="#repository-groups-view") {
mainContent.find("#repository-groups-view-tabs-li-edit a").html($.i18n.prop("add"));

View File

@ -429,7 +429,7 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
if (idx<0){
return "";
}
return this.substring(idx);
return this.substring(idx+str.length);
}
escapeDot=function(str){

View File

@ -1182,7 +1182,7 @@
<div class="span6 dotted">
<div id="repository-groups-edit-div" data-bind='template:{name:"repository-group-edit-tmpl"}'></div>
<div id="repository-groups-edit-order-div" style="min-height: 80px"
data-bind="sortable: { template: 'repository-group-edit-order-tmpl',data:repositoryGroup.managedRepositories,afterMove:repositoryMoved}">
data-bind="sortable: { template: 'repository-group-edit-order-tmpl-choosed',data:repositoryGroup.managedRepositories,afterMove:repositoryMoved}">
</div>
</div>
@ -1190,7 +1190,7 @@
<h5>${$.i18n.prop('repository.groups.available.repositories')}</h5>
<br/>
<div id="repository-groups-edit-available-repositories" style="min-height: 80px"
data-bind="sortable: { template: 'repository-group-edit-order-tmpl',data:availableRepositories,afterMove:repositoryMoved}">
data-bind="sortable: { template: 'repository-group-edit-order-tmpl-available',data:availableRepositories,afterMove:repositoryMoved}">
</div>
</div>
@ -1202,6 +1202,44 @@
</div>
</script>
<script id="repository-group-edit-order-tmpl-choosed" type="text/html">
<div class="well draggable-item">
<span class="pull-right">
<i class="icon-minus-sign cursor-hand" id="minus-${$data.id()}"/>
</span>
<blockquote>
${$data.id()}
<br/>
${$data.name()}
<br/>
<a href="${$data.url}" target="_blank">
${$data.url}
</a>
<br/>
</blockquote>
</div>
</script>
<script id="repository-group-edit-order-tmpl-available" type="text/html">
<div class="well draggable-item">
<span class="pull-right">
<i class="icon-plus-sign" id="plus-${$data.id()}"/>
</span>
<blockquote>
${$data.id()}
<br/>
${$data.name()}
<br/>
<a href="${$data.url}" target="_blank">
${$data.url}
</a>
<br/>
</blockquote>
</div>
</script>
<script id="repository-groups-table-tmpl" type="text/html">
<table class="table table-striped table-bordered">
<thead>
@ -1285,21 +1323,7 @@
</div>
</script>
<script id="repository-group-edit-order-tmpl" type="text/html">
<div class="well draggable-item">
<blockquote>
${$data.id()}
<br/>
${$data.name()}
<br/>
<a href="${$data.url}" target="_blank">
${$data.url}
</a>
<br/>
</blockquote>
</div>
</script>
<script id="repository-group-delete-warning-tmpl" type='text/html'>
<div>