self.repositoryGroup.repositories(repositories);
self.repositoryGroup.modified(true);
}
+
this.saveRepositoryGroup=function(repositoryGroup){
if (self.update){
self.repositoryGroupsViewModel.saveRepositoryGroup(repositoryGroup);
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(){
this.managedRepositories=ko.observableArray([]);
this.applicationUrl="";
+ this.removeFromList=function(managedRepository){
+ $.log("removeFromList");
+ }
+
this.findManagedRepository=function(id){
return findManagedRepository(id,self.managedRepositories());
}
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"));
}
});
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();
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"));
<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>
<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>
</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>
</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>