From b2b442861881b827459d677dd8b41cfce2b55f3e Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 28 Oct 2012 10:10:24 +0100 Subject: [PATCH] book section: show navigation links to previous and next sections --- compound/book/browser.py | 31 +++++++++++++++++++++++++++++++ compound/book/view_macros.pt | 18 ++++++++++++++++++ knowledge/browser.py | 2 +- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/compound/book/browser.py b/compound/book/browser.py index 533e12d..6b55e5f 100644 --- a/compound/book/browser.py +++ b/compound/book/browser.py @@ -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'] diff --git a/compound/book/view_macros.pt b/compound/book/view_macros.pt index cef53c2..e37ddf4 100644 --- a/compound/book/view_macros.pt +++ b/compound/book/view_macros.pt @@ -13,6 +13,21 @@ + +
+ + < + + > + +
+
@@ -57,6 +72,9 @@
+
+ +
diff --git a/knowledge/browser.py b/knowledge/browser.py index 8a7a281..fd9a8ed 100644 --- a/knowledge/browser.py +++ b/knowledge/browser.py @@ -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',