]> source.dussan.org Git - archiva.git/commitdiff
handle navigation for metatadata tab in artifact detail view
authorOlivier Lamy <olamy@apache.org>
Fri, 10 Aug 2012 21:56:24 +0000 (21:56 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 10 Aug 2012 21:56:24 +0000 (21:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1371828 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js

index 74d4cf1c52acfb8869c0bfba0b12fe5fd1371a9f..fc8ccb9eb62a91ab0c5b5bfe1b450ca212faedf2 100644 (file)
@@ -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;
index 7245a227d5f69805d6cd9e71f63b8c6f55ab7e40..d7a4a0a9676ca74aabd82b4d2bd82312112501d6 100644 (file)
@@ -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);
               }
             }