Commit 26ec8c7d authored by Romain Courteaud's avatar Romain Courteaud

ProxyField can now surcharged attributes from the template field.

The extra_context attribute is now be deprecated.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10993 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 91afdf4f
......@@ -57,6 +57,7 @@ def get_value(self, id, **kw):
self.tales = {}
tales_expr = self.tales.get(id, "")
# tales_expr = self.get_tales(id)
if tales_expr:
REQUEST = get_request()
form = self.aq_parent # XXX (JPS) form for default is wrong apparently in listbox - double check
......@@ -109,6 +110,7 @@ def get_value(self, id, **kw):
self.overrides = {}
override = self.overrides.get(id, "")
# override = self.get_override(id)
if override:
# call wrapped method to get answer
value = override.__of__(self)()
......
......@@ -62,7 +62,8 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget,
'container_getter_id', 'catalog_index',
'relation_setter_id', 'columns', 'sort',
'parameter_list','list_method',
'first_item', 'items', 'size', 'extra_item']
'first_item', 'items', 'size', 'extra_item',
]
property_names = Widget.LinesTextAreaWidget.property_names + \
Widget.TextWidget.property_names + \
......@@ -548,6 +549,7 @@ class MultiRelationStringFieldValidator(Validator.LinesValidator):
portal_type = relation_uid[len(NEW_CONTENT_PREFIX):]
translated_portal_type = Message(domain='erp5_ui',
message=portal_type)
# XXX Replace New by Add
message = Message(
domain='erp5_ui', message='New ${portal_type}',
mapping={'portal_type': translated_portal_type})
......@@ -766,15 +768,13 @@ class MultiRelationStringField(ZMIField):
widget = MultiRelationStringFieldWidgetInstance
validator = MultiRelationStringFieldValidatorInstance
security.declareProtected('Access contents information', 'get_value')
def get_value(self, id, **kw):
security.declareProtected('Access contents information', 'get_orig_value')
def get_orig_value(self, id):
"""
Get value for id.
Optionally pass keyword arguments that get passed to TALES
expression.
Get value for id; don't do any override calculation.
"""
if id in ('is_relation_field', 'is_multi_relation_field'):
result = 1
else:
result = ZMIField.get_value(self, id, **kw)
result = ZMIField.get_orig_value(self, id)
return result
This diff is collapsed.
......@@ -98,7 +98,7 @@ class RelationStringFieldValidator(
_v_message_name_list.append(message_name)
_v_dict[message_name] = 1
message_names = _v_message_name_list
_v_dict = {}
_v_property_name_list = []
for property_name in property_names:
......@@ -150,17 +150,15 @@ class RelationStringField(ZMIField):
widget = RelationStringFieldWidgetInstance
validator = RelationStringFieldValidatorInstance
security.declareProtected('Access contents information', 'get_value')
def get_value(self, id, **kw):
security.declareProtected('Access contents information', 'get_orig_value')
def get_orig_value(self, id):
"""
Get value for id.
Optionally pass keyword arguments that get passed to TALES
expression.
Get value for id; don't do any override calculation.
"""
if id == 'is_relation_field':
if id == 'is_relation_field':
result = 1
elif id == 'is_multi_relation_field':
result = 0
else:
result = ZMIField.get_value(self, id, **kw)
result = ZMIField.get_orig_value(self, id)
return result
<dtml-var manage_page_header>
<dtml-let help_product="'Formulator'" help_topic=meta_type>
<dtml-var manage_tabs>
</dtml-let>
<p class="form-help">
Surcharge <dtml-var meta_type> properties here.
</p>
<form action="manage_edit" method="POST">
<table cellspacing="0" cellpadding="2" border="0">
<!-- First, display ProxyField properties -->
<!-- see: Formulator/dtml/fieldEdit.dtml -->
<dtml-in "form.get_groups()">
<dtml-let group=sequence-item fields="form.get_fields_in_group(group)">
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
Proxy Widget properties
</td>
</tr>
<dtml-var fieldListHeader>
<dtml-let current_field="this()">
<dtml-in fields>
<dtml-let field=sequence-item field_id="field.id"
value="current_field.get_orig_value(field_id)"
override="current_field.get_override(field_id)"
tales="current_field.get_tales(field_id)">
<tr>
<td align="left" valign="top">
<div class="form-label">
<dtml-if "tales or override">[</dtml-if><dtml-var "field.title()"><dtml-if "field.has_value('required') and field.get_value('required')">*</dtml-if><dtml-if "tales or override">]</dtml-if>
</div>
</td>
<td align="left" valign="top">
<dtml-var "field.render(value)">
</td>
<td><div class="form-element">
<dtml-var "field.meta_type">
</div></td>
</tr>
</dtml-let>
</dtml-in>
</dtml-let>
</dtml-if>
</dtml-let>
</dtml-in>
<!-- Then, display Template Field properties -->
<dtml-let proxy_field="this()"
current_field="proxy_field.getRecursiveTemplateField()">
<dtml-if "current_field is not None">
<dtml-let form="current_field.form">
<dtml-in "form.get_groups()">
<dtml-let group=sequence-item fields="form.get_fields_in_group(group)">
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
<dtml-var "_.string.capitalize(group)"> properties
</td>
</tr>
<dtml-var proxyFieldListHeader>
<dtml-in fields>
<dtml-let field=sequence-item field_id="field.id"
value="proxy_field.get_recursive_orig_value(field_id)"
override="proxy_field.get_recursive_override(field_id)"
tales="proxy_field.get_recursive_tales(field_id)">
<tr>
<td align="left" valign="top">
<dtml-let checkbox_key="'surcharge_%s' % field_id" >
<dtml-if "proxy_field.is_delegated(field_id)">
<input type="checkbox"
name="<dtml-var checkbox_key>"
checked="checked" />
<dtml-else >
<input type="checkbox"
name="<dtml-var checkbox_key>" />
</dtml-if >
</dtml-let >
</td>
<td align="left" valign="top">
<div class="form-label">
<dtml-if "tales or override">[
</dtml-if>
<dtml-var "field.title()">
<dtml-if "field.has_value('required') and field.get_value('required')">*
</dtml-if>
<dtml-if "tales or override">]
</dtml-if>
</div>
</td>
<td align="left" valign="top">
<dtml-var "field.render(value)">
</td>
<td><div class="form-element">
<dtml-var "field.meta_type">
</div></td>
</tr>
</dtml-let>
</dtml-in>
</dtml-if>
</dtml-let>
</dtml-in>
</dtml-let>
</dtml-if>
</dtml-let>
<tr>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value="Save Changes" />
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
<tr class="list-header">
<td align="left" valign="top">
<div class="form-label">
Delegated
</div>
</td>
<td align="left" valign="top">
<div class="form-label">
Name
</div>
</td>
<td align="left" valign="top">
<div class="form-label">
Value
</div>
</td>
<td align="left" valign="top">
<div class="form-label">
Field
</div>
</td>
</tr>
<dtml-var manage_page_header>
<dtml-var manage_tabs>
<p class="form-help">
Edit <dtml-var meta_type> method TALES expressions here.
<dtml-if "not isTALESAvailable()"><br>
<span style="color: #FF0000;">
Zope Page Templates and therefore TALES is not installed.
This tab can therefore not be used.
</span>
</dtml-if>
</p>
<form action="manage_tales" method="POST">
<table cellspacing="0" cellpadding="2" border="0">
<dtml-in "override_form.get_groups()">
<dtml-let group=sequence-item fields="tales_form.get_fields_in_group(group)">
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
Proxy Widget properties
</td>
</tr>
<dtml-var fieldListHeader>
<dtml-let current_field="this()">
<dtml-in fields>
<dtml-let field=sequence-item field_id="field.id"
value="current_field.get_tales(field.id)">
<tr>
<td align="left" valign="top">
<div class="form-label">
<dtml-var "field.title()">
</div>
</td>
<td align="left" valign="top">
<dtml-var "field.render(value)">
</td>
<td><div class="form-element">
<dtml-var "current_field.form.get_field(field.id).meta_type">
</div></td>
</tr>
</dtml-let>
</dtml-in>
</dtml-let>
</dtml-if>
</dtml-let>
</dtml-in>
<!-- XXX Loop until find not a proxy field -->
<dtml-let proxy_field="this()"
current_field="proxy_field.getRecursiveTemplateField()">
<dtml-if "current_field is not None">
<dtml-let form="current_field.tales_form">
<dtml-in "form.get_groups()">
<dtml-let group=sequence-item fields="form.get_fields_in_group(group)">
<dtml-if fields>
<tr>
<td colspan="3" class="form-title">
<dtml-var "_.string.capitalize(group)"> properties
</td>
</tr>
<dtml-var proxyFieldListHeader>
<dtml-in fields>
<dtml-let field=sequence-item field_id="field.id"
value="proxy_field.get_recursive_tales(field_id)">
<tr>
<td align="left" valign="top">
<dtml-let checkbox_key="'surcharge_%s' % field_id" >
<dtml-if "proxy_field.is_delegated(field_id)">
<input type="checkbox"
name="<dtml-var checkbox_key>"
checked="checked" />
<dtml-else >
<input type="checkbox"
name="<dtml-var checkbox_key>" />
</dtml-if >
</dtml-let >
</td>
<td align="left" valign="top">
<div class="form-label">
<dtml-var "field.title()">
</div>
</td>
<td align="left" valign="top">
<dtml-var "field.render(value)">
</td>
<td><div class="form-element">
<dtml-var "current_field.form.get_field(field.id).meta_type">
</div></td>
</tr>
</dtml-let>
</dtml-in>
</dtml-if>
</dtml-let>
</dtml-in>
</dtml-let>
</dtml-if>
</dtml-let>
<tr>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="submit"
value="Save Changes" />
</div>
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
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