From 01e276a590eb8b18793678a2e3c9d9f41f7f0852 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sun, 29 Jul 2012 19:22:07 +0000 Subject: [PATCH] correctly handle current groupId browsing when changing repositoryId. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1366909 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/search.js | 8 +++++++- .../src/main/webapp/js/archiva/utils.js | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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 435311f32..00219e70f 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 @@ -694,7 +694,13 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno changeBrowseRepository=function(){ var selectedRepository=getSelectedBrowsingRepository(); - window.sammyArchivaApplication.setLocation("#browse~"+selectedRepository); + // #browse~internal/org.apache.maven + var currentHash=window.location.hash; + var newLocation = "#browse~"+selectedRepository+currentHash.substringAfterFirst("/"); + // do we have extra path after repository ? + + $.log("changeBrowseRepository:"+newLocation); + window.sammyArchivaApplication.setLocation(newLocation); } getSelectedBrowsingRepository=function(){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js index f9bc2687e..cbaeefd4f 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js @@ -405,6 +405,18 @@ define("utils",["jquery","i18n","jquery.tmpl"], function() { String.prototype.substringAfterLast = function(str) { return this.substring(this.lastIndexOf(str)+1); } + /** + * + * @param str + * @return {String} if str not found return empty string + */ + String.prototype.substringAfterFirst = function(str) { + var idx = this.indexOf(str); + if (idx<0){ + return ""; + } + return this.substring(idx); + } //----------------------------------------- // extends jquery tmpl to support var def -- 2.39.5