provide a resources list node view; sort all relations using the title attribute

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1295 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2006-08-12 11:03:36 +00:00
parent 3bd8e181be
commit e05caedc38
4 changed files with 47 additions and 8 deletions

View file

@ -89,7 +89,9 @@ class ConceptView(BaseView):
cm = self.loopsRoot.getConceptManager()
hasType = cm.getTypePredicate()
standard = cm.getDefaultPredicate()
for r in self.context.getChildRelations():
rels = sorted(self.context.getChildRelations(),
key=(lambda x: x.second.title))
for r in rels:
if r.predicate == hasType:
# only show top-level entries for type instances:
skip = False
@ -101,11 +103,15 @@ class ConceptView(BaseView):
yield ConceptRelationView(r, self.request, contextIsSecond=True)
def parents(self):
for r in self.context.getParentRelations():
rels = sorted(self.context.getParentRelations(),
key=(lambda x: x.first.title))
for r in rels:
yield ConceptRelationView(r, self.request)
def resources(self):
for r in self.context.getResourceRelations():
rels = sorted(self.context.getResourceRelations(),
key=(lambda x: x.second.title))
for r in rels:
yield ConceptRelationView(r, self.request, contextIsSecond=True)
@Lazy
@ -238,11 +244,6 @@ class ConceptConfigureView(ConceptView):
result = [r for r in result if r.conceptType is None]
return self.viewIterator(result)
def viewIterator(self, objs):
request = self.request
for o in objs:
yield BaseView(o, request)
def conceptTypes(self):
return util.KeywordVocabulary([(t.token, t.title)
for t in ITypeManager(self.context).listTypes(('concept',))])

View file

@ -521,6 +521,14 @@
permission="zope.View"
/>
<zope:adapter
name="listresources"
for="loops.interfaces.INode
zope.publisher.interfaces.browser.IBrowserRequest"
provides="zope.interface.Interface"
factory="loops.browser.node.ListResources"
permission="zope.View"
/>
<!-- render file or image assigned to a node as target -->

View file

@ -242,6 +242,17 @@ class ListPages(NodeView):
return self
class ListResources(NodeView):
@Lazy
def macro(self):
return self.template.macros['listresources']
@Lazy
def view(self):
return self
class ConfigureView(NodeView):
""" An editing view for configuring a node, optionally creating
a target object.

View file

@ -80,6 +80,8 @@
</metal:body>
<!-- named views -->
<metal:body define-macro="listpages">
<div class="content-1"
tal:content="structure view/body"
@ -94,6 +96,23 @@
</metal:body>
<metal:resources define-macro="listresources"
tal:define="item view/target">
<div class="content-1"
tal:content="structure view/body"
tal:attributes="ondblclick python: item.openEditWindow('resources.html')">
Listing
</div><br />
<div tal:attributes="ondblclick python: item.openEditWindow('resources.html')">
<div tal:repeat="related item/resources">
<a href="#"
tal:attributes="href string:${view/url}/.target${related/uniqueId}"
tal:content="related/title">Resource Title</a>
</div>
</div>
</metal:resources>
<!-- menu -->
<metal:menu define-macro="menu">