Commit fa21ea71 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Better support of cell parameter and editable property in listbox embedded fields;

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15817 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d5f36099
...@@ -25,6 +25,7 @@ from Products.Formulator.Field import Field ...@@ -25,6 +25,7 @@ from Products.Formulator.Field import Field
from Products.Formulator.Widget import Widget from Products.Formulator.Widget import Widget
from Products.Formulator.Widget import render_element from Products.Formulator.Widget import render_element
from Products.Formulator.FieldRegistry import FieldRegistry from Products.Formulator.FieldRegistry import FieldRegistry
from ProxyField import ProxyField
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from cgi import escape from cgi import escape
import types import types
...@@ -92,9 +93,9 @@ def Field_validate_sub_field(self, id, REQUEST, key=None): ...@@ -92,9 +93,9 @@ def Field_validate_sub_field(self, id, REQUEST, key=None):
def Field_render_helper(self, key, value, REQUEST): def Field_render_helper(self, key, value, REQUEST):
value = self._get_default(key, value, REQUEST) value = self._get_default(key, value, REQUEST)
__traceback_info__ = ('key=%s value=%r' % (key, value)) __traceback_info__ = ('key=%s value=%r' % (key, value))
if self.get_value('hidden'): if self.get_value('hidden', REQUEST=REQUEST):
return self.widget.render_hidden(self, key, value, REQUEST) return self.widget.render_hidden(self, key, value, REQUEST)
elif (not self.get_value('editable',REQUEST=REQUEST)): elif (not self.get_value('editable', REQUEST=REQUEST)):
return self.widget.render_view(self, value) return self.widget.render_view(self, value)
else: else:
return self.widget.render(self, key, value, REQUEST) return self.widget.render(self, key, value, REQUEST)
...@@ -113,6 +114,8 @@ Field.validate_sub_field = Field_validate_sub_field ...@@ -113,6 +114,8 @@ Field.validate_sub_field = Field_validate_sub_field
Field._render_helper = Field_render_helper Field._render_helper = Field_render_helper
Field._get_user_input_value = Field_get_user_input_value Field._get_user_input_value = Field_get_user_input_value
ProxyField._render_helper = Field_render_helper
from Products.Formulator.Validator import SelectionValidator from Products.Formulator.Validator import SelectionValidator
from Products.Formulator.Validator import StringBaseValidator from Products.Formulator.Validator import StringBaseValidator
......
...@@ -2059,22 +2059,29 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine): ...@@ -2059,22 +2059,29 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
# the REQUEST into the brain. In addition, the define a # the REQUEST into the brain. In addition, the define a
# cell property on the request itself so that forms may # cell property on the request itself so that forms may
# use the 'cell' value (refer to get_value method in Form.py) # use the 'cell' value (refer to get_value method in Form.py)
cell_html = editable_field.render( \ cell_request = brain.asContext( REQUEST = self.renderer.request
value = display_value , form = self.renderer.request.form
, REQUEST = brain.asContext( \ , cell = self.getObject()
REQUEST = self.renderer.request )
, form = self.renderer.request.form if editable_field.get_value('enabled', REQUEST=cell_request):
, cell = self.getObject() cell_html = editable_field.render( \
) value = display_value
, key = key , REQUEST = cell_request
) , key = key
)
else:
cell_html = ''
else: else:
# If the brain does not support asContext (eg. it is None), no way # If the brain does not support asContext (eg. it is None), no way
self.renderer.request.cell = self.getObject() self.renderer.request.cell = self.getObject()
cell_html = editable_field.render( value = display_value cell_request = brain
, REQUEST = brain if editable_field.get_value('enabled', REQUEST=cell_request):
, key = key cell_html = editable_field.render( value = display_value
) , REQUEST = cell_request
, key = key
)
else:
cell_html = ''
if isinstance(cell_html, str): if isinstance(cell_html, str):
cell_html = unicode(cell_html, encoding) cell_html = unicode(cell_html, encoding)
...@@ -2082,7 +2089,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine): ...@@ -2082,7 +2089,7 @@ class ListBoxHTMLRendererLine(ListBoxRendererLine):
if url is None: if url is None:
html = cell_html + error_message html = cell_html + error_message
else: else:
if editable_field.get_value('editable'): if editable_field.get_value('editable', REQUEST=cell_request):
html = u'%s' % cell_html html = u'%s' % cell_html
else: else:
html = u'<a href="%s">%s</a>' % (url, cell_html) html = u'<a href="%s">%s</a>' % (url, cell_html)
......
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