]> source.dussan.org Git - archiva.git/commitdiff
fix artifact detail view when using url query param shortcut
authorOlivier Lamy <olamy@apache.org>
Mon, 19 Mar 2012 22:46:57 +0000 (22:46 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 19 Mar 2012 22:46:57 +0000 (22:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1302700 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/archiva/templates/search.html

index af4d18d0e2981da705bfdfda9a5b71785b64dfa7..2d50df70e1ae39672a58c151cf0afe7d47204005 100644 (file)
@@ -83,16 +83,43 @@ $(function() {
     }
 
     var artifact= $.urlParam("artifact");
+    var repositoryId = $.urlParam("repositoryId");
     // format groupId:artifactId org.apache.maven.plugins:maven-jar-plugin
-    //
+    // or  groupId:artifactId:version org.apache.maven.plugins:maven-jar-plugin:2.3.1
+    // repository in param repositoryId
     if (artifact){
       if ( artifact.indexOf(':')>=0){
         var splitted = artifact.split(':');
-        displayBrowseArtifactDetail(splitted[0],splitted[1],null,null);
-        return;
+        $.log("splitted.length:"+splitted.length);
+        if(splitted.length==2){
+          displayBrowseArtifactDetail(splitted[0],splitted[1],null,null);
+          return;
+        } else if (splitted.length==3) {
+          var mainContent=$("#main-content");
+          mainContent.html($("#browse-tmpl" ).tmpl());
+          mainContent.find("#browse_result" ).hide();
+          mainContent.find("#browse_artifact_detail").show();
+          mainContent.find("#browse_artifact_detail").html(mediumSpinnerImg());
+          mainContent.find("#browse_breadcrumb" ).show();
+          mainContent.find("#browse_breadcrumb" ).html(mediumSpinnerImg());
+          $.ajax("restServices/archivaServices/browseService/userRepositories", {
+              type: "GET",
+              dataType: 'json',
+              success: function(data) {
+                mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId}));
+                var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(splitted[0],splitted[1],splitted[2]);
+                artifactVersionDetailViewModel.display(true);
+              }
+          });
+
+          return;
+        } else {
+          displayWarningMessage( $.i18n.prop("shortcut.artifact.illegal"));
+        }
       }
     }
 
+
     var screen = $.urlParam('screen');
 
     if(screen){
index 95cd54d482269852a8a14637512854c7f956a06f..c1b5524f490c82b325c75b2b6d330930f4e5ca5d 100644 (file)
@@ -75,6 +75,7 @@ $(function() {
     for (var i=0;i<splitted.length;i++){
       curGroupId+=splitted[i];
       breadCrumbEntries.push(new BreadCrumbEntry(curGroupId,splitted[i]));
+      $.log("calculateBreadCrumbEntries:"+curGroupId+":"+splitted[i]);
       curGroupId+="."
     }
     return breadCrumbEntries;
@@ -138,19 +139,24 @@ $(function() {
     }
 
     displayArtifactVersionDetail=function(version){
-      var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(self.groupId,self.artifactId,version,self);
+      var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(self.groupId,self.artifactId,version,getSelectedBrowsingRepository());
       artifactVersionDetailViewModel.display();
     }
 
   }
 
-  ArtifactVersionDetailViewModel=function(groupId,artifactId,version,artifactDetailViewModel){
+  ArtifactVersionDetailViewModel=function(groupId,artifactId,version){
     var mainContent = $("#main-content");
     var self=this;
     this.groupId=groupId;
     this.artifactId=artifactId;
     this.version=version;
     this.projectVersionMetadata=null;
+
+    displayGroupId=function(groupId){
+      displayGroupDetail(groupId,null);
+    }
+
     breadCrumbEntries=function(){
       var entries = calculateBreadCrumbEntries(self.groupId);
       var artifactBreadCrumbEntry = new BreadCrumbEntry(self.groupId,self.artifactId);
index 654e2e885d4d322824824d77019af1b71a3d8347..7eed22d9d26593cfc82c674f92a1e367043b95fe 100644 (file)
   <select id="select_browse_repository" onchange="changeBrowseRepository()">
     <option value="">All</option>
     {{each(i,repository) repositories}}
-    <option value="${repository.id}">${repository.name}</option>
+      {{if selected && selected==repository.id}}
+        <option value="${repository.id}" selected>${repository.name}</option>
+      {{else}}
+        <option value="${repository.id}">${repository.name}</option>
+      {{/if}}
     {{/each}}
   </select>
 </script>