add 'labelWidth' schema property for better control of the apperance of forms
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3709 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
c6d80925eb
commit
6cb702924e
4 changed files with 27 additions and 18 deletions
|
@ -28,7 +28,7 @@ from zope.app.session.interfaces import ISession
|
|||
from zope.cachedescriptors.property import Lazy
|
||||
|
||||
from cybertools.composer.interfaces import IInstance
|
||||
from cybertools.composer.schema.interfaces import IClientFactory
|
||||
from cybertools.composer.schema.interfaces import IClientFactory, ISchema
|
||||
|
||||
|
||||
schema_macros = ViewPageTemplateFile('schema_macros.pt')
|
||||
|
@ -158,3 +158,18 @@ class BaseView(object):
|
|||
def getSessionInfo(self, key, default=None, packageId=packageId):
|
||||
session = ISession(self.request)[packageId]
|
||||
return session.get(key, default)
|
||||
|
||||
def details(self, clientName):
|
||||
result = []
|
||||
client = self.context.getClients().get(clientName)
|
||||
schemas = [s for s in self.context.getClientSchemas()
|
||||
if ISchema.providedBy(s)]
|
||||
instance = IInstance(client)
|
||||
for s in schemas:
|
||||
instance.template = s
|
||||
data = instance.applyTemplate()
|
||||
for f in s.fields:
|
||||
if f.storeData:
|
||||
result.append(dict(label=f.title, value=data.get(f.name)))
|
||||
return result
|
||||
|
||||
|
|
|
@ -137,20 +137,6 @@ class FormManagerView(BaseView):
|
|||
result.append(data)
|
||||
return result
|
||||
|
||||
def details(self, clientName):
|
||||
result = []
|
||||
client = self.context.getClients().get(clientName)
|
||||
schemas = [s for s in self.context.getClientSchemas()
|
||||
if ISchema.providedBy(s)]
|
||||
instance = IInstance(client)
|
||||
for s in schemas:
|
||||
instance.template = s
|
||||
data = instance.applyTemplate()
|
||||
for f in s.fields:
|
||||
if f.storeData:
|
||||
result.append(dict(label=f.title, value=data.get(f.name)))
|
||||
return result
|
||||
|
||||
|
||||
class CheckoutView(BaseView):
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ class ISchema(ITemplate):
|
|||
name = schema.ASCII(
|
||||
title=_(u'Schema name'),
|
||||
description=_(u'The internal name of the schema; will be used '
|
||||
'to identify data fields of instance objects that '
|
||||
'are associated with this schema.'),
|
||||
u'to identify data fields of instance objects that '
|
||||
u'are associated with this schema.'),
|
||||
required=True,)
|
||||
title = schema.TextLine(
|
||||
title=_(u'Title'),
|
||||
|
@ -51,6 +51,13 @@ class ISchema(ITemplate):
|
|||
title=_(u'Description'),
|
||||
description=_(u'A brief description of the item.'),
|
||||
required=False,)
|
||||
labelWidth = schema.TextLine(
|
||||
title=_(u'Label column width'),
|
||||
description=_(u'The width of the label column; please enter '
|
||||
u'a value like used for CSS style sheets, '
|
||||
u'e.g. "200px" or "20%".'),
|
||||
default=u'auto',
|
||||
required=False,)
|
||||
|
||||
fields = Attribute('The components the schema is built up of. '
|
||||
'Should be a sequence of IField objects.')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (c) 2007 Helmut Merz helmutm@cy55.de
|
||||
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -36,6 +36,7 @@ class Schema(Template):
|
|||
implements(ISchema)
|
||||
|
||||
name = u''
|
||||
labelWidth = 'auto'
|
||||
manager = None
|
||||
|
||||
def __init__(self, *fields, **kw):
|
||||
|
|
Loading…
Add table
Reference in a new issue