diff --git a/gen/__init__.py b/gen/__init__.py index 233d375..2236535 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -1671,7 +1671,8 @@ class Ref(Type): specificWritePermission=False, width=None, height=5, maxChars=None, colspan=1, master=None, masterValue=None, focus=False, historized=False, mapping=None, label=None, - queryable=False, queryFields=None, queryNbCols=1): + queryable=False, queryFields=None, queryNbCols=1, + navigable=False): self.klass = klass self.attribute = attribute # May the user add new objects through this ref ? @@ -1737,6 +1738,8 @@ class Ref(Type): self.queryFields = queryFields # The search screen will have this number of columns self.queryNbCols = queryNbCols + # Within the portlet, will referred elements appear ? + self.navigable = navigable Type.__init__(self, validator, multiplicity, index, default, optional, editDefault, show, page, group, layouts, move, indexed, False, specificReadPermission, specificWritePermission, diff --git a/gen/mixins/__init__.py b/gen/mixins/__init__.py index 04d63b6..51594df 100644 --- a/gen/mixins/__init__.py +++ b/gen/mixins/__init__.py @@ -737,6 +737,8 @@ class BaseMixin: else: phase = phases[typePhase] phase.addPage(appyType, self, layoutType) + if (appyType.type == 'Ref') and appyType.navigable: + phase.addPageLinks(appyType, self) # Remove phases that have no visible page for i in range(len(res)-1, -1, -1): if not res[i]['pages']: diff --git a/gen/model.py b/gen/model.py index 0ac4c3b..d3d45ea 100644 --- a/gen/model.py +++ b/gen/model.py @@ -199,7 +199,7 @@ class Page(ModelClass): def showSubPages(self): pass pages = gen.Ref(None, multiplicity=(0,None), add=True, link=False, back=gen.Ref(attribute='parent', show=False), - show=showSubPages) + show=showSubPages, navigable=True) Page.pages.klass = Page setattr(Page, Page.pages.back.attribute, Page.pages.back) diff --git a/gen/ui/portlet.pt b/gen/ui/portlet.pt index a714e97..dfa2563 100644 --- a/gen/ui/portlet.pt +++ b/gen/ui/portlet.pt @@ -18,7 +18,7 @@ - + One section for every searchable root class. @@ -99,58 +99,48 @@ This macro displays, within the portlet, the navigation tree for the currently shown object, made of phases and contained pages. - - + tal:condition="python: phases" width="100%"> The box containing phase-related information
-
- - A single page in the phase - - - - + The title of the phase +
+
+ The page(s) within the phase +
- - -
+ + 1st line: page name and icons + + + + + 2nd line: links + + + -
+ + + + +
- Several pages in the phase - -
-
- - - - - -
- - - - -
-
+ + +
The down arrow pointing to the next phase (if any) @@ -159,4 +149,3 @@ -
diff --git a/gen/utils.py b/gen/utils.py index 950275b..60beb85 100644 --- a/gen/utils.py +++ b/gen/utils.py @@ -114,6 +114,15 @@ class PhaseDescr(Descr): self.previousPhase = None self.nextPhase = None + def addPageLinks(self, appyType, obj): + '''If p_appyType is a navigable Ref, we must add, within self.pagesInfo, + those links.''' + if appyType.page.name in self.hiddenPages: return + infos = [] + for obj in appyType.getValue(obj, type="zobjects"): + infos.append({'title': obj.title, 'url':obj.absolute_url()}) + self.pagesInfo[appyType.page.name]['links'] = infos + def addPage(self, appyType, obj, layoutType): '''Adds page-related information in the phase.''' # If the page is already there, we have nothing more to do. diff --git a/gen/wrappers/PageWrapper.py b/gen/wrappers/PageWrapper.py new file mode 100644 index 0000000..bdf49d5 --- /dev/null +++ b/gen/wrappers/PageWrapper.py @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +from appy.gen.wrappers import AbstractWrapper + +# ------------------------------------------------------------------------------ +class PageWrapper(AbstractWrapper): + + def validate(self, new, errors): + '''Inter-field validation.''' + return self._callCustom('validate', new, errors) + + def showSubPages(self): + '''Show the sub-pages.''' + if self.user.has_role('Manager'): return 'view' + + def onEdit(self, created): + return self._callCustom('onEdit', created) +# ------------------------------------------------------------------------------