From 22479f55eede2f83bf1c62dda7d163fc95febcfb Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 10 Aug 2012 21:56:24 +0000 Subject: [PATCH] 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 --- .../src/main/webapp/js/archiva/main.js | 47 ++++++++++++++++++- .../src/main/webapp/js/archiva/search.js | 26 +++------- 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 74d4cf1c5..fc8ccb9eb 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -256,10 +256,10 @@ function() { } } generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId, - function(){ + function(artifactVersionDetailViewModel){ $("#main-content #"+tabToActivate).tab('show') 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); }); + 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){ var groupId = this.params.groupId; diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js index 7245a227d..d7a4a0a96 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js @@ -318,25 +318,13 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno } if ($(e.target).attr("href")=="#artifact-details-metadatas-content") { - $.log("artifact metadata"); - var metadatasContentDiv=mainContent.find("#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); + var location ="#artifact-metadatas"; + if (self.repositoryId){ + location+="~"+self.repositoryId; } - $.ajax(metadatasUrl, { - type: "GET", - dataType: 'json', - success: function(data) { - var entries= $.map(data,function(e,i){ - return new MetadataEntry( e.key, e.value,false); - }); - self.entries(entries); - } - }); + location+="/"+self.groupId+"/"+self.artifactId+"/"+self.version; + + window.sammyArchivaApplication.setLocation(location); return; } @@ -357,7 +345,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno } }); if(afterCallbackFn){ - afterCallbackFn(); + afterCallbackFn(self); } }