[Erp5-report] r6914 - in /erp5/trunk/products/ERP5Form: MultiLinkField.py __init__.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Apr 24 22:03:26 CEST 2006
Author: jerome
Date: Mon Apr 24 22:03:17 2006
New Revision: 6914
URL: http://svn.erp5.org?rev=6914&view=rev
Log:
added MultiLinkField, handy field for displaying read only related objects
Added:
erp5/trunk/products/ERP5Form/MultiLinkField.py (with props)
Modified:
erp5/trunk/products/ERP5Form/__init__.py
Added: erp5/trunk/products/ERP5Form/MultiLinkField.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/MultiLinkField.py?rev=6914&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Form/MultiLinkField.py (added)
+++ erp5/trunk/products/ERP5Form/MultiLinkField.py Mon Apr 24 22:03:17 2006
@@ -1,0 +1,61 @@
+##############################################################################
+#
+# Copyright (c) 2002 Nexedi SARL and Contributors. All Rights Reserved.
+# Jerome Perrin <jerome at 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
+
Propchange: erp5/trunk/products/ERP5Form/MultiLinkField.py
------------------------------------------------------------------------------
svn:executable = *
Modified: erp5/trunk/products/ERP5Form/__init__.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/__init__.py?rev=6914&r1=6913&r2=6914&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/__init__.py (original)
+++ erp5/trunk/products/ERP5Form/__init__.py Mon Apr 24 22:03:17 2006
@@ -43,7 +43,7 @@
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 @@
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 @@
'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 @@
'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 @@
'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 @@
# 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 @@
import Selection
allow_class(Selection)
-from AccessControl.SecurityInfo import allow_module
-
More information about the Erp5-report
mailing list