handle navigation for metatadata tab in artifact detail view

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1371828 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-08-10 21:56:24 +00:00
parent 273aeb97a7
commit 22479f55ee
2 changed files with 52 additions and 21 deletions

View File

@ -256,10 +256,10 @@ function() {
} }
} }
generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId, generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId,
function(){ function(artifactVersionDetailViewModel){
$("#main-content #"+tabToActivate).tab('show') $("#main-content #"+tabToActivate).tab('show')
if(contentDisplayFn){ if(contentDisplayFn){
contentDisplayFn(groupId,artifactId,version); contentDisplayFn(groupId,artifactId,version,artifactVersionDetailViewModel);
} }
} }
); );
@ -362,6 +362,49 @@ function() {
checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-used-by-content-a","artifact-details-used-by-content",calculateUsedBy); checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-used-by-content-a","artifact-details-used-by-content",calculateUsedBy);
}); });
var calculateMetadatas=function(groupId,artifactId,version,artifactVersionDetailViewModel){
var metadatasContentDiv=$("#main-content #artifact-details-metadatas-content" );
var metadatasUrl="restServices/archivaServices/browseService/metadatas/"+encodeURIComponent(groupId);
metadatasUrl+="/"+encodeURIComponent(artifactId);
metadatasUrl+="/"+encodeURIComponent(version);
var selectedRepo=getSelectedBrowsingRepository();
if (selectedRepo){
metadatasUrl+="?repositoryId="+encodeURIComponent(selectedRepo);
}
//fixe self.entries not in the scope
$.ajax(metadatasUrl, {
type: "GET",
dataType: 'json',
success: function(data) {
var entries= $.map(data,function(e,i){
return new MetadataEntry( e.key, e.value,false);
});
artifactVersionDetailViewModel.entries(entries);
}
});
}
this.get('#artifact-metadatas/:groupId/:artifactId/:version',function(context){
var repositoryId = this.params.repositoryId;
var groupId= this.params.groupId;
var artifactId= this.params.artifactId;
var version= this.params.version;
checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-metadatas-content-a",null,calculateMetadatas);
});
this.get('#artifact-metadatas~:repositoryId/:groupId/:artifactId/:version',function(context){
var repositoryId = this.params.repositoryId;
var groupId= this.params.groupId;
var artifactId= this.params.artifactId;
var version= this.params.version;
checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-metadatas-content-a",null,calculateMetadatas);
});
this.get('#browse/:groupId',function(context){ this.get('#browse/:groupId',function(context){
var groupId = this.params.groupId; var groupId = this.params.groupId;

View File

@ -318,25 +318,13 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
} }
if ($(e.target).attr("href")=="#artifact-details-metadatas-content") { if ($(e.target).attr("href")=="#artifact-details-metadatas-content") {
$.log("artifact metadata"); var location ="#artifact-metadatas";
var metadatasContentDiv=mainContent.find("#artifact-details-metadatas-content" ); if (self.repositoryId){
var metadatasUrl="restServices/archivaServices/browseService/metadatas/"+encodeURIComponent(groupId); location+="~"+self.repositoryId;
metadatasUrl+="/"+encodeURIComponent(artifactId);
metadatasUrl+="/"+encodeURIComponent(version);
var selectedRepo=getSelectedBrowsingRepository();
if (selectedRepo){
metadatasUrl+="?repositoryId="+encodeURIComponent(selectedRepo);
} }
$.ajax(metadatasUrl, { location+="/"+self.groupId+"/"+self.artifactId+"/"+self.version;
type: "GET",
dataType: 'json', window.sammyArchivaApplication.setLocation(location);
success: function(data) {
var entries= $.map(data,function(e,i){
return new MetadataEntry( e.key, e.value,false);
});
self.entries(entries);
}
});
return; return;
} }
@ -357,7 +345,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
} }
}); });
if(afterCallbackFn){ if(afterCallbackFn){
afterCallbackFn(); afterCallbackFn(self);
} }
} }