Added smart editing upon click

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1006 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-01-13 14:04:01 +00:00
parent 4962810373
commit 03e1500809
7 changed files with 136 additions and 27 deletions

View file

@ -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
--------------

View file

@ -8,6 +8,7 @@
<!-- resources -->
<resource name="node.css" file="node.css" />
<resource name="edit.gif" file="edit.gif" />
<!-- macros -->
@ -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">

View file

@ -149,22 +149,6 @@
i18n:domain="zope"
/>
<div tal:condition="view/orderable">
<input type="submit" name="move_top" value="Top"
i18n:attributes="value container-movetop-button"
i18n:domain="zope" />
<input type="submit" name="move_up" value="Up"
i18n:attributes="value container-moveup-button"
i18n:domain="zope" />
<input type="submit" name="move_down" value="Down"
i18n:attributes="value container-moveup-button"
i18n:domain="zope" />
<input type="submit" name="move_bottom" value="Bottom"
i18n:attributes="value container-movebottom-button"
i18n:domain="zope" />
<input type="hidden" name="delta" value="1" />
</div>
<div tal:condition="view/hasAdding" tal:omit-tag="">
<div tal:omit-tag=""
tal:define="adding nocall:context/@@+;
@ -187,6 +171,22 @@
</div>
</div>
<div tal:condition="view/orderable">
<input type="submit" name="move_top" value="Top"
i18n:attributes="value container-movetop-button"
i18n:domain="zope" />
<input type="submit" name="move_up" value="Up"
i18n:attributes="value container-moveup-button"
i18n:domain="zope" />
<input type="text" size="2" name="delta" value="1" />
<input type="submit" name="move_down" value="Down"
i18n:attributes="value container-moveup-button"
i18n:domain="zope" />
<input type="submit" name="move_bottom" value="Bottom"
i18n:attributes="value container-movebottom-button"
i18n:domain="zope" />
</div>
</div>
<div tal:condition="view/specialButtons">

BIN
browser/edit.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

79
browser/edit.pt Normal file
View file

@ -0,0 +1,79 @@
<tal:tag condition="view/update"/>
<html metal:use-macro="context/@@standard_macros/view"
i18n:domain="zope">
<body>
<div metal:fill-slot="body">
<div metal:define-macro="body">
<form action="." tal:attributes="action request/URL" method="post"
enctype="multipart/form-data">
<input type="hidden" name="form_submitted" value="true" />
<tal:control condition="request/form_submitted|nothing">
<script language="JavaScript">
if (typeof(opener) != 'undefined' && opener != null) {
opener.location.reload();
opener.focus();
}
</script>
</tal:control>
<div metal:define-macro="formbody">
<h3 tal:condition="view/label"
tal:content="view/label"
metal:define-slot="heading"
i18n:translate=""
>Edit something</h3>
<p tal:define="status view/update"
tal:condition="status"
tal:content="status"
i18n:translate=""/>
<p tal:condition="view/errors" i18n:translate="">
There are <strong tal:content="python:len(view.errors)"
i18n:name="num_errors">6</strong> input errors.
</p>
<div metal:define-slot="extra_info" tal:replace="nothing">
</div>
<div class="row"
metal:define-slot="extra_top" tal:replace="nothing">
<div class="label">Extra top</div>
<div class="field"><input type="text" style="width:100%" /></div>
</div>
<div metal:use-macro="context/@@form_macros/widget_rows" />
<div class="separator"></div>
<div class="row"
metal:define-slot="extra_bottom" tal:replace="nothing">
<div class="label">Extra bottom</div>
<div class="field"><input type="text" style="width:100%" /></div>
</div>
<div class="separator"></div>
</div>
<div class="row">
<div class="controls">
<input type="submit" name="UPDATE_SUBMIT" value="Change"
i18n:attributes="value submit-button;" />
</div>
</div>
<div class="row" metal:define-slot="extra_buttons" tal:replace="nothing">
</div>
<div class="separator"></div>
</form>
</div>
</div>
</body>
</html>

View file

@ -10,7 +10,7 @@
@import url(view.css);
</style>
</metal:css>
<metal:body fill-slot="body">
<tal:content define="item view/content;
@ -20,8 +20,14 @@
<tal:body define="body item/body"
condition="body">
<div class="content-1"
tal:content="structure body"
tal:attributes="class string:content-$level">The body</div>
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
</div>
</tal:body>
<tal:sub define="level python:level+1">
<tal:items repeat="item item/items">
@ -61,6 +67,22 @@
</tal:menu>
</div>
</body>
</html>
</tal:show>
<tal:hide condition="nothing">
<metal:editlink define-macro="editlink">
<a target="zmi"
tal:define="url string:${item/url}/@@edit.html'"
tal:attributes="href url;
onclick string:
zmi=window.open('$url', 'zmi');;
zmi.focus();; return false;;">
<img src="edit.gif"
tal:attributes="src context/++resource++edit.gif" border="0" />
</a>
</metal:editlink>
</tal:hide>

View file

@ -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')