this.repositoryGroup=repositoryGroup;
this.update=update;
this.repositoryGroupsViewModel=repositoryGroupsViewModel;
+ this.availableRepositories=ko.observableArray([]);
+
+ for (var i=0;i<repositoryGroupsViewModel.managedRepositories().length;i++){
+ if ( $.inArray(repositoryGroupsViewModel.managedRepositories()[i].id(),this.repositoryGroup.repositories())<0){
+ this.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
+ }
+ }
repositoryMoved=function(arg){
$.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
self.repositoryGroup.modified(true);
}
this.saveRepositoryGroup=function(repositoryGroup){
- self.repositoryGroupsViewModel.saveRepositoryGroup(repositoryGroup);
+ if (self.update){
+ self.repositoryGroupsViewModel.saveRepositoryGroup(repositoryGroup);
+ } else {
+ $.log("addRepository group");
+ }
+ }
+
+ this.removeRepository=function(id){
+ $.log("removeRepository:"+id);
}
}
mappedRepositoryGroups[i]
.managedRepositories(self.mapManagedRepositoriesToRepositoryGroup(mappedRepositoryGroups[i]));
mappedRepositoryGroups[i].modified(false);
+ $.log("mappedRepositoryGroups.repositories().length:"+mappedRepositoryGroups[i].repositories().length);
}
mainContent.html($("#repositoryGroupsMain").tmpl());
self.repositoryGroupsViewModel.repositoryGroups(mappedRepositoryGroups);
+ $.log("displayRepositoryGroups#applyBindings before");
ko.applyBindings(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();
+ var repositoryGroupViewModel=new RepositoryGroupViewModel(repositoryGroup,false,self);
+ activateRepositoryGroupEditTab();
+ ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
+ }
+ if ($(e.target).attr("href")=="#repository-groups-view") {
+ mainContent.find("#repository-groups-view-tabs-li-edit a").html($.i18n.prop("add"));
+ clearUserMessages();
+ }
+
+ });
}
}
});
this.mapManagedRepositoriesToRepositoryGroup=function(repositoryGroup){
- var managedRepositories=[];
+ $.log("mapManagedRepositoriesToRepositoryGroup");
+ var managedRepositories=new Array();
+ if (!repositoryGroup.repositories()) {
+ repositoryGroup.repositories(new Array());
+ return managedRepositories;
+ }
for(var i=0;i<repositoryGroup.repositories().length;i++){
managedRepositories.push(self.repositoryGroupsViewModel.findManagedRepository(repositoryGroup.repositories()[i]));
}
+ $.log("end mapManagedRepositoriesToRepositoryGroup");
return managedRepositories;
}
</div>
<ul id="repository-groups-view-tabs" class="nav nav-tabs">
<li id="repository-groups-view-tabs-li-grid" class="active">
- <a data-toggle="tab" href="#repository-groups-view" id="repository-groups-view-tabs-a-network-proxies-grid">${$.i18n.prop('repository-groups.grid.tab.title')}</a>
+ <a data-toggle="tab" href="#repository-groups-view" id="repository-groups-view-tabs-a-network-proxies-grid">
+ ${$.i18n.prop('repository-groups.grid.tab.title')}
+ </a>
</li>
<li id="repository-groups-view-tabs-li-edit">
<a data-toggle="tab" href="#repository-groups-edit" id="repository-groups-view-tabs-a-edit">${$.i18n.prop('add')}</a>
</ul>
<div id="repository-groups-view-tabs-content" class="tab-content">
- <div id="repository-groups-view" class="tab-pane active">
- <div id="repository-groups-table" data-bind='template:{name:"repository-groups-table-tmpl"}'>
- </div>
- </div>
- <div id="repository-groups-edit" class="tab-pane active">
- <div id="repository-groups-edit-div" data-bind='template:{name:"repository-group-edit-tmpl"}'></div>
- <div id="repository-groups-edit-order-div"
- data-bind="sortable: { template: 'repository-group-edit-order-tmpl',data:repositoryGroup.managedRepositories,afterMove: repositoryMoved}">
- </div>
- </div>
- </div>
+ <div id="repository-groups-view" class="tab-pane active">
+ <div id="repository-groups-table" data-bind='template:{name:"repository-groups-table-tmpl"}'>
+ </div>
+ </div>
+ <div id="repository-groups-edit" class="tab-pane">
+ <div class="row-fluid">
+ <div class="span5 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}">
+ </div>
+ </div>
+
+ <div class="span5 dotted">
+ <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}">
+
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+
+ </div>
</script>
<script id="repository-groups-table-tmpl" type="text/html">
</script>
<script id="repository-group-edit-order-tmpl" type="text/html">
- <div class="well draggable-item span6">
+ <div class="well draggable-item">
<blockquote>
${$data.id()}
<br/>
${$data.name()}
<br/>
- ${window.archivaRuntimeInfo.baseUrl}/repository/${$data.id()}
+ <a href="${window.archivaRuntimeInfo.baseUrl}/repository/${$data.id()}" target="_blank">
+ ${window.archivaRuntimeInfo.baseUrl}/repository/${$data.id()}
+ </a>
<br/>
</blockquote>