cleanup and simplify browse js model

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1245415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-02-17 11:53:51 +00:00
parent 4efbe7c1b1
commit 3be005aa70
1 changed files with 7 additions and 14 deletions

View File

@ -18,22 +18,16 @@
*/ */
$(function() { $(function() {
BrowseTopViewModel=function(browseIdEntries){ BrowseViewModel=function(browseIdEntries,parentGroupdId){
this.browseIdEntries=browseIdEntries; this.browseIdEntries=browseIdEntries;
this.parentGroupdId=parentGroupdId;
displayGroupId=function(groupId){ displayGroupId=function(groupId){
displayGroupDetail(groupId,".."); displayGroupDetail(groupId,"..");
} }
} }
BrowseGroupsViewModel=function(browseIdEntries,parentGroupdId){
var self = this;
this.browseIdEntries=browseIdEntries;
this.parentGroupdId=parentGroupdId;
displayGroupId=function(groupId){
displayGroupDetail(groupId,self.parentGroupdId);
}
}
displayBrowse=function(){ displayBrowse=function(){
clearUserMessages(); clearUserMessages();
@ -46,9 +40,9 @@ $(function() {
success: function(data) { success: function(data) {
var browseIdEntries = mapBrowseIdEntries(data); var browseIdEntries = mapBrowseIdEntries(data);
$.log("size:"+browseIdEntries.length); $.log("size:"+browseIdEntries.length);
var browseTopViewModel = new BrowseTopViewModel(browseIdEntries); var browseViewModel = new BrowseViewModel(browseIdEntries);
ko.applyBindings(browseTopViewModel,mainContent.get(0)); ko.applyBindings(browseViewModel,mainContent.get(0));
} }
}); });
} }
@ -66,10 +60,9 @@ $(function() {
dataType: 'json', dataType: 'json',
success: function(data) { success: function(data) {
var browseIdEntries = mapBrowseIdEntries(data); var browseIdEntries = mapBrowseIdEntries(data);
//browseResult.html($("#browse-groups-div-tmpl" ).tmpl()); var browseViewModel = new BrowseViewModel(browseIdEntries,parentGroupdId);
var browseGroupsViewModel = new BrowseGroupsViewModel(browseIdEntries,parentGroupdId);
ko.applyBindings(browseGroupsViewModel,mainContent.get(0)); ko.applyBindings(browseViewModel,mainContent.get(0));
} }
}); });
} }