Commit 43261890 authored by Romain Courteaud's avatar Romain Courteaud

Extend formulator in order to make PlanningBox compatible with ProxyField.

Add methods render_css and get_javascript_list on all fields.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14921 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b56e4d2b
......@@ -455,6 +455,13 @@ Widget.render_hidden = Widget_render_hidden
# default render_pdf for a Widget
Widget.render_pdf = Widget.render_view
def Widget_render_css(self, field, REQUEST):
"""
Default render css for widget
"""
pass
Widget.render_css = Widget_render_css
from Products.Formulator.Validator import LinesValidator
def LinesValidator_validate(self, field, key, REQUEST):
......@@ -1242,6 +1249,22 @@ def Field_render_pdf(self, value=None, REQUEST=None, key=None, **kw):
return self.widget.render_pdf(self, value)
Field.render_pdf = Field_render_pdf
def Field_render_css(self, REQUEST=None):
"""
Generate css content which will be added in the html header.
XXX key parameter may be needed.
"""
return self.widget.render_css(self, REQUEST)
Field.render_css = Field_render_css
def Field_get_javascript_list(self, REQUEST=None):
"""
Returns list of javascript needed by the field
"""
return []
Field.get_javascript_list = Field_get_javascript_list
from Products.Formulator.TALESField import TALESWidget
def TALESWidget_render_view(self, field, value):
......
......@@ -101,7 +101,7 @@ class PlanningBoxValidator(Validator.StringBaseValidator):
##################################################
# build structure
basic, planning = PlanningBoxWidgetInstance.render_structure(field=field,
key=key, value=value, REQUEST= REQUEST,
REQUEST= REQUEST,
context=context)
# getting coordinates script generator
......@@ -928,7 +928,7 @@ class PlanningBoxWidget(Widget.Widget):
default=2,
required=0)
def render_css(self, field, key, value, REQUEST):
def render_css(self, field, REQUEST):
"""
first method called for rendering by PageTemplate form_view
create the whole object based structure, and then call a special
......@@ -940,8 +940,8 @@ class PlanningBoxWidget(Widget.Widget):
# render_structure will call all method necessary to build the entire
# structure relative to the planning
# creates and fill up self.basic, self.planning and self.build_error_list
basic, planning = self.render_structure(field=field, key=key, value=value,
REQUEST=REQUEST, context=context)
basic, planning = self.render_structure(field=field, REQUEST=REQUEST,
context=context)
# getting CSS script generator
planning_css_method = getattr(context, 'planning_css')
# recover CSS data buy calling DTML document
......@@ -974,7 +974,7 @@ class PlanningBoxWidget(Widget.Widget):
# return HTML data
return HTML_data
def render_structure(self, field, key, value, REQUEST, context):
def render_structure(self, field, REQUEST, context):
"""
This method is the begining of the rendering procedure. it calls all
methods needed to generate BasicStructure with ERP5 objects, and then
......@@ -3136,8 +3136,21 @@ class PlanningBox(ZMIField):
else:
return ZMIField.get_value(self, id, **kw)
def render_css(self, value=None, REQUEST=None):
return self.widget.render_css(self, '', value, REQUEST)
def render_css(self, REQUEST=None):
return self.widget.render_css(self, REQUEST)
def get_javascript_list(self, REQUEST=None):
"""
Returns list of javascript needed by the field
"""
if self.get_value('js_enabled'):
context = getContext(self, REQUEST)
# XXX Instead of harcoding library name
# it should be better to call a python script, as
# it is done on type base method.
return ['%s/wz_dragdrop.js' % context.portal_url.getPortalPath()]
else:
return []
# XXX Copy paste from listbox
def getContext(field, REQUEST):
......
......@@ -116,6 +116,16 @@ class ProxyWidget(Widget.Widget):
result = proxy_field.widget.render_view(field, value)
return result
def render_css(self, field, REQUEST):
"""
Render proxy field
"""
result = ''
proxy_field = field.getRecursiveTemplateField()
if proxy_field is not None:
result = proxy_field.widget.render_css(field, REQUEST)
return result
class ProxyValidator(Validator.Validator):
"""
Validation of entered value through proxy field
......@@ -486,5 +496,16 @@ class ProxyField(ZMIField):
if proxy_field is not None:
result = proxy_field._get_user_input_value(key, REQUEST)
else:
result = ZMIField._get_user_input_value(key, REQUEST)
result = ZMIField._get_user_input_value(self, key, REQUEST)
return result
def get_javascript_list(self, REQUEST=None):
"""
Returns list of javascript needed by the field
"""
proxy_field = self.getTemplateField()
if proxy_field is not None:
result = proxy_field.get_javascript_list(REQUEST)
else:
result = ZMIField.get_javascript_list(self, REQUEST)
return result
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