From 03e150080975714735499284f738475e782f64d2 Mon Sep 17 00:00:00 2001 From: helmutm Date: Fri, 13 Jan 2006 14:04:01 +0000 Subject: [PATCH] Added smart editing upon click git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1006 fd906abe-77d9-0310-91a1-e0d9ade77398 --- README.txt | 12 ++++--- browser/configure.zcml | 2 ++ browser/contents.pt | 32 ++++++++--------- browser/edit.gif | Bin 0 -> 879 bytes browser/edit.pt | 79 +++++++++++++++++++++++++++++++++++++++++ browser/node.pt | 28 +++++++++++++-- browser/node.py | 10 +++--- 7 files changed, 136 insertions(+), 27 deletions(-) create mode 100644 browser/edit.gif create mode 100644 browser/edit.pt diff --git a/README.txt b/README.txt index e4d2265..d38ed40 100755 --- a/README.txt +++ b/README.txt @@ -10,7 +10,7 @@ loops - Linked Objects for Organization and Processing Services >>> from zope.app import zapi >>> from zope.app.tests import ztapi >>> from zope.publisher.browser import TestRequest - + Concepts and Relations ====================== @@ -123,6 +123,10 @@ thus provide the presentation space to concepts and resources. We first need a view manager: >>> from loops.view import ViewManager, Node + >>> from zope.security.checker import NamesChecker, defineChecker + >>> nodeChecker = NamesChecker(('body',)) + >>> defineChecker(Node, nodeChecker) + >>> loops['views'] = ViewManager() >>> views = loops['views'] @@ -218,7 +222,7 @@ Node views 'selected': True, 'title': u'Menu'} >>> view.content() {'url': 'http://127.0.0.1/loops/views/m1', 'body': u'', 'items': [], - 'title': u'Menu'} + 'editable': False, 'title': u'Menu'} >>> view = NodeView(m11, TestRequest()) >>> view.menu() @@ -229,8 +233,8 @@ Node views >>> view.content() {'url': 'http://127.0.0.1/loops/views/m1/m11', 'body': u'', 'items': [{'url': 'http://127.0.0.1/loops/views/m1/m11/m112', - 'body': u'', 'items': [], 'title': u'Zope 3'}], - 'title': u'Zope'} + 'body': u'', 'items': [], 'editable': False, 'title': u'Zope 3'}], + 'editable': False, 'title': u'Zope'} Ordering Nodes -------------- diff --git a/browser/configure.zcml b/browser/configure.zcml index 6445acc..3a8d5a3 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -8,6 +8,7 @@ + @@ -228,6 +229,7 @@ schema="loops.interfaces.INode" fields="title description nodeType body" for="loops.interfaces.INode" + template="edit.pt" permission="zope.ManageContent" menu="zmi_views" title="Edit"> diff --git a/browser/contents.pt b/browser/contents.pt index efa9557..505f090 100644 --- a/browser/contents.pt +++ b/browser/contents.pt @@ -149,22 +149,6 @@ i18n:domain="zope" /> -
- - - - - -
-
+ + + + + +
+
diff --git a/browser/edit.gif b/browser/edit.gif new file mode 100644 index 0000000000000000000000000000000000000000..428e9bfbb2051ddaf2a283680d1bf2e65db21b10 GIT binary patch literal 879 zcmeH`y-OQm0Eb^S+E6GagNtNPDh{RKpwbpINQbILu(Ti!E`q3tR0p9$2L*3Y5HbiM z2(1}Ju!}+$i%Sy`#g9^|;#Xp7?k@NF-h21H@8#}tms9_Z(&sPuJwJH5dfvQzH539N zPy~QdjSw}x9P|%c4@bb+cB^41Wq-yrjgymomc2ll@OCPm&7R3Zj?Z7YuI>B2jzmhK zs<6JtD01GisOLE#;ZusSu25nl~QC`#I|XvWI>fHmp#ub>AG}$oc=JrYMQ#P%lFpq*x3D;|NKi2G}?g*0EWTy z2dRf9K(H6=2P54ZD?jIgwJ9MMYp8nqBHGrJZb*eA(fY@sSVi@d#YZ*PKyouRTN&v5 j(wlfU+q3j+sJSWpe&lssc%u3HZ)R`jYiDgu0Cd~|A&(fp literal 0 HcmV?d00001 diff --git a/browser/edit.pt b/browser/edit.pt new file mode 100644 index 0000000..5a92a02 --- /dev/null +++ b/browser/edit.pt @@ -0,0 +1,79 @@ + + + +
+ +
+ +
+ + + + + + +
+ +

Edit something

+ +

+ +

+ There are 6 input errors. +

+ +
+
+ +
+
Extra top
+
+
+ +
+ +
+ +
+
Extra bottom
+
+
+
+
+ +
+
+ +
+
+
+
+ +
+ + + +
+ +
+ + + diff --git a/browser/node.pt b/browser/node.pt index 3a06417..57338de 100644 --- a/browser/node.pt +++ b/browser/node.pt @@ -10,7 +10,7 @@ @import url(view.css); - +
The body
+ tal:define="onclick string: + zmi=window.open('${item/url}/@@edit.html', 'zmi');; + zmi.focus();; return false;;" + tal:attributes="class string:content-$level; + onclick python: item['editable'] and onclick or ''" + tal:content="structure body"> + The body +
@@ -61,6 +67,22 @@
+ + + + + + + + + + diff --git a/browser/node.py b/browser/node.py index a7c39d4..a2423d7 100644 --- a/browser/node.py +++ b/browser/node.py @@ -27,6 +27,7 @@ from zope.app import zapi from zope.app.container.browser.contents import JustContents from zope.app.dublincore.interfaces import ICMFDublinCore from zope.proxy import removeAllProxies +from zope.security import canAccess, canWrite from zope.security.proxy import removeSecurityProxy from loops.interfaces import IConcept @@ -62,6 +63,7 @@ class NodeView(object): result = {'title': item.title, 'url': zapi.absoluteURL(item, self.request), 'body': self.render(item.body), + 'editable': canWrite(item, 'body'), 'items': [self.content(child) for child in item.getTextItems()]} return result @@ -107,19 +109,19 @@ class OrderedContainerView(JustContents): return True return False - def moveDown(self, ids, delta=1): + def moveDown(self, ids=[], delta=1): self.context.moveSubNodesByDelta(ids, int(delta)) self.request.response.redirect(self.url + '/contents.html') - def moveUp(self, ids, delta=1): + def moveUp(self, ids=[], delta=1): self.context.moveSubNodesByDelta(ids, -int(delta)) self.request.response.redirect(self.url + '/contents.html') - def moveToBottom(self, ids): + def moveToBottom(self, ids=[]): self.context.moveSubNodesByDelta(ids, len(self.context)) self.request.response.redirect(self.url + '/contents.html') - def moveToTop(self, ids): + def moveToTop(self, ids=[]): self.context.moveSubNodesByDelta(ids, -len(self.context)) self.request.response.redirect(self.url + '/contents.html')