Author: jmorliaguet Date: Sat Feb 18 02:11:58 2006 New Revision: 2409 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/__init__.py (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/configure.zcml (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/container-last.png (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/container-open.png (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/container.png (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/folder.png (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/node-link-branch.png (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/node-link-last.png (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt (contents, props changed) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/configure.zcml Log:
- saving work: the model consists of: - tree data generated on the server (remote storage with a @@getTreeData getter) - tree states (information about which nodes are open) (local storage, the information is stored in a cookie) - a compound storage that combines the tree data and the tree state. the view: - CTAL template that renders the tree - observes the model (see above) the controller: - behaviour on each container node (close/open) - 2 handlers (openContainer() and closeContainer() - controls the view (see above) TODO: - the server must use the tree state information to avoid sending information about closed nodes - ... Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/configure.zcml ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/configure.zcml Sat Feb 18 02:11:58 2006 @@ -12,4 +12,6 @@ <include package=".latency" /> + <include package=".treeview" /> + </configure> Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/__init__.py ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/__init__.py Sat Feb 18 02:11:58 2006 @@ -0,0 +1 @@ +# Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py Sat Feb 18 02:11:58 2006 @@ -0,0 +1,22 @@ + +from zope.app.publisher.browser import BrowserView + +from cpsskins import minjson as json + +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'}, + ] +} + +class Views(BrowserView): + + def getTreeData(self): + return json.write(data) + Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/configure.zcml ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/configure.zcml Sat Feb 18 02:11:58 2006 @@ -0,0 +1,53 @@ +<configure + xmlns:browser="http://namespaces.zope.org/browser"> + + <browser:resource + name="container.png" file="container.png" + layer="cpsskins-test" /> + + <browser:resource + name="container-open.png" file="container-open.png" + layer="cpsskins-test" /> + + <browser:resource + name="node-link-branch.png" file="node-link-branch.png" + layer="cpsskins-test" /> + + <browser:resource + name="node-link-last.png" file="node-link-last.png" + layer="cpsskins-test" /> + + <browser:resource + name="folder.png" file="folder.png" + layer="cpsskins-test" /> + + <browser:page + for="*" + layer="cpsskins-test" + name="cpsskins_treeview.html" + permission="zope.Public" + template="cpsskins_treeview.pt" + /> + + <browser:page + for="*" + layer="cpsskins-test" + name="treeview_widget.html" + permission="zope.Public" + template="treeview_widget.pt" + /> + + <browser:pages + layer="cpsskins-test" + for="*" + class=".browser.Views" + permission="zope.Public"> + + <browser:page + name="getTreeData" + attribute="getTreeData" + /> + + </browser:pages> + +</configure> Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/container-last.png ============================================================================== Binary file. No diff available. Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/container-open.png ============================================================================== Binary file. No diff available. Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/container.png ============================================================================== Binary file. No diff available. Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Sat Feb 18 02:11:58 2006 @@ -0,0 +1,115 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xml:lang="en" lang="en" + xmlns="http://www.w3.org/1999/xhtml"> +<head> + <title>CPSSkins Unit test file</title> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <script src="/++skin++cpsskins/@@/++resource++prototype.js" + type="text/javascript"></script> + <script src="/++skin++cpsskins/@@/++resource++ctal.js" + type="text/javascript"></script> + <script src="/++skin++cpsskins/@@/++resource++json.js" + type="text/javascript"></script> + <script src="/++skin++cpsskins/@@/++resource++cpsskins.js" + type="text/javascript"></script> + <link rel="stylesheet" type="text/css" + href="/++skin++cpsskins/@@/++resource++cpsskins.css" /> + + + <style type="text/css"> + .tree img { + vertical-align: middle; + } + + .tree a { + } + </style> + + <script type="text/javascript"> + function openContainer(event) { + var target = Event.element(event); + var nodeid = target.getAttribute("nodeid"); + } + + function closeContainer(event) { + var target = Event.element(event); + var nodeid = target.getAttribute("nodeid"); + } + + CPSSkins.registerHandlers( + {'open-container': openContainer, + 'close-container': closeContainer + } + ); + </script> + +</head> +<body> + + <h1>CPSSkins treeview</h1> + + <div id="area0"> + + <ins class="controller"> + {"id": "behaviour", + "type": "behaviour", + "rules": { + "img.open": { + "click": "open-container" + }, + "img.close": { + "click": "close-container" + } + }} + </ins> + + <ins class="model"> + {"id": "tree-state", + "data": { + "state": {} + }, + "storage": { + "id": 1, + "type": "local" + }} + </ins> + + <ins class="model"> + {"id": "tree-data", + "data": { + "items": [] + }, + "storage": { + "type": "remote", + "accessors": { + "get": "@@getTreeData" + } + }} + </ins> + + <ins class="model"> + {"id": "tree", + "data": { + "state": {"1": "open", "2": "open"}, + "items": [] + }, + "storage": { + "type": "compound", + "partitions": ["tree-state", "tree-data"] + } + }} + </ins> + + <ins class="view"> + {"model": "tree", + "controllers": ["behaviour"], + "widget": { + "template": "treeview_widget.html" + }} + </ins> + + </div> + +</body> +</html> Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/folder.png ============================================================================== Binary file. No diff available. Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/node-link-branch.png ============================================================================== Binary file. No diff available. Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/node-link-last.png ============================================================================== Binary file. No diff available. Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt ============================================================================== --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt Sat Feb 18 02:11:58 2006 @@ -0,0 +1,29 @@ + +<div class="tree" ctal:repeat="item items"> + + <span ctal:attributes="style + javascript:'margin-left:'+(item['depth']-1)*15+'px'"></span> + + <img class="close" ctal:attributes="nodeid item/id" + src="/++skin++cpsskins-test/@@/++resource++container-open.png" + ctal:condition="javascript:state[item['id']] == 'open' && + item['type'] == 'container'" /> + + <img class="open" ctal:attributes="nodeid item/id" + src="/++skin++cpsskins-test/@@/++resource++container.png" + ctal:condition="javascript:state[item['id']] != 'open' && + item['type'] == 'container'" /> + + <img src="/++skin++cpsskins-test/@@/node-link-branch.png" + ctal:condition="javascript:item['type'] != 'container' + && item['position'] != 'last'"/> + + <img src="/++skin++cpsskins-test/@@/node-link-last.png" + ctal:condition="javascript:item['type'] != 'container' + && item['position'] == 'last'"/> + + <img src="/++skin++cpsskins-test/@@/folder.png" /> + + <a ctal:content="item/title">ITEM</a> + +</div> -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins