[gen] for Type.shownInfo and tool.resultColumns..., added the possibility to define the name, width and alignment of every column (=notion of 'column layout').
This commit is contained in:
parent
4a69a3beb2
commit
f31cbc4d12
9 changed files with 95 additions and 72 deletions
|
@ -406,28 +406,14 @@ class ToolMixin(BaseMixin):
|
|||
self.REQUEST.SESSION['search_%s' % searchName] = uids
|
||||
return res.__dict__
|
||||
|
||||
def getResultColumnsNames(self, contentType, refInfo):
|
||||
contentTypes = contentType.strip(',').split(',')
|
||||
resSet = None # Temporary set for computing intersections.
|
||||
res = [] # Final, sorted result.
|
||||
fieldNames = None
|
||||
appyTool = self.appy()
|
||||
refField = None
|
||||
if refInfo[0]: refField = refInfo[0].getAppyType(refInfo[1])
|
||||
for cType in contentTypes:
|
||||
if refField:
|
||||
fieldNames = refField.shownInfo
|
||||
else:
|
||||
fieldNames = getattr(appyTool, 'resultColumnsFor%s' % cType)
|
||||
if not resSet:
|
||||
resSet = set(fieldNames)
|
||||
else:
|
||||
resSet = resSet.intersection(fieldNames)
|
||||
# By converting to set, we've lost order. Let's put things in the right
|
||||
# order.
|
||||
for fieldName in fieldNames:
|
||||
if fieldName in resSet:
|
||||
res.append(fieldName)
|
||||
def getResultColumnsLayouts(self, contentType, refInfo):
|
||||
'''Returns the column layouts for displaying objects of
|
||||
p_contentType.'''
|
||||
if refInfo[0]:
|
||||
res = refInfo[0].getAppyType(refInfo[1]).shownInfo
|
||||
else:
|
||||
toolFieldName = 'resultColumnsFor%s' % contentType
|
||||
res = getattr(self.appy(), toolFieldName)
|
||||
return res
|
||||
|
||||
def truncateValue(self, value, appyType):
|
||||
|
|
|
@ -7,7 +7,7 @@ import os, os.path, sys, types, mimetypes, urllib, cgi
|
|||
from appy import Object
|
||||
import appy.gen as gen
|
||||
from appy.gen.utils import *
|
||||
from appy.gen.layout import Table, defaultPageLayouts
|
||||
from appy.gen.layout import Table, defaultPageLayouts, ColumnLayout
|
||||
from appy.gen.descriptors import WorkflowDescriptor, ClassDescriptor
|
||||
from appy.shared.utils import sequenceTypes, normalizeText
|
||||
from appy.shared.data import rtlLanguages
|
||||
|
@ -683,15 +683,21 @@ class BaseMixin:
|
|||
res['css'] = css
|
||||
res['js'] = js
|
||||
|
||||
def getAppyTypesFromNames(self, fieldNames, asDict=True):
|
||||
'''Gets the Appy types named p_fieldNames.'''
|
||||
def getColumnsSpecifiers(self, columnLayouts, dir):
|
||||
'''Extracts and returns, from a list of p_columnLayouts, the information
|
||||
that is necessary for displaying a column in a result screen or for
|
||||
a Ref field.'''
|
||||
res = []
|
||||
for name in fieldNames:
|
||||
appyType = self.getAppyType(name, asDict)
|
||||
if appyType: res.append(appyType)
|
||||
tool = self.getTool()
|
||||
for info in columnLayouts:
|
||||
fieldName, width, align = ColumnLayout(info).get()
|
||||
align = tool.flipLanguageDirection(align, dir)
|
||||
field = self.getAppyType(fieldName, asDict=True)
|
||||
if not field:
|
||||
self.log('Field "%s", used in a column specifier, was not ' \
|
||||
'found.' % fieldName, type='warning')
|
||||
else:
|
||||
self.log('Field "%s", used as shownInfo in a Ref, ' \
|
||||
'was not found.' % name, type='warning')
|
||||
res.append({'field':field, 'width':width, 'align': align})
|
||||
return res
|
||||
|
||||
def getAppyStates(self, phase, currentOnly=False):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue