book section: show navigation links to previous and next sections
This commit is contained in:
parent
3bcc61880c
commit
b2b4428618
3 changed files with 50 additions and 1 deletions
|
@ -41,6 +41,10 @@ book_template = ViewPageTemplateFile('view_macros.pt')
|
|||
|
||||
class Base(object):
|
||||
|
||||
@Lazy
|
||||
def book_macros(self):
|
||||
return book_template.macros
|
||||
|
||||
@Lazy
|
||||
def isPartOfPredicate(self):
|
||||
return self.conceptManager['ispartof']
|
||||
|
@ -50,6 +54,29 @@ class Base(object):
|
|||
for p in self.context.getParents([self.isPartOfPredicate]):
|
||||
return self.nodeView.getViewForTarget(p)
|
||||
|
||||
@Lazy
|
||||
def neighbours(self):
|
||||
pred = succ = None
|
||||
parent = self.breadcrumbsParent
|
||||
if parent is not None:
|
||||
myself = None
|
||||
children = list(parent.context.getChildren([self.isPartOfPredicate]))
|
||||
for idx, c in enumerate(children):
|
||||
if c == self.context:
|
||||
if idx > 0:
|
||||
pred = self.nodeView.getViewForTarget(children[idx-1])
|
||||
if idx < len(children) - 1:
|
||||
succ = self.nodeView.getViewForTarget(children[idx+1])
|
||||
return pred, succ
|
||||
|
||||
@Lazy
|
||||
def predecessor(self):
|
||||
return self.neighbours[0]
|
||||
|
||||
@Lazy
|
||||
def successor(self):
|
||||
return self.neighbours[1]
|
||||
|
||||
@Lazy
|
||||
def tabview(self):
|
||||
if self.editable:
|
||||
|
@ -73,6 +100,10 @@ class SectionView(Base, ConceptView):
|
|||
def documentTypeType(self):
|
||||
return self.conceptManager['documenttype']
|
||||
|
||||
@Lazy
|
||||
def showNavigation(self):
|
||||
return self.typeOptions.show_navigation
|
||||
|
||||
@Lazy
|
||||
def sectionType(self):
|
||||
return self.conceptManager['section']
|
||||
|
|
|
@ -13,6 +13,21 @@
|
|||
|
||||
|
||||
<metal:section define-macro="section">
|
||||
<metal:navigation define-macro="navigation"
|
||||
tal:condition="item/showNavigation">
|
||||
<div tal:define="parent nocall:item/breadcrumbsParent;
|
||||
pred nocall:item/predecessor;
|
||||
succ nocall:item/successor">
|
||||
<span tal:condition="nocall:pred">
|
||||
<a tal:attributes="href pred/targetUrl"
|
||||
tal:content="pred/title" /> < </span>
|
||||
<a tal:attributes="href parent/targetUrl"
|
||||
tal:content="parent/title" />
|
||||
<span tal:condition="nocall:succ"> >
|
||||
<a tal:attributes="href succ/targetUrl"
|
||||
tal:content="succ/title" /></span>
|
||||
</div>
|
||||
</metal:navigation>
|
||||
<metal:info use-macro="view/concept_macros/concepttitle" />
|
||||
<div tal:repeat="related item/textResources">
|
||||
<div class="span-4">
|
||||
|
@ -57,6 +72,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br style="clear: both" />
|
||||
<metal:navigation use-macro="item/book_macros/navigation" />
|
||||
<br />
|
||||
</metal:section>
|
||||
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ actions.register('editTopic', 'portlet', DialogAction,
|
|||
|
||||
actions.register('createQualification', 'portlet', DialogAction,
|
||||
title=_(u'Create Qualification Record...'),
|
||||
description=_(u'Create a work item for this person.'),
|
||||
description=_(u'Create a qualification record for this person.'),
|
||||
viewName='create_qualification.html',
|
||||
dialogName='createQualification',
|
||||
prerequisites=['registerDojoDateWidget', 'registerDojoNumberWidget',
|
||||
|
|
Loading…
Add table
Reference in a new issue