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:
parent
3bd8e181be
commit
e05caedc38
4 changed files with 47 additions and 8 deletions
|
@ -89,7 +89,9 @@ class ConceptView(BaseView):
|
||||||
cm = self.loopsRoot.getConceptManager()
|
cm = self.loopsRoot.getConceptManager()
|
||||||
hasType = cm.getTypePredicate()
|
hasType = cm.getTypePredicate()
|
||||||
standard = cm.getDefaultPredicate()
|
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:
|
if r.predicate == hasType:
|
||||||
# only show top-level entries for type instances:
|
# only show top-level entries for type instances:
|
||||||
skip = False
|
skip = False
|
||||||
|
@ -101,11 +103,15 @@ class ConceptView(BaseView):
|
||||||
yield ConceptRelationView(r, self.request, contextIsSecond=True)
|
yield ConceptRelationView(r, self.request, contextIsSecond=True)
|
||||||
|
|
||||||
def parents(self):
|
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)
|
yield ConceptRelationView(r, self.request)
|
||||||
|
|
||||||
def resources(self):
|
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)
|
yield ConceptRelationView(r, self.request, contextIsSecond=True)
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
|
@ -238,11 +244,6 @@ class ConceptConfigureView(ConceptView):
|
||||||
result = [r for r in result if r.conceptType is None]
|
result = [r for r in result if r.conceptType is None]
|
||||||
return self.viewIterator(result)
|
return self.viewIterator(result)
|
||||||
|
|
||||||
def viewIterator(self, objs):
|
|
||||||
request = self.request
|
|
||||||
for o in objs:
|
|
||||||
yield BaseView(o, request)
|
|
||||||
|
|
||||||
def conceptTypes(self):
|
def conceptTypes(self):
|
||||||
return util.KeywordVocabulary([(t.token, t.title)
|
return util.KeywordVocabulary([(t.token, t.title)
|
||||||
for t in ITypeManager(self.context).listTypes(('concept',))])
|
for t in ITypeManager(self.context).listTypes(('concept',))])
|
||||||
|
|
|
@ -521,6 +521,14 @@
|
||||||
permission="zope.View"
|
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 -->
|
<!-- render file or image assigned to a node as target -->
|
||||||
|
|
||||||
|
|
|
@ -242,6 +242,17 @@ class ListPages(NodeView):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
||||||
|
class ListResources(NodeView):
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def macro(self):
|
||||||
|
return self.template.macros['listresources']
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def view(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class ConfigureView(NodeView):
|
class ConfigureView(NodeView):
|
||||||
""" An editing view for configuring a node, optionally creating
|
""" An editing view for configuring a node, optionally creating
|
||||||
a target object.
|
a target object.
|
||||||
|
|
|
@ -80,6 +80,8 @@
|
||||||
</metal:body>
|
</metal:body>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- named views -->
|
||||||
|
|
||||||
<metal:body define-macro="listpages">
|
<metal:body define-macro="listpages">
|
||||||
<div class="content-1"
|
<div class="content-1"
|
||||||
tal:content="structure view/body"
|
tal:content="structure view/body"
|
||||||
|
@ -94,6 +96,23 @@
|
||||||
</metal:body>
|
</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 -->
|
<!-- menu -->
|
||||||
|
|
||||||
<metal:menu define-macro="menu">
|
<metal:menu define-macro="menu">
|
||||||
|
|
Loading…
Add table
Reference in a new issue