Commit 54c0fa63 authored by Romain Courteaud's avatar Romain Courteaud

Improve compatibility between PlanningBox and ProxyField, in order to surcharge

Javascript configuration.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15182 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 57528dc5
......@@ -462,6 +462,13 @@ def Widget_render_css(self, field, REQUEST):
pass
Widget.render_css = Widget_render_css
def Widget_get_javascript_list(self, field, REQUEST):
"""
Return JS needed by the widget
"""
return []
Widget.get_javascript_list = Widget_get_javascript_list
from Products.Formulator.Validator import LinesValidator
def LinesValidator_validate(self, field, key, REQUEST):
......@@ -1262,7 +1269,7 @@ def Field_get_javascript_list(self, REQUEST=None):
"""
Returns list of javascript needed by the field
"""
return []
return self.widget.get_javascript_list(self, REQUEST)
Field.get_javascript_list = Field_get_javascript_list
......
......@@ -928,6 +928,19 @@ class PlanningBoxWidget(Widget.Widget):
default=2,
required=0)
def get_javascript_list(self, field, REQUEST=None):
"""
Returns list of javascript needed by the widget
"""
if field.get_value('js_enabled'):
context = getContext(field, 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 []
def render_css(self, field, REQUEST):
"""
first method called for rendering by PageTemplate form_view
......@@ -3154,19 +3167,6 @@ class PlanningBox(ZMIField):
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):
"""
......
......@@ -126,6 +126,16 @@ class ProxyWidget(Widget.Widget):
result = proxy_field.widget.render_css(field, REQUEST)
return result
def get_javascript_list(self, field, REQUEST):
"""
Render proxy field
"""
result = []
proxy_field = field.getRecursiveTemplateField()
if proxy_field is not None:
result = proxy_field.widget.get_javascript_list(field, REQUEST)
return result
class ProxyValidator(Validator.Validator):
"""
Validation of entered value through proxy field
......@@ -498,14 +508,3 @@ class ProxyField(ZMIField):
else:
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