]> source.dussan.org Git - archiva.git/commitdiff
handle navigation for used-by tab in artifact detail view
authorOlivier Lamy <olamy@apache.org>
Thu, 9 Aug 2012 21:13:21 +0000 (21:13 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 9 Aug 2012 21:13:21 +0000 (21:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1371489 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
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html

index e9f4be3168d6eb294dea5d2f8616f8db42f04085..84fc1270d75a13be0a8eb994cac12bcce0cd5ad7 100644 (file)
@@ -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;
index f1b6b1be588be0c0e76fa384fb52e95a9cd793b0..7245a227d5f69805d6cd9e71f63b8c6f55ab7e40 100644 (file)
@@ -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;
                 }
 
index 6b95a5bb8a96b466b6d26167209d2bcc7829e2bd..83f0e706a74b8e35531a6e77b2b673a287fd52d4 100644 (file)
         <a data-toggle="tab" id="artifact-details-dependency-tree-content-a" data-target="#artifact-details-dependency-tree-content" href="#artifact-details-dependency-tree-content">${$.i18n.prop('artifact.detail.tab.header.dependency.tree')}</a>
       </li>
       <li>
-        <a data-toggle="tab" href="#artifact-details-files-content">${$.i18n.prop('artifact.detail.tab.header.file.content')}</a>
+        <a data-toggle="tab" id="artifact-details-files-content-a" data-target="#artifact-details-files-content" href="#artifact-details-files-content">${$.i18n.prop('artifact.detail.tab.header.file.content')}</a>
       </li>
       <li>
-        <a data-toggle="tab" href="#artifact-details-download-content">${$.i18n.prop('artifact.detail.tab.header.file.download')}</a>
+        <a data-toggle="tab" id="artifact-details-download-content-a" data-target="#artifact-details-download-content" href="#artifact-details-download-content">${$.i18n.prop('artifact.detail.tab.header.file.download')}</a>
       </li>
       <li>
-        <a data-toggle="tab" href="#artifact-details-used-by-content">${$.i18n.prop('artifact.detail.tab.header.used.by')}</a>
+        <a data-toggle="tab" id="artifact-details-used-by-content-a" data-target="#artifact-details-used-by-content" href="#artifact-details-used-by-content">${$.i18n.prop('artifact.detail.tab.header.used.by')}</a>
       </li>
       <li>
-        <a data-toggle="tab" href="#artifact-details-mailing-list-content">${$.i18n.prop('artifact.detail.tab.header.mailing.list')}</a>
+        <a data-toggle="tab" id="artifact-details-mailing-list-content-a" data-target="#artifact-details-mailing-list-content" href="#artifact-details-mailing-list-content">${$.i18n.prop('artifact.detail.tab.header.mailing.list')}</a>
       </li>
       <li>
-        <a data-toggle="tab" href="#artifact-details-metadatas-content">${$.i18n.prop('artifact.detail.tab.header.metadatas')}</a>
+        <a data-toggle="tab" id="artifact-details-metadatas-content-a" data-target="#artifact-details-metadatas-content" href="#artifact-details-metadatas-content">${$.i18n.prop('artifact.detail.tab.header.metadatas')}</a>
       </li>
     </ul>
     <div class="tab-content">