From ab3edfb450d544a386878791d1af69f201965550 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 9 Aug 2012 21:13:21 +0000 Subject: [PATCH] handle navigation for used-by tab in artifact detail view git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1371489 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 55 ++++++++++++++++++- .../src/main/webapp/js/archiva/search.js | 24 ++------ .../webapp/js/templates/archiva/search.html | 10 ++-- 3 files changed, 63 insertions(+), 26 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 e9f4be316..84fc1270d 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 @@ -245,15 +245,23 @@ function() { return; }); - var checkArtifactDetailContent=function(groupId,artifactId,version,repositoryId,tabToActivate){ + var checkArtifactDetailContent=function(groupId,artifactId,version,repositoryId,tabToActivate,idContentToCheck,contentDisplayFn){ // no need to recalculate all stuff just activate the tab - if($("#browse_artifact_detail" ).html()!=null){ + var htmlId = idContentToCheck?idContentToCheck:"browse_artifact_detail"; + if($("#main-content #"+htmlId ).html()!=null){ if( $.trim($("#browse_artifact_detail" ).html().length)>0){ $("#main-content #"+tabToActivate).tab('show') return; } } - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId,function(){$("#main-content #"+tabToActivate).tab('show')}); + generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId, + function(){ + $("#main-content #"+tabToActivate).tab('show') + if(contentDisplayFn){ + contentDisplayFn(); + } + } + ); } this.get('#artifact/:groupId/:artifactId/:version',function(context){ @@ -312,6 +320,47 @@ function() { checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-dependency-tree-content-a"); }); + this.get('#artifact-used-by/: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; + + var calculateUsedBy=function(){ + var dependeesContentDiv=$("#main-content #artifact-details-used-by-content" ); + if( $.trim(dependeesContentDiv.html()).length<1){ + dependeesContentDiv.html(mediumSpinnerImg()); + var dependeesUrl="restServices/archivaServices/browseService/dependees/"+encodeURIComponent(groupId); + dependeesUrl+="/"+encodeURIComponent(artifactId); + dependeesUrl+="/"+encodeURIComponent(version); + var selectedRepo=getSelectedBrowsingRepository(); + if (selectedRepo){ + dependeesUrl+="?repositoryId="+encodeURIComponent(selectedRepo); + } + $.ajax(dependeesUrl, { + type: "GET", + dataType: 'json', + success: function(data) { + var artifacts=mapArtifacts(data); + dependeesContentDiv.html($("#dependees_tmpl").tmpl({artifacts: artifacts})); + } + }); + } + } + + checkArtifactDetailContent(groupId,artifactId,version,repositoryId,"artifact-details-used-by-content-a","artifact-details-used-by-content",calculateUsedBy); + }); + + this.get('#artifact-used-by~: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-used-by-content-a"); + }); + 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 f1b6b1be5..7245a227d 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 @@ -307,25 +307,13 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno } if ($(e.target).attr("data-target")=="#artifact-details-used-by-content") { - var dependeesContentDiv=mainContent.find("#artifact-details-used-by-content" ); - if( $.trim(dependeesContentDiv.html()).length<1){ - dependeesContentDiv.html(mediumSpinnerImg()); - var dependeesUrl="restServices/archivaServices/browseService/dependees/"+encodeURIComponent(groupId); - dependeesUrl+="/"+encodeURIComponent(artifactId); - dependeesUrl+="/"+encodeURIComponent(version); - var selectedRepo=getSelectedBrowsingRepository(); - if (selectedRepo){ - dependeesUrl+="?repositoryId="+encodeURIComponent(selectedRepo); - } - $.ajax(dependeesUrl, { - type: "GET", - dataType: 'json', - success: function(data) { - var artifacts=mapArtifacts(data); - dependeesContentDiv.html($("#dependees_tmpl" ).tmpl({artifacts: artifacts})); - } - }); + var location ="#artifact-used-by"; + if (self.repositoryId){ + location+="~"+self.repositoryId; } + location+="/"+self.groupId+"/"+self.artifactId+"/"+self.version; + + window.sammyArchivaApplication.setLocation(location); return; } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html index 6b95a5bb8..83f0e706a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html @@ -435,19 +435,19 @@ ${$.i18n.prop('artifact.detail.tab.header.dependency.tree')}
  • - ${$.i18n.prop('artifact.detail.tab.header.file.content')} + ${$.i18n.prop('artifact.detail.tab.header.file.content')}
  • - ${$.i18n.prop('artifact.detail.tab.header.file.download')} + ${$.i18n.prop('artifact.detail.tab.header.file.download')}
  • - ${$.i18n.prop('artifact.detail.tab.header.used.by')} + ${$.i18n.prop('artifact.detail.tab.header.used.by')}
  • - ${$.i18n.prop('artifact.detail.tab.header.mailing.list')} + ${$.i18n.prop('artifact.detail.tab.header.mailing.list')}
  • - ${$.i18n.prop('artifact.detail.tab.header.metadatas')} + ${$.i18n.prop('artifact.detail.tab.header.metadatas')}