start using sammy for navigation while browsing tru the ui

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1360109 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-07-11 10:32:34 +00:00
parent 05149a2b15
commit 57014d6ab0
2 changed files with 33 additions and 23 deletions

View File

@ -64,29 +64,8 @@ function() {
resetPasswordForm(resetPassword); resetPasswordForm(resetPassword);
return; return;
} }
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(':');
$.log("splitted.length:"+splitted.length);
if(splitted.length==2){
displayBrowseArtifactDetail(splitted[0],splitted[1],null,null);
return;
} else if (splitted.length==3) {
generalDisplayArtifactDetailsVersionView(splitted[0],splitted[1],splitted[2],repositoryId);
return;
} else {
displayWarningMessage( $.i18n.prop("shortcut.artifact.illegal"));
}
}
}
// by default display search screen // by default display search screen
displaySearch(); window.sammyArchivaApplication.setLocation("#search");
} }
hasKarma=function(karmaName){ hasKarma=function(karmaName){
@ -256,6 +235,30 @@ function() {
this.activeMenuId = ko.observable(); this.activeMenuId = ko.observable();
window.sammyArchivaApplication = Sammy(function () { window.sammyArchivaApplication = Sammy(function () {
// #artifact-(optionnal 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
this.get('#artifact/:groupId/:artifactId',function(context){
var groupId= this.params['groupId'];
var artifactId= this.params['artifactId'];
$.log("get #artifact:"+groupId+":"+artifactId);
goToBrowseArtifactDetail(groupId,artifactId);//,null,null);
return;
});
this.get('#artifact: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'];
if(!version){
displayBrowseArtifactDetail(splitted[0],splitted[1]);//,null,null);
} else {
generalDisplayArtifactDetailsVersionView(groupId,artifactId,version,repositoryId);
}
});
this.get('#browse/:groupId',function(context){ this.get('#browse/:groupId',function(context){
var groupId = this.params['groupId']; var groupId = this.params['groupId'];
if (groupId){ if (groupId){
@ -274,7 +277,7 @@ function() {
}); });
}); });
this.get('', function () { this.app.runRoute('get', '#Search') }); this.get('', function () { this.app.runRoute('get', '#search') });
} ); } );
sammyArchivaApplication.run(); sammyArchivaApplication.run();
} }

View File

@ -59,6 +59,7 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
$.log("displayProjectEntry:"+id+",groupId:"+self.groupId+",values:"+values); $.log("displayProjectEntry:"+id+",groupId:"+self.groupId+",values:"+values);
displayArtifactDetail(self.groupId,values,self); displayArtifactDetail(self.groupId,values,self);
//window.sammyArchivaApplication.setLocation("#artifact/"+self.groupId+"/"+values);
} }
@ -829,6 +830,12 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
} }
displayBrowseArtifactDetail=function(groupId, artifactId){ displayBrowseArtifactDetail=function(groupId, artifactId){
window.sammyArchivaApplication.setLocation("#artifact/"+groupId+"/"+artifactId);
//displayArtifactDetail(groupId,artifactId,null,null);
}
goToBrowseArtifactDetail=function(groupId, artifactId){
$.log("displayBrowseArtifactDetail");
displayBrowseGroupId(groupId); displayBrowseGroupId(groupId);
displayArtifactDetail(groupId,artifactId,null,null); displayArtifactDetail(groupId,artifactId,null,null);
} }