]> source.dussan.org Git - archiva.git/commitdiff
group naviguation
authorOlivier Lamy <olamy@apache.org>
Thu, 16 Feb 2012 21:27:22 +0000 (21:27 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 16 Feb 2012 21:27:22 +0000 (21:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1245186 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 5466f8feff82f113747c1a6aef1e4efbe49ad238..b8c3a452d2cd876bbb01e991b9a3b93f13f1805f 100644 (file)
@@ -29,18 +29,21 @@ $(function() {
           success: function(data) {
             var browseGroupIdEntryies = $.isArray(data.browseGroupIdResult.browseGroupIdEntries) ?
                 $.map(data.browseGroupIdResult.browseGroupIdEntries,function(item){
-                  $.log("name:"+item.name);
                   return new BrowseGroupIdEntry(item.name, item.project);
                 }): [data.browseGroupIdResult.browseGroupIdEntries];
-            $.log("size:"+browseGroupIdEntryies.length);
-            //var browseTopViewModel = new BrowseTopViewModel(groupdIds);
+            $("#main-content #browse_result").html($("#browse-groups-div-tmpl" ).tmpl());
+            var browseGroupsViewModel = new BrowseGroupsViewModel(browseGroupIdEntryies);
 
-            //ko.applyBindings(browseTopViewModel,mainContent.find("#browse_result" ).get(0));
+            ko.applyBindings(browseGroupsViewModel,$("#main-content #browse-groups-div" ).get(0));
           }
       });
     }
   }
 
+  BrowseGroupsViewModel=function(browseGroupIdEntryies){
+    this.browseGroupIdEntryies=browseGroupIdEntryies;
+  }
+
   displayBrowse=function(){
     var mainContent = $("#main-content");
     mainContent.html($("#browse-tmpl" ).tmpl());
@@ -49,9 +52,10 @@ $(function() {
         type: "GET",
         dataType: 'json',
         success: function(data) {
-          var groupdIds = $.map(data.groupIdList.groupIds,function(item){
-            return item;
-          });
+          var groupdIds =
+              $.isArray(data.groupIdList.groupIds)? $.map(data.groupIdList.groupIds,function(item){
+                return item;
+              }): [data.groupIdList.groupIds];
           $.log("size:"+groupdIds.length);
           var browseTopViewModel = new BrowseTopViewModel(groupdIds);
 
index d6b050ad6c6fd401606973761f350272b55af544..3aa741654a98b5620569c20e6150ab5a3c1c708f 100644 (file)
       {{/each}}
     </ul>
   </div>
+</script>
+
+<script id="browse-groups-div-tmpl" type="text/html">
+  <div id="browse-groups-div" data-bind='template:{name:"browse-groups-tmpl"}'>
+
+  </div>
+</script>
+
+<script id="browse-groups-tmpl" type="text/html">
+  <div>
+    <ul>
+      {{each(i,browseGroupIdEntry) browseGroupIdEntryies}}
+        <li class="browse-list">
+          <a href="#">&nbsp;${browseGroupIdEntry.name}-project: ${browseGroupIdEntry.project}</a>
+        </li>
+      {{/each}}
+    </ul>
+  </div>
 </script>
\ No newline at end of file