]> source.dussan.org Git - archiva.git/commitdiff
simply breadcrumb calculation
authorOlivier Lamy <olamy@apache.org>
Fri, 17 Feb 2012 22:50:39 +0000 (22:50 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 17 Feb 2012 22:50:39 +0000 (22:50 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1245789 13f79535-47bb-0310-9956-ffa450edef68

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 1ff45a25e0db349cf86be3adec9048cac2ca417b..e76c99a542074a86087844b81e7afb6045b7d2e6 100644 (file)
@@ -43,15 +43,21 @@ $(function() {
     }
 
     breadCrumbEntries=function(){
-      var curBrowseViewModel=self;
-      var entries=[];
-      do{
-        entries.push(curBrowseViewModel.groupId);
-        curBrowseViewModel=curBrowseViewModel.parentBrowseViewModel;
-        if (!curBrowseViewModel) return entries.reverse();
-      }while(curBrowseViewModel.parentBrowseViewModel)
-      return entries.reverse();
+      // root level ?
+      if (!self.parentBrowseViewModel) return [];
+
+      var splitted = self.groupId.split(".");
+      var breadCrumbEntries=[];
+      var curGroupId;
+      for (var i=0;i<splitted.length;i++){
+        curGroupId+=splitted[i];
+        breadCrumbEntries.push(new BreadCrumbEntry(curGroupId,splitted[i]));
+        curGroupId+="."
+      }
+      return breadCrumbEntries;
     }
+
+
   }
 
   findParentGroupId=function(browseViewModel){
@@ -122,6 +128,11 @@ $(function() {
     this.project=project;
   }
 
+  BreadCrumbEntry=function(groupId,displayValue){
+    this.groupId=groupId;
+    this.displayValue=displayValue;
+  }
+
   //-----------------------------------------
   // search part
   //-----------------------------------------
index ac32be8d111945dea1eb93e2da6197f27de45e35..74bf3daa5bd4fd25728a8ad4275facfb4e1d5827 100644 (file)
@@ -61,7 +61,9 @@
   <ul class="breadcrumb">
     <li><a href="#" data-bind="click: function(){ browseRoot()}"><i class="icon-home"/>&nbsp;</a>&nbsp;<span class="divider">/</span></li>
     {{each(i,breadCrumbEntry) breadCrumbEntries}}
-      <li><a href="#">${breadCrumbEntry}</a>&nbsp;<span class="divider">/</span></li>
+      <li data-bind="click: function(){displayGroupId(breadCrumbEntry.groupId)}">
+        <a href="#">${breadCrumbEntry.displayValue}</a>&nbsp;<span class="divider">/</span>
+      </li>
     {{/each}}
   </ul>
 </script>
\ No newline at end of file