better handling of repositoryId in url while browsing to make it work with history

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1366908 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-07-29 19:21:55 +00:00
parent e75ddd592e
commit 0985ccf02a
2 changed files with 67 additions and 43 deletions

View File

@ -220,9 +220,9 @@ function() {
var repositoryId = this.params.repositoryId;
$.log("repositoryId:"+repositoryId);
if (groupId){
displayBrowseGroupId(groupId);
displayBrowseGroupId(groupId,repositoryId);
} else {
displayBrowse(true);
displayBrowse(true,repositoryId);
}
});
this.get('#browse~:repositoryId',function(context){

View File

@ -23,13 +23,19 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
// browse part
//-----------------------------------------
BrowseViewModel=function(browseResultEntries,parentBrowseViewModel,groupId){
BrowseViewModel=function(browseResultEntries,parentBrowseViewModel,groupId,repositoryId){
var self=this;
this.browseResultEntries=browseResultEntries;
this.parentBrowseViewModel=parentBrowseViewModel;
this.groupId=groupId;
this.repositoryId=repositoryId;
displayGroupId=function(groupId){
window.sammyArchivaApplication.setLocation("#browse/"+groupId);
$.log("BrowseViewModel#displayGroupId,self.repositoryId:"+self.repositoryId);
if(self.repositoryId){
window.sammyArchivaApplication.setLocation("#browse~"+self.repositoryId+"/"+groupId);
} else {
window.sammyArchivaApplication.setLocation("#browse/"+groupId);
}
}
displayParentGroupId=function(){
$.log("called displayParentGroupId groupId:"+self.parentBrowseViewModel.groupId);
@ -86,7 +92,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
return breadCrumbEntries;
}
displayGroupDetail=function(groupId,parentBrowseViewModel,restUrl){
displayGroupDetail=function(groupId,parentBrowseViewModel,restUrl,repositoryId){
var mainContent = $("#main-content");
mainContent.find("#browse_artifact_detail").hide();
var browseResult=mainContent.find("#browse_result");
@ -97,7 +103,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
function(){
browseResult.html(mediumSpinnerImg());
browseBreadCrumb.html(smallSpinnerImg());
mainContent.find("#main_browse_result_content" ).show();
mainContent.find("#main_browse_result_content").show();
var url = "";
if (!restUrl) {
url="restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(groupId);
@ -105,7 +111,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
if (selectedRepo){
url+="?repositoryId="+selectedRepo;
}
}else {
} else {
url=restUrl;
}
@ -114,7 +120,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
dataType: 'json',
success: function(data) {
var browseResultEntries = mapBrowseResultEntries(data);
var browseViewModel = new BrowseViewModel(browseResultEntries,parentBrowseViewModel,groupId);
var browseViewModel = new BrowseViewModel(browseResultEntries,parentBrowseViewModel,groupId,repositoryId);
ko.applyBindings(browseViewModel,browseBreadCrumb.get(0));
ko.applyBindings(browseViewModel,browseResult.get(0));
enableAutocompleBrowse(groupId);
@ -661,36 +667,33 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
mainContent.find("#browse_artifact" ).hide();
mainContent.find("#browse_result").html(mediumSpinnerImg());
$.ajax("restServices/archivaServices/browseService/userRepositories", {
type: "GET",
dataType: 'json',
success: function(data) {
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
var url="restServices/archivaServices/browseService/rootGroups";
if(repositoryId){
url+="?repositoryId="+repositoryId;
}
$.ajax(url, {
type: "GET",
dataType: 'json',
success: function(data) {
var browseResultEntries = mapBrowseResultEntries(data);
$.log("size:"+browseResultEntries.length);
var browseViewModel = new BrowseViewModel(browseResultEntries,null,null);
ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
enableAutocompleBrowse();
}
});
userRepositoriesCall(
function(data) {
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
var url="restServices/archivaServices/browseService/rootGroups";
if(repositoryId){
url+="?repositoryId="+repositoryId;
}
});
$.ajax(url, {
type: "GET",
dataType: 'json',
success: function(data) {
var browseResultEntries = mapBrowseResultEntries(data);
$.log("size:"+browseResultEntries.length);
var browseViewModel = new BrowseViewModel(browseResultEntries,null,null,repositoryId);
ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
enableAutocompleBrowse();
}
});
}
)
}
changeBrowseRepository=function(){
var selectedRepository=getSelectedBrowsingRepository();
//$.log("changeBrowseRepository:"+selectedRepository);
//displayGroupDetail(null,null,"restServices/archivaServices/browseService/rootGroups?repositoryId="+encodeURIComponent(selectedRepository));
window.sammyArchivaApplication.setLocation("#browse~"+selectedRepository);
}
@ -827,20 +830,31 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
* called if browser url contains queryParam browse=groupId
* @param groupId
*/
displayBrowseGroupId=function(groupId){
displayBrowseGroupId=function(groupId,repositoryId){
clearUserMessages();
$.log("displayBrowseGroupId:"+groupId);
var mainContent = $("#main-content");
mainContent.html($("#browse-tmpl" ).tmpl());
mainContent.find("#browse_result").html(mediumSpinnerImg());
var parentBrowseViewModel=new BrowseViewModel(null,null,null);
displayGroupDetail(groupId,parentBrowseViewModel,null);
$.log("displayBrowseGroupId:"+groupId+":"+repositoryId);
userRepositoriesCall(
function(data){
var mainContent = $("#main-content");
mainContent.html($("#browse-tmpl" ).tmpl());
mainContent.find("#browse_result").html(mediumSpinnerImg());
var parentBrowseViewModel=new BrowseViewModel(null,null,null,repositoryId);
var url="restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(groupId);
if (repositoryId){
url+="?repositoryId="+repositoryId;
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
}else{
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:""}));
}
displayGroupDetail(groupId,parentBrowseViewModel,url,repositoryId);
}
);
}
displayBrowseArtifactDetail=function(groupId, artifactId){
$.log("displayBrowseArtifactDetail");
window.sammyArchivaApplication.setLocation("#artifact/"+groupId+"/"+artifactId);
//displayArtifactDetail(groupId,artifactId,null,null);
}
goToBrowseArtifactDetail=function(groupId, artifactId){
@ -1353,13 +1367,23 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
mainContent.find("#browse_artifact_detail").html(mediumSpinnerImg());
mainContent.find("#browse_breadcrumb" ).show();
mainContent.find("#browse_breadcrumb" ).html(mediumSpinnerImg());
userRepositoriesCall(
function(data) {
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(groupId,artifactId,version,repositoryId);
artifactVersionDetailViewModel.display();
}
);
}
userRepositoriesCall=function(successCallbackFn){
$.ajax("restServices/archivaServices/browseService/userRepositories", {
type: "GET",
dataType: 'json',
success: function(data) {
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(groupId,artifactId,version,repositoryId);
artifactVersionDetailViewModel.display();
successCallbackFn(data);
}
});
}