Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge field schema into one tab #764

Merged
merged 1 commit into from
Sep 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 35 additions & 34 deletions src/Products/CMFPlomino/contents/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class IPlominoField(model.Schema):
""" Plomino field schema
"""

#directives.widget('field_type', onchange=u'this.form.submit()')
field_type = schema.Choice(
title=_('CMFPlomino_label_FieldType', default="Field type"),
description=_('CMFPlomino_label_FieldType', default="Field type"),
Expand All @@ -89,6 +90,24 @@ class IPlominoField(model.Schema):
vocabulary=field_types,
)

mandatory = schema.Bool(
title=_('CMFPlomino_label_FieldMandatory', default="Mandatory"),
description=_('CMFPlomino_help_FieldMandatory',
default='Is this field mandatory? (empty value will not be '
'allowed)'),
default=False,
required=True,
)

directives.widget('validation_formula', klass='plomino-formula')
validation_formula = schema.Text(
title=_('CMFPlomino_label_FieldValidation',
default="Validation formula"),
description=_('CMFPlomino_help_FieldValidation',
default='Evaluate the input validation'),
required=False,
)

field_mode = schema.Choice(
title=_('CMFPlomino_label_FieldMode', default="Field mode"),
description=_('CMFPlomino_label_FieldMode', default="Field mode"),
Expand All @@ -115,40 +134,6 @@ class IPlominoField(model.Schema):
required=False,
)

read_template = schema.TextLine(
title=_('CMFPlomino_label_FieldReadTemplate',
default="Field read template"),
description=_('CMFPlomino_help_FieldReadTemplate',
default='Custom rendering template in read mode'),
required=False,
)

edit_template = schema.TextLine(
title=_('CMFPlomino_label_FieldEditTemplate',
default="Field edit template"),
description=_('CMFPlomino_help_FieldEditTemplate',
default='Custom rendering template in edit mode'),
required=False,
)

mandatory = schema.Bool(
title=_('CMFPlomino_label_FieldMandatory', default="Mandatory"),
description=_('CMFPlomino_help_FieldMandatory',
default='Is this field mandatory? (empty value will not be '
'allowed)'),
default=False,
required=True,
)

directives.widget('validation_formula', klass='plomino-formula')
validation_formula = schema.Text(
title=_('CMFPlomino_label_FieldValidation',
default="Validation formula"),
description=_('CMFPlomino_help_FieldValidation',
default='Evaluate the input validation'),
required=False,
)

to_be_indexed = schema.Bool(
title=_('CMFPlomino_label_FieldIndex', default="Add to index"),
description=_('CMFPlomino_help_FieldIndex',
Expand All @@ -175,6 +160,22 @@ class IPlominoField(model.Schema):
required=False,
)

read_template = schema.TextLine(
title=_('CMFPlomino_label_FieldReadTemplate',
default="Field read template"),
description=_('CMFPlomino_help_FieldReadTemplate',
default='Custom rendering template in read mode'),
required=False,
)

edit_template = schema.TextLine(
title=_('CMFPlomino_label_FieldEditTemplate',
default="Field edit template"),
description=_('CMFPlomino_help_FieldEditTemplate',
default='Custom rendering template in edit mode'),
required=False,
)


class PlominoField(Item):
implements(IPlominoField, IInstanceBehaviorAssignableContent)
Expand Down
14 changes: 7 additions & 7 deletions src/Products/CMFPlomino/fields/attachment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import IFormFieldProvider, ORDER_KEY
from plone.supermodel import directives, model
from Products.CMFPlone.utils import normalizeString
from zope.interface import implementer, provider
Expand All @@ -17,12 +17,6 @@ class IAttachmentField(model.Schema):
""" Attachment field schema
"""

directives.fieldset(
'settings',
label=_(u'Settings'),
fields=('single_or_multiple', ),
)

single_or_multiple = schema.Choice(
vocabulary=SimpleVocabulary.fromItems(
[("Single file", "SINGLE"), ("Multiple files", "MULTI")]),
Expand All @@ -31,6 +25,12 @@ class IAttachmentField(model.Schema):
default="MULTI",
required=True)

# bug in plone.autoform means order_after doesn't moves correctly
IAttachmentField.setTaggedValue(ORDER_KEY,
[('single_or_multiple', 'after', 'field_type'),
]
)


@implementer(IAttachmentField)
class AttachmentField(BaseField):
Expand Down
13 changes: 6 additions & 7 deletions src/Products/CMFPlomino/fields/boolean.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import IFormFieldProvider, ORDER_KEY
from plone.supermodel import directives, model
from zope.interface import implementer, provider
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
Expand All @@ -16,12 +16,6 @@ class IBooleanField(model.Schema):
"""
"""

directives.fieldset(
'settings',
label=_(u'Settings'),
fields=('widget', ),
)

widget = schema.Choice(
vocabulary=SimpleVocabulary.fromItems([
("Single checkbox", "CHECKBOX")
Expand All @@ -31,6 +25,11 @@ class IBooleanField(model.Schema):
default="CHECKBOX",
required=True)

# bug in plone.autoform means order_after doesn't moves correctly
IBooleanField.setTaggedValue(ORDER_KEY,
[('widget', 'after', 'field_type'),
]
)

@implementer(IBooleanField)
class BooleanField(BaseField):
Expand Down
20 changes: 9 additions & 11 deletions src/Products/CMFPlomino/fields/datagrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from jsonutil import jsonutil as json
from DateTime import DateTime
from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import IFormFieldProvider, ORDER_KEY
from plone.supermodel import directives, model
from zope.interface import implementer, provider
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
Expand All @@ -20,16 +20,6 @@ class IDatagridField(model.Schema):
""" Datagrid field schema
"""

directives.fieldset(
'settings',
label=_(u'Settings'),
fields=(
'widget',
'associated_form',
'field_mapping',
),
)

widget = schema.Choice(
vocabulary=SimpleVocabulary.fromItems([
("Always dynamic", "REGULAR"),
Expand All @@ -51,6 +41,14 @@ class IDatagridField(model.Schema):
description=u'Field ids from the associated form, separated by commas.',
required=False)

# bug in plone.autoform means order_after doesn't moves correctly
IDatagridField.setTaggedValue(ORDER_KEY,
[('widget', 'after', 'field_type'),
('associated_form', 'after', ".widget"),
('field_mapping', 'after', ".associated_form"),
]
)


@implementer(IDatagridField)
class DatagridField(BaseField):
Expand Down
16 changes: 9 additions & 7 deletions src/Products/CMFPlomino/fields/datetime.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

from DateTime import DateTime
from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import IFormFieldProvider, ORDER_KEY
from plone.supermodel import directives, model
from zope.interface import implementer, provider
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
Expand All @@ -18,12 +18,6 @@ class IDatetimeField(model.Schema):
""" DateTime field schema
"""

directives.fieldset(
'settings',
label=_(u'Settings'),
fields=('widget', 'format', 'startingyear'),
)

widget = schema.Choice(
vocabulary=SimpleVocabulary.fromItems([
("Default", "SERVER"),
Expand All @@ -45,6 +39,14 @@ class IDatetimeField(model.Schema):
description=u"Oldest year selectable in the calendar widget",
required=False)

# bug in plone.autoform means order_after doesn't moves correctly
IDatetimeField.setTaggedValue(ORDER_KEY,
[('widget', 'after', 'field_type'),
('format', 'after', ".widget"),
('startingyear', 'after', ".format"),
]
)


@implementer(IDatetimeField)
class DatetimeField(BaseField):
Expand Down
23 changes: 10 additions & 13 deletions src/Products/CMFPlomino/fields/doclink.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from jsonutil import jsonutil as json
from plone.autoform import directives as form
from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import IFormFieldProvider, ORDER_KEY
from plone.supermodel import directives, model
from zope.interface import implementer, provider
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
Expand All @@ -21,18 +21,6 @@ class IDoclinkField(model.Schema):
""" Selection field schema
"""

directives.fieldset(
'settings',
label=_(u'Settings'),
fields=(
'widget',
'sourceview',
'labelcolumn',
'documentslistformula',
'separator',
),
)

widget = schema.Choice(
vocabulary=SimpleVocabulary.fromItems([
("Selection list", "SELECT"),
Expand Down Expand Up @@ -67,6 +55,15 @@ class IDoclinkField(model.Schema):
description=u'Only apply if multiple values will be displayed',
required=False)

# bug in plone.autoform means order_after doesn't moves correctly
IDoclinkField.setTaggedValue(ORDER_KEY,
[('widget', 'after', 'field_type'),
('sourceview', 'after', ".widget"),
('labelcolumn', 'after', ".sourceview"),
('documentslistformula', 'after', ".labelcolumn"),
('separator', 'after', ".documentslistformula"),
]
)

@implementer(IDoclinkField)
class DoclinkField(BaseField):
Expand Down
12 changes: 6 additions & 6 deletions src/Products/CMFPlomino/fields/googlechart.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import IFormFieldProvider, ORDER_KEY
from plone.supermodel import directives, model
from zope.interface import implementer, provider
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
Expand All @@ -16,18 +16,18 @@ class IGooglechartField(model.Schema):
""" Google chart field schema
"""

directives.fieldset(
'settings',
label=_(u'Settings'),
fields=('editrows', ),
)

editrows = schema.TextLine(
title=u'Rows',
description=u'Size of the editable text area',
default=u"6",
required=False)

# bug in plone.autoform means order_after doesn't moves correctly
IGooglechartField.setTaggedValue(ORDER_KEY,
[('editrows', 'after', 'field_type'),
]
)

@implementer(IGooglechartField)
class GooglechartField(BaseField):
Expand Down
15 changes: 8 additions & 7 deletions src/Products/CMFPlomino/fields/googlevisualization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import IFormFieldProvider, ORDER_KEY
from plone.autoform import directives as form
from plone.supermodel import directives, model
from zope.interface import implementer, provider
Expand Down Expand Up @@ -29,12 +29,6 @@ class IGooglevisualizationField(model.Schema):
""" Google viz field schema
"""

directives.fieldset(
'settings',
label=_(u'Settings'),
fields=('jssettings', 'chartid', ),
)

form.widget('jssettings', klass='plomino-formula')
jssettings = schema.Text(
title=u'Javascript settings',
Expand Down Expand Up @@ -76,6 +70,13 @@ class IGooglevisualizationField(model.Schema):
required=True,
default=u'gvisudata')

# bug in plone.autoform means order_after doesn't moves correctly
IGooglevisualizationField.setTaggedValue(ORDER_KEY,
[('jssettings', 'after', 'field_type'),
('chartid', 'after', ".jssettings"),
]
)


@implementer(IGooglevisualizationField)
class GooglevisualizationField(BaseField):
Expand Down
17 changes: 10 additions & 7 deletions src/Products/CMFPlomino/fields/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from jsonutil import jsonutil as json
from plone import api
from plone.autoform.interfaces import IFormFieldProvider
from plone.autoform.interfaces import IFormFieldProvider, ORDER_KEY
from plone.supermodel import directives, model
from zope.interface import implementer, provider
from zope.pagetemplate.pagetemplatefile import PageTemplateFile
Expand All @@ -18,12 +18,6 @@ class INameField(model.Schema):
""" Name field schema
"""

directives.fieldset(
'settings',
label=_(u'Settings'),
fields=('type', 'selector', 'restricttogroup', 'separator', ),
)

type = schema.Choice(
vocabulary=SimpleVocabulary.fromItems([
("Single valued", "SINGLE"),
Expand Down Expand Up @@ -55,6 +49,15 @@ class INameField(model.Schema):
description=u'Only apply if multiple values will be displayed',
required=False)

# bug in plone.autoform means order_after doesn't moves correctly
INameField.setTaggedValue(ORDER_KEY,
[('type', 'after', 'field_type'),
('selector', 'after', ".type"),
('restricttogroup', 'after', ".selector"),
('separator', 'after', ".restricttogroup"),
]
)


@implementer(INameField)
class NameField(BaseField):
Expand Down
Loading