Commit ff447311 authored by Jérome Perrin's avatar Jérome Perrin

added MultiLinkField, handy field for displaying read only related objects

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6914 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent be16b58e
##############################################################################
#
# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
# Jerome Perrin <jerome@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Products.Formulator import Widget, Validator
from Products.Formulator.Field import ZMIField
class MultiLinkFieldWidget(Widget.MultiItemsWidget):
"""A widget that displays multiples link fields.
"""
property_names = Widget.Widget.property_names +\
['items', 'view_separator', 'extra', 'extra_item']
def render_item(self, item_text, item_value, key, css_class, extra_item) :
"""Render an Item."""
return Widget.render_element('a',
href=item_value,
contents = item_text,
name = key,
css_class = css_class,
extra_item = extra_item)
render_selected_item = render_item
def render(self, field, key, value, REQUEST):
"""Render the field."""
rendered_items = self.render_items(field, key, value, REQUEST)
return field.get_value('view_separator').join(rendered_items)
MultiLinkFieldWidgetInstance = MultiLinkFieldWidget()
class MultiLinkField(ZMIField):
meta_type = "MultiLinkField"
widget = MultiLinkFieldWidgetInstance
# No validation for now
validator = Validator.SuppressValidatorInstance
......@@ -43,7 +43,7 @@ document_classes = updateGlobals( this_module, globals(),
import Form, FSForm, ListBox, MatrixBox, SelectionTool
import ZGDChart, PDFTemplate, Report, PDFForm, ParallelListField
import PlanningBox, POSBox, FormBox, EditorField, ProxyField
import RelationField, ImageField, MultiRelationField
import RelationField, ImageField, MultiRelationField, MultiLinkField
import ZPyChart
import PreferenceTool
......@@ -62,12 +62,9 @@ content_constructors = ()
import FormulatorPatch
# Optimization
import psyco
from Products.ERP5Type.PsycoWrapper import psyco
psyco.bind(ListBox.ListBoxWidget.render)
psyco.bind(ListBox.ListBoxValidator.validate)
#psyco.bind(Form.ERP5Field.get_value)
#psyco.bind(Form.ERP5Form.__call__)
#psyco.bind(Form.ERP5Form._exec)
# Finish installation
def initialize( context ):
......@@ -87,7 +84,7 @@ def initialize( context ):
'www/StringField.gif')
FieldRegistry.registerField(EditorField.EditorField,
'www/TextAreaField.gif')
FieldRegistry.registerField(FormBox.FormBox,
FieldRegistry.registerField(FormBox.FormBox,
'www/StringField.gif')
FieldRegistry.registerField(POSBox.POSBox,
'www/StringField.gif')
......@@ -109,8 +106,6 @@ def initialize( context ):
'www/StringField.gif')
FieldRegistry.registerField(StandardFields.StringField,
'www/StringField.gif')
#FieldRegistry.registerField(StandardFields.LabelField,
# 'www/LabelField.gif')
FieldRegistry.registerField(StandardFields.CheckBoxField,
'www/CheckBoxField.gif')
FieldRegistry.registerField(StandardFields.IntegerField,
......@@ -143,6 +138,8 @@ def initialize( context ):
'www/FileField.gif')
FieldRegistry.registerField(StandardFields.LinkField,
'www/LinkField.gif')
FieldRegistry.registerField(MultiLinkField.MultiLinkField,
'www/LinkField.gif')
# some helper fields
FieldRegistry.registerField(HelperFields.ListTextAreaField)
......@@ -154,19 +151,12 @@ def initialize( context ):
# register field help for all fields
FieldRegistry.registerFieldHelp(context)
# register the form itself
#context.registerClass(
# Form.ZMIForm,
# constructors = (Form.manage_addForm,
# Form.manage_add),
# icon = 'www/Form.png')
# make Dummy Fields into real fields
FieldRegistry.initializeFields()
# do initialization of Form class to make fields addable
Form.initializeForm(FieldRegistry)
Form.initializeForm(FieldRegistry, form_class = Report.ERP5Report)
Form.initializeForm(FieldRegistry, form_class=Report.ERP5Report)
# Register FSPDFTemplate icon
registerIcon(PDFTemplate.FSPDFTemplate,
......@@ -181,5 +171,3 @@ ModuleSecurityInfo('Products.ERP5Form.Report').declarePublic('ReportSection',)
import Selection
allow_class(Selection)
from AccessControl.SecurityInfo import allow_module
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment