From e0ddc83e6c6d58b7bbeeb2bc33a47e05f22f3757 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 7 Aug 2012 18:13:05 +0000 Subject: [PATCH] use navigation when browsing with autocomplete git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1370412 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/main.js | 8 +- .../src/main/webapp/js/archiva/search.js | 73 ++++++++++--------- 2 files changed, 42 insertions(+), 39 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 01cf81717..fa72b4b27 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 @@ -205,18 +205,14 @@ function() { return; }); - this.get('#artifact:repositoryId/:groupId/:artifactId/:version',function(context){ + this.get('#artifact/: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; + generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId); - if(!version){ - displayBrowseArtifactDetail(splitted[0],splitted[1]);//,null,null); - } else { - generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId); - } }); 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 00219e70f..be9d585ca 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 @@ -598,6 +598,37 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno artifactVersionDetailViewModel.display(); } + goToBrowseArtifactDetail=function(groupId, artifactId){ + $.log("goToBrowseArtifactDetail:"+groupId+":"+artifactId); + displayBrowseGroupId(groupId,null,null); + displayArtifactDetail(groupId,artifactId,null,null); + } + + /** + * + */ + displayBrowseGroupId=function(groupId,repositoryId,artifactId){ + clearUserMessages(); + $.log("displayBrowseGroupId:"+groupId+":"+repositoryId); + userRepositoriesCall( + function(data){ + var mainContent = $("#main-content"); + mainContent.html($("#browse-tmpl" ).tmpl()); + mainContent.find("#browse_result").html(mediumSpinnerImg()); + var parentBrowseViewModel=new BrowseViewModel(null,null,null,repositoryId); + var url="restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(groupId); + if (repositoryId){ + url+="?repositoryId="+repositoryId; + mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId})); + }else{ + mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:""})); + } + displayGroupDetail(groupId,parentBrowseViewModel,url,repositoryId); + } + ); + + } + /** * * @param groupId @@ -606,6 +637,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno * @param restUrl */ displayArtifactDetail=function(groupId,artifactId,parentBrowseViewModel,restUrl){ + $.log("displayArtifactDetail:"+groupId+":"+artifactId); var artifactDetailViewModel=new ArtifactDetailViewModel(groupId,artifactId); var mainContent = $("#main-content"); mainContent.find("#browse_artifact_detail" ).hide(); @@ -808,7 +840,14 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno var artifactId=values[values.length-1]; displayArtifactDetail(groupId,artifactId,self); } else { - displayBrowseGroupIdFromAutoComplete(ui.item.name); + var selectedRepo=getSelectedBrowsingRepository(); + var location ="#browse"; + if (selectedRepo){ + location+="~"+selectedRepo; + } + location+="/"+ui.item.name; + window.sammyArchivaApplication.setLocation(location); + //displayBrowseGroupIdFromAutoComplete(ui.item.name); } return false; } @@ -832,43 +871,11 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno displayGroupDetail(groupId,parentBrowseViewModel,null); } - /** - * called if browser url contains queryParam browse=groupId - * @param groupId - */ - displayBrowseGroupId=function(groupId,repositoryId){ - clearUserMessages(); - $.log("displayBrowseGroupId:"+groupId+":"+repositoryId); - userRepositoriesCall( - function(data){ - var mainContent = $("#main-content"); - mainContent.html($("#browse-tmpl" ).tmpl()); - mainContent.find("#browse_result").html(mediumSpinnerImg()); - var parentBrowseViewModel=new BrowseViewModel(null,null,null,repositoryId); - var url="restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(groupId); - if (repositoryId){ - url+="?repositoryId="+repositoryId; - mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId})); - }else{ - mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:""})); - } - displayGroupDetail(groupId,parentBrowseViewModel,url,repositoryId); - } - ); - - } - displayBrowseArtifactDetail=function(groupId, artifactId){ $.log("displayBrowseArtifactDetail"); window.sammyArchivaApplication.setLocation("#artifact/"+groupId+"/"+artifactId); } - goToBrowseArtifactDetail=function(groupId, artifactId){ - $.log("displayBrowseArtifactDetail"); - displayBrowseGroupId(groupId); - displayArtifactDetail(groupId,artifactId,null,null); - } - mapBrowseResultEntries=function(data){ $.log("mapBrowseResultEntries"); if (data.browseResultEntries) { -- 2.39.5