Commit a8575223 authored by Bartek Górny's avatar Bartek Górny

a link from ProxyField to its target's ZMI (by Marek Petlicki)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9571 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 67bce20b
...@@ -57,6 +57,7 @@ class ProxyWidget(Widget.Widget): ...@@ -57,6 +57,7 @@ class ProxyWidget(Widget.Widget):
property_names = [ property_names = [
'form_id', 'form_id',
'field_id', 'field_id',
'target',
'extra_context', 'extra_context',
] ]
...@@ -85,6 +86,14 @@ class ProxyWidget(Widget.Widget): ...@@ -85,6 +86,14 @@ class ProxyWidget(Widget.Widget):
default=(), default=(),
required=0) required=0)
target = fields.HyperLinkField(
'target',
title='Proxy Target',
description="Link to the master field edit form",
default='Click to edit the target',
href='manage_edit_target',
required=0)
def render(self, field, key, value, REQUEST): def render(self, field, key, value, REQUEST):
""" """
Render proxy field Render proxy field
...@@ -171,6 +180,18 @@ class ProxyField(ZMIField): ...@@ -171,6 +180,18 @@ class ProxyField(ZMIField):
REQUEST.other['erp5_extra_context'] = extra_context REQUEST.other['erp5_extra_context'] = extra_context
return REQUEST return REQUEST
security.declareProtected('Edit target', 'manage_edit_target')
def manage_edit_target(self, REQUEST):
""" Edit target field of this proxy
"""
proxy_field = self.getTemplateField()
if proxy_field:
url='/'.join((self.absolute_url(),self.get_value('form_id'),self.get_value('field_id'),'manage_main'))
REQUEST.RESPONSE.redirect(url)
else:
# FIXME: should show some error message ("form_id and field_id don't define a valid template")
pass
security.declareProtected('Access contents information', 'get_value') security.declareProtected('Access contents information', 'get_value')
def get_value(self, id, **kw): def get_value(self, id, **kw):
"""Get value for id. """Get value for id.
......
...@@ -146,6 +146,9 @@ def initialize( context ): ...@@ -146,6 +146,9 @@ def initialize( context ):
FieldRegistry.registerField(HelperFields.MethodField) FieldRegistry.registerField(HelperFields.MethodField)
FieldRegistry.registerField(HelperFields.TALESField) FieldRegistry.registerField(HelperFields.TALESField)
import HyperLinkField
FieldRegistry.registerField(HyperLinkField.HyperLinkField)
# register help for the product # register help for the product
context.registerHelp() context.registerHelp()
# register field help for all fields # register field help for all fields
......
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