Author: jmorliaguet
Date: Sat Feb 18 18:00:29 2006
New Revision: 2420

Modified:
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py
Log:

- filter out closed nodes



Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py
  (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py
  Sat Feb 18 18:00:29 2006
@@ -5,28 +5,47 @@
 
 from cpsskins import minjson as json
 
-data = {
+tree_data = {
     'items': [
-        {'id': 1, 'title': 'item 1', 'depth': 1, 'type': 'container'},
-        {'id': 2, 'title': 'item 2', 'depth': 1, 'type': 'container'},
-        {'id': 3, 'title': 'item 3', 'depth': 2},
-        {'id': 4, 'title': 'item 4', 'depth': 2},
-        {'id': 5, 'title': 'item 5', 'depth': 2, 'position': 'last'},
-        {'id': 6, 'title': 'item 6', 'depth': 1, 'type': 'container'},
-        {'id': 7, 'title': 'item 7', 'depth': 1, 'type': 'container'},
+        {'id': '1', 'title': 'item 1', 'depth': 1, 'type': 'container'},
+        {'id': '2', 'title': 'item 2', 'depth': 1, 'type': 'container'},
+        {'id': '3', 'title': 'item 3', 'depth': 2, 'type': 'item'},
+        {'id': '4', 'title': 'item 4', 'depth': 2, 'type': 'item'},
+        {'id': '5', 'title': 'item 5', 'depth': 2, 'type': 'item', 
+          'position': 'last'},
+        {'id': '6', 'title': 'item 6', 'depth': 1, 'type': 'container'},
+        {'id': '7', 'title': 'item 7', 'depth': 1, 'type': 'container'},
+        {'id': '8', 'title': 'item 7', 'depth': 2, 'type': 'item'},
     ]
 }
 
+MAX_DEPTH = 10
+
 class Views(BrowserView):
 
     def getTreeData(self):
         local_data = self._getLocalStorageData(1)
         if local_data is None:
             local_data = {}
-        tree_state = local_data.get('states', {})
+        tree_state = local_data.get('state', {})
+
+        filtered_items = []
+        filter_depth = MAX_DEPTH
+        for item in tree_data['items']:
+
+            depth = item['depth']
+            if depth > filter_depth:
+                continue
+            else:
+                filter_depth = MAX_DEPTH
+
+            if item['type'] == 'container':
+                state = tree_state.get(item['id'])
+                if state != 'open':
+                    filter_depth = depth
 
-        print local_data
-        return json.write(data)
+            filtered_items.append(item)
+        return json.write({'items': filtered_items})
 
     # TODO: moves this to an API
     def _getLocalStorageData(self, id):
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to