]> source.dussan.org Git - archiva.git/commitdiff
implements repository browsing
authorOlivier Lamy <olamy@apache.org>
Fri, 17 Feb 2012 17:40:43 +0000 (17:40 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 17 Feb 2012 17:40:43 +0000 (17:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1245680 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/BrowseResult.java
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 57dcd4943fc6098ff1d40204a12996491ec63ded..8278ac1dbac29df27fe474b836f0ea9bae62844c 100644 (file)
@@ -31,6 +31,8 @@ public class BrowseResult
 {
     private List<BrowseResultEntry> browseResultEntries;
 
+    private boolean rootLevel;
+
     public BrowseResult()
     {
         // no op
index 313061e9cc68f45d2da77c9b6c1b671070f8eacb..76439836050b99e9876e7637a3af9e9f400b7ee6 100644 (file)
@@ -22,19 +22,30 @@ $(function() {
   // browse part
   //-----------------------------------------
 
-  BrowseViewModel=function(browseResultEntries,parentGroupdId){
+  BrowseViewModel=function(browseResultEntries,parentBrowseViewModel,groupId){
     var self=this;
     this.browseResultEntries=browseResultEntries;
-    this.parentGroupdId=parentGroupdId;
+    this.parentBrowseViewModel=parentBrowseViewModel;
+    this.groupId=groupId;
     displayGroupId=function(groupId){
-      displayGroupDetail(groupId,self.parentGroupdId);
+      displayGroupDetail(groupId,self);
+      $.log("called displayGroupDetail groupId:"+groupId
+                +",parentBrowseViewModel.groupId:"+(parentBrowseViewModel?parentBrowseViewModel.groupId:"null"));
+    }
+    displayParentGroupId=function(){
+      $.log("called displayParentGroupId groupId:"+self.parentBrowseViewModel.groupId);
+      // if null parent is root level
+      if (self.parentBrowseViewModel.groupId){
+        displayGroupDetail(self.parentBrowseViewModel.groupId,self.parentBrowseViewModel);
+      } else {
+        browseRoot();
+      }
     }
-
   }
 
 
 
-  displayGroupDetail=function(groupId,parentGroupdId,restUrl){
+  displayGroupDetail=function(groupId,parentBrowseViewModel,restUrl){
     var mainContent = $("#main-content");
     var browseResult=mainContent.find("#browse_result");
     var browseBreadCrumb=mainContent.find("#browse_breadcrumb");
@@ -49,7 +60,8 @@ $(function() {
             dataType: 'json',
             success: function(data) {
               var browseResultEntries = mapbrowseResultEntries(data);
-              var browseViewModel = new BrowseViewModel(browseResultEntries,parentGroupdId);
+              $.log("displayGroupDetail#sucess parentBrowseViewModel:"+parentBrowseViewModel);
+              var browseViewModel = new BrowseViewModel(browseResultEntries,parentBrowseViewModel,groupId);
 
               ko.applyBindings(browseViewModel,mainContent.get(0));
             }
@@ -76,7 +88,7 @@ $(function() {
         success: function(data) {
           var browseResultEntries = mapbrowseResultEntries(data);
           $.log("size:"+browseResultEntries.length);
-          var browseViewModel = new BrowseViewModel(browseResultEntries,"..");
+          var browseViewModel = new BrowseViewModel(browseResultEntries,null,null);
           ko.applyBindings(browseViewModel,mainContent.get(0));
         }
     });
index c80b4d3ea398a41a9f0c8d66ce4a303526ea9b64..7d8e4dfb87c83aefb64160e49a10d462de1b64b4 100644 (file)
 <script id="browse-groups-tmpl" type="text/html">
   <div>
     <ul>
-      <li class="browse-list"><a href="#" data-bind="click:function(){displayGroupId($root.parentGroupdId)}">..</a></li>
+      <!-- if null we are on root level -->
+      {{if $root.parentBrowseViewModel}}
+        <li class="browse-list"><a href="#" data-bind="click:function(){displayParentGroupId()}">..</a></li>
+      {{/if}}
       {{each(i,browseResultEntry) browseResultEntries}}
         <li class="browse-list">
           <a href="#" data-bind="click:function(){displayGroupId(browseResultEntry.name)}">