[gen] Ergonomic improvements: added a breadcrumb, more compact design.

This commit is contained in:
Gaetan Delannay 2012-11-29 20:45:21 +01:00
parent 3ec1270fc2
commit 387fbaea7c
11 changed files with 137 additions and 99 deletions

View file

@ -245,7 +245,10 @@ class ToolMixin(BaseMixin):
elems = sortMethod(elems)
return [importParams['headers'], elems]
def showPortlet(self, context):
def showPortlet(self, context, layoutType):
'''When must the portlet be shown?'''
# Not on 'edit' pages.
if layoutType == 'edit': return
if context.id == 'ui': context = context.getParentNode()
res = True
if hasattr(context.aq_base, 'appy'):
@ -424,17 +427,29 @@ class ToolMixin(BaseMixin):
return '<acronym title="%s">%s</acronym>' % \
(text, uText[:width].encode('utf-8') + '...')
def getPublishedObject(self):
def getLayoutType(self):
'''Guess the current layout type, according to actual URL.'''
actualUrl = self.REQUEST['ACTUAL_URL']
res = ''
if actualUrl.endswith('/ui/view'):
res = 'view'
elif actualUrl.endswith('/ui/edit') or actualUrl.endswith('/do'):
res = 'edit'
return res
def getPublishedObject(self, layoutType):
'''Gets the currently published object, if its meta_class is among
application classes.'''
req = self.REQUEST
# If we are querying object, there is no published object (the truth is:
# the tool is the currently published object but we don't want to
# consider it this way).
if not req['ACTUAL_URL'].endswith('/ui/view'): return
# In some situations (ie, we are querying objects), the published object
# according to Zope is the tool, but we don't want to consider it that
# way.
if layoutType not in ('edit', 'view'): return
obj = self.REQUEST['PUBLISHED']
parent = obj.getParentNode()
if parent.id == 'ui': obj = parent.getParentNode()
# If URL is a /do, published object is the "do" method.
if type(obj) == types.MethodType: obj = obj.im_self
else:
parent = obj.getParentNode()
if parent.id == 'ui': obj = parent.getParentNode()
if obj.meta_type in self.getProductConfig().attributes: return obj
def getZopeClass(self, name):

View file

@ -822,6 +822,11 @@ class BaseMixin:
break
return phase
else:
# Return an empty list if we have a single, link-free page within
# a single phase.
if (len(res) == 1) and (len(res[0]['pages']) == 1) and \
not res[0]['pagesInfo'][res[0]['pages'][0]].get('links'):
return None
return res
def getIcons(self):
@ -1434,7 +1439,16 @@ class BaseMixin:
# Not-Managers can't navigate back to the tool
if (parent.id == 'config') and not self.getUser().has_role('Manager'):
return False
if parent.meta_type != 'Folder': return parent
if parent.meta_type not in ('Folder', 'Temporary Folder'): return parent
def getBreadCrumb(self):
'''Gets breadcrumb info about this object and its parents.'''
res = [{'url': self.absolute_url(),
'title': self.getFieldValue('title', layoutType='view')}]
parent = self.getParent()
if parent:
res = parent.getBreadCrumb() + res
return res
def index_html(self):
'''Redirects to /ui.'''