[Zope3-checkins] CVS: ZopeProducts/RotterdamSprint - XmlObjectView.py:1.9 template.pt:1.22 zope3.css:1.14 xmltree.js:1.9

Godefroid Chapelle gotcha@swing.be
Wed, 11 Dec 2002 06:28:49 -0500


Update of /cvs-repository/ZopeProducts/RotterdamSprint
In directory cvs.zope.org:/tmp/cvs-serv21496

Modified Files:
	XmlObjectView.py template.pt zope3.css xmltree.js 
Log Message:
add root folder which was missing in the tree
clean css and pt for breadcrumbs


=== ZopeProducts/RotterdamSprint/XmlObjectView.py 1.8 => 1.9 ===
--- ZopeProducts/RotterdamSprint/XmlObjectView.py:1.8	Tue Dec 10 16:46:58 2002
+++ ZopeProducts/RotterdamSprint/XmlObjectView.py	Wed Dec 11 06:28:48 2002
@@ -4,7 +4,7 @@
 from Zope.ComponentArchitecture import queryView
 
 class XmlObjectView(BrowserView):
-    """Provide a user interface for editing a contact"""
+    """Provide a xml interface for dynamic navigation tree in UI"""
 
     __used_for__ = IReadContainer
 
@@ -28,10 +28,15 @@
         return u'<?xml version="1.0" ?><children> %s </children>' % self.children_utility()
 
     def singleBranchTree(self, root=''):
-        """ """
+        """Return an XML document that contains the siblings and parents of an object.
+        
+           There is only one branch expanded, in other words, the tree is filled with the object,
+           its siblings and its parents with their respective siblings. 
+        """
         result = ''
         oldItem = self.context
         for item in getParents(self.context):
+            # skip skin if present
             if item == oldItem:
                     continue
             subItems = []
@@ -47,5 +52,9 @@
                     subItems.append('<item name="%s" />' % name)
             result = ' '.join(subItems)
             oldItem = item
+        # do not forget root folder
+        icon = queryView(oldItem, 'zmi_icon', self.request)
+        #XXX should not hardcode root folder name string
+        result = '<collection name="%s" length="%s" icon_url="%s">%s</collection>' % ('[top]', len(oldItem), icon.url(), result)    
         self.request.response.setHeader('Content-Type', 'text/xml')
         return u'<?xml version="1.0" ?><children> %s </children>' % result


=== ZopeProducts/RotterdamSprint/template.pt 1.21 => 1.22 ===
--- ZopeProducts/RotterdamSprint/template.pt:1.21	Tue Dec 10 12:43:43 2002
+++ ZopeProducts/RotterdamSprint/template.pt	Wed Dec 11 06:28:48 2002
@@ -43,33 +43,14 @@
     </div>
 
     <div id="breadcrumbs"
-         metal:define-macro="breadcrumbs">
-
-      Location:&nbsp;
-
-      <tal:block repeat="breadcrumb context/@@absolute_url/breadcrumbs">
-        <a href=""
+         metal:define-macro="breadcrumbs"> Location:&nbsp;<tal:block repeat="breadcrumb context/@@absolute_url/breadcrumbs"><a href=""
           tal:condition="repeat/breadcrumb/start"
-          tal:content="string:[top] /"
-          tal:attributes="href string:${breadcrumb/url}/@@SelectedManagementView.html">
-
-          breadcrumb item
-
-        </a>
-
-        <a href=""
+          tal:content="string:[top]"
+          tal:attributes="href string:${breadcrumb/url}/@@SelectedManagementView.html">XXX should not hardcode root folder name string</a><a href=""
            tal:condition="not:repeat/breadcrumb/start"
-           tal:content="string:${breadcrumb/name} /"
+           tal:content="string:${breadcrumb/name}"
            tal:attributes="
-           href string:${breadcrumb/url}/@@SelectedManagementView.html">
-
-          breadcrumb item
-
-        </a>
-
-      </tal:block>
-
-    </div>
+           href string:${breadcrumb/url}/@@SelectedManagementView.html">breadcrumb item</a>/</tal:block></div>
 
 
     <div id="navigators">


=== ZopeProducts/RotterdamSprint/zope3.css 1.13 => 1.14 ===
--- ZopeProducts/RotterdamSprint/zope3.css:1.13	Tue Dec 10 16:38:01 2002
+++ ZopeProducts/RotterdamSprint/zope3.css	Wed Dec 11 06:28:48 2002
@@ -30,7 +30,7 @@
     font-size: 100%;
 }
 
-a {
+a, #navtreecontents title {
 	text-decoration: none;
     color: #436976;
     background-color: transparent;
@@ -225,13 +225,13 @@
 /*  Styles for xmltree
 */
 
-title {
+#navtreecontents title {
 	   display: inline;
 	   cursor: pointer;
 	   height: 18px;
 		 }
 
-expand {
+#navtreecontents expand {
   	   background-image: url("pl.gif");
   	   background-repeat: no-repeat;
   	   padding-left: 15px;
@@ -239,17 +239,17 @@
 	   cursor: pointer;
                 }
                  
-icon {
+#navtreecontents icon {
   	   background-repeat: no-repeat;
   	   padding-left: 18px;
 	   display: inline;
 	   cursor: auto;
                 }
                  
-collection {
+#navtreecontents collection {
 	   display: block;
 	   margin-left: 15px;
-/*	   border: red solid 1pt; */
+/*	   border: red solid 1pt;  */
 	   height: auto;
 }
 
@@ -270,7 +270,9 @@
 
 #breadcrumbs {
     border-bottom: 1px solid black;
-    color: blue;
+/*    color: blue; */
+    padding-bottom: 1px;
+    padding-top: 1px;
 }
 
 #navigators {
@@ -439,7 +441,8 @@
     text-align: left;
 }
 
-table.listing a:hover {
+/*table.listing a:hover { */
+a:hover {
     text-decoration: underline;
 }
 


=== ZopeProducts/RotterdamSprint/xmltree.js 1.8 => 1.9 ===
--- ZopeProducts/RotterdamSprint/xmltree.js:1.8	Tue Dec 10 16:38:01 2002
+++ ZopeProducts/RotterdamSprint/xmltree.js	Wed Dec 11 06:28:48 2002
@@ -6,7 +6,6 @@
 var EXPAND = 'EXPAND';
 var XML_CHILDREN_VIEW = 'children.xml';
 var SINGLE_BRANCH_TREE_VIEW = 'singleBranchTree.xml';
-//var CONTENT_VIEW = '';
 var CONTENT_VIEW = '@@contents.html';
 var baseurl;
 
@@ -39,6 +38,7 @@
         if (elem.id == 'navtree') return;
         if (isTitle(elem)) {
 	        elem.style.textDecoration = 'underline';
+                window.status = getTargetURL(elem.parentNode.parentNode.parentNode);
 	        }
         }
 
@@ -66,6 +66,7 @@
         if (elem.id == 'navtree') return;
         if (isTitle(elem)) {
 	        elem.style.textDecoration = 'none';
+                window.status = '';
 	        }
         }
 
@@ -118,15 +119,21 @@
         expand.style.backgroundImage = 'url("' + baseurl + '@@/' + icon + '")';
         }
 
+
+function getTargetURL(elem) {
+        var location_href = baseurl;
+	location_href = location_href + elem.getAttribute('name');
+	location_href = location_href + CONTENT_VIEW;
+        return location_href;
+        }
+
 function treeclicked (e) {
         prettydump('treeclicked', LG_TRACE);
         var elem = getTreeEventTarget(e);
         prettydump(elem.tagName, LG_DEBUG);
         if (elem.id == 'navtree') return;
         if (isTitle(elem)) {
-	        location_href = baseurl + elem.parentNode.parentNode.parentNode.getAttribute('name') + '/' + CONTENT_VIEW;
-	        prettydump(location_href, LG_DEBUG);
-	        location.href=location_href;
+	        location.href = getTargetURL(elem.parentNode.parentNode.parentNode);
 	        }
 
         // If this collection is empty and should have data, go get it
@@ -138,7 +145,7 @@
                         prettydump('isEmpty');
 
                         var name = elem.getAttribute('name');
-                        var url = baseurl + name + '/' + XML_CHILDREN_VIEW;
+                        var url = baseurl + name + XML_CHILDREN_VIEW;
                         var data = loadtreexml(url);
                         createAndAddNodes(data, elem, 0);
                         elem.setAttribute('isEmpty', 0);
@@ -230,9 +237,6 @@
 
 function createAndAddNodes(sourceNode, targetNode, deep) {
         var basename = targetNode.getAttribute('name');
-        if (basename != '')
-                basename = basename + '/';
-
         var items = getChildCollectionNodes(sourceNode);
         var numitems = items.length;
         for (var i=0; i< numitems; i++) {
@@ -262,35 +266,59 @@
         return result;
         }
 
-function createCollection(curritem, basename, deep) {
-        var currname = curritem.getAttribute('name');
-        var icon_url = curritem.getAttribute('icon_url');        
-        var newelem = document.createElement(curritem.tagName);
+
+function createCollectionDescription(title, icon_url) {
         // create elem for plus/minus icon
         var expandElem = document.createElement('expand');
-        newelem.appendChild(expandElem);
         // create elem for item icon
         var iconElem = document.createElement('icon');
         expandElem.appendChild(iconElem);
         iconElem.style.backgroundImage = 'url("' + baseurl + icon_url + '")';
         // create title
         var titleelem = document.createElement('title');
-        var newtextnode = document.createTextNode(currname);
+        var newtextnode = document.createTextNode(title);
+        
         titleelem.appendChild(newtextnode);
+        
         iconElem.appendChild(titleelem);
-        newelem.setAttribute('name',basename + currname);
+
+        return expandElem;
+        }
+
+function createCollection(curritem, basename, deep) {
+        var currname = curritem.getAttribute('name');
+        var length = curritem.getAttribute('length');
+        var title = currname + '(' + length + ')';
+        var icon_url = curritem.getAttribute('icon_url');  
+
+        var newelem = document.createElement(curritem.tagName);
+        
+        var expandElem = createCollectionDescription(title, icon_url);
+        newelem.appendChild(expandElem);
+
+        var elemName;
+        //XXX should not hardcode root folder name string
+        if (currname == '[top]') {
+                elemName = basename;
+                newelem.style.marginLeft = '0px';
+                }
+        else {
+                elemName = basename + currname + '/';
+                }
+        newelem.setAttribute('name', elemName);
 
         if (deep) {
                 var children = getChildCollectionNodes(curritem);
                 var numchildren = children.length;
                 for (var i=0; i< numchildren; i++) {
-                        var newchild = createCollection(children[i], basename + currname + '/', deep);
+                        var newchild = createCollection(children[i], elemName, deep);
                         prettydump("add " + newelem.tagName, LG_DEBUG);
                         newelem.appendChild(newchild);
                         }
                 if (numchildren) {
 	                newelem.setAttribute('isCollapsed', 0);
 	                newelem.setAttribute('isEmpty', 0);
+                        changeIcon(newelem, "mi.gif");
                         }
                 else {
 	                newelem.setAttribute('isCollapsed', 1);