From 6cb702924ee61bca1c9b2860e43f0949060a46f7 Mon Sep 17 00:00:00 2001 From: helmutm Date: Mon, 1 Feb 2010 15:07:23 +0000 Subject: [PATCH] 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 --- composer/schema/browser/common.py | 17 ++++++++++++++++- composer/schema/browser/schema.py | 14 -------------- composer/schema/interfaces.py | 11 +++++++++-- composer/schema/schema.py | 3 ++- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/composer/schema/browser/common.py b/composer/schema/browser/common.py index eea8de0..c0366b3 100644 --- a/composer/schema/browser/common.py +++ b/composer/schema/browser/common.py @@ -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 + diff --git a/composer/schema/browser/schema.py b/composer/schema/browser/schema.py index be62d72..f659798 100644 --- a/composer/schema/browser/schema.py +++ b/composer/schema/browser/schema.py @@ -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): diff --git a/composer/schema/interfaces.py b/composer/schema/interfaces.py index 4100d6f..c0dfc6d 100644 --- a/composer/schema/interfaces.py +++ b/composer/schema/interfaces.py @@ -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.') diff --git a/composer/schema/schema.py b/composer/schema/schema.py index d04e2bb..3c11de2 100644 --- a/composer/schema/schema.py +++ b/composer/schema/schema.py @@ -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):