From dcfad19e538ef9f496d4c0e81058c5349267edc2 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 22 Mar 2012 22:38:11 +0000 Subject: [PATCH] [MRM-1615] Artifact detail view add link on dependency tree entries. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1304115 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/search.js | 65 ++++++++++++++++++- .../webapp/js/archiva/templates/search.html | 20 +++++- 2 files changed, 80 insertions(+), 5 deletions(-) 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 fc8086833..cdd056d98 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 @@ -202,7 +202,7 @@ $(function() { mainContent.find("#browse-autocomplete-divider" ).hide(); mainContent.find("#artifact-details-tabs").on('show', function (e) { if ($(e.target).attr("href")=="#artifact-details-dependency-tree-content") { - var treeContentDiv=$("#artifact-details-dependency-tree-content" ); + var treeContentDiv=mainContent.find("#artifact-details-dependency-tree-content" ); //if( $.trim(treeContentDiv.html()).length<1){ treeContentDiv.html(mediumSpinnerImg()); var treeDependencyUrl="restServices/archivaServices/browseService/treeEntries/"+encodeURIComponent(groupId); @@ -212,12 +212,12 @@ $(function() { if (selectedRepo){ treeDependencyUrl+="?repositoryId="+encodeURIComponent(selectedRepo); } - var treeDependencyUrl= $.ajax(treeDependencyUrl, { type: "GET", dataType: 'json', success: function(data) { - treeContentDiv.html($("#dependency_tree_tmpl" ).tmpl({treeEntries: [data[0]]})); + var treeEntries = mapTreeEntries(data); + treeContentDiv.html($("#dependency_tree_tmpl" ).tmpl({treeEntries: treeEntries}));//[data[0]] } }); //} @@ -234,6 +234,8 @@ $(function() { }); } + + displayGroup=function(groupId){ var parentBrowseViewModel=new BrowseViewModel(null,null,null); displayGroupDetail(groupId,parentBrowseViewModel,null); @@ -249,7 +251,33 @@ $(function() { } } + TreeEntry=function(artifact,childs){ + this.artifact=artifact; + this.childs=childs; + } + + mapTreeEntries=function(data){ + if (data==null){ + return []; + } + return $.map(data,function(e) { + return new TreeEntry(mapArtifact(e.artifact),mapTreeEntries(e.childs)); + }) + } + + dependencyTreeDisplayGroup=function(groupId) { + var parentBrowseViewModel=new BrowseViewModel(null,null,null); + displayGroupDetail(groupId,parentBrowseViewModel,null); + } + + dependencyTreeDisplayArtifactDetailView=function(groupId, artifactId){ + displayArtifactDetail(groupId, artifactId); + } + dependencyTreeDisplayArtifactVersionDetailViewModel=function(groupId,artifactId,version){ + var artifactVersionDetailViewModel = new ArtifactVersionDetailViewModel (groupId,artifactId,version) + artifactVersionDetailViewModel.display(); + } displayArtifactDetail=function(groupId,artifactId,parentBrowseViewModel,restUrl){ var artifactDetailViewModel=new ArtifactDetailViewModel(groupId,artifactId); @@ -741,6 +769,9 @@ $(function() { Artifact=function(context,url,groupId,artifactId,repositoryId,version,prefix,goals,bundleVersion,bundleSymbolicName, bundleExportPackage,bundleExportService,bundleDescription,bundleName,bundleLicense,bundleDocUrl, bundleImportPackage,bundleRequireBundle,classifier,packaging,fileExtension){ + + var self=this; + //private String context; this.context=context; @@ -815,6 +846,31 @@ $(function() { //file extension of the artifact //private String fileExtension; this.fileExtension=fileExtension; + + // FIXME it's a copy an paste from Dependency we must extract an "abstract" class with common fields + this.crumbEntries=function(){ + var splitted = self.groupId.split("."); + var breadCrumbEntries=[]; + var curGroupId=""; + for (var i=0;i -
+
+
used by @@ -677,7 +678,22 @@