Commit d855e4bc authored by Alexandre Boeglin's avatar Alexandre Boeglin

Added 'Jump Allowed' parameter that hides the jump clickable link and plane.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3228 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 75ba0c70
...@@ -162,7 +162,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, RelationField.R ...@@ -162,7 +162,7 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, RelationField.R
html_string += '&nbsp;<input type="image" src="%s/images/exec16.png" value="update..." name="%s/portal_selections/viewSearchRelatedDocumentDialog%s:method">' \ html_string += '&nbsp;<input type="image" src="%s/images/exec16.png" value="update..." name="%s/portal_selections/viewSearchRelatedDocumentDialog%s:method">' \
% (portal_url_string, portal_object.getPath(), field.aq_parent._v_relation_field_index) % (portal_url_string, portal_object.getPath(), field.aq_parent._v_relation_field_index)
if value_list not in ((), [], None, ['']) and value_list == field.get_value('default'): if value_list not in ((), [], None, ['']) and value_list == field.get_value('default') and field.get_value('jump_allowed') == 1 :
if REQUEST.get('selection_name') is not None: if REQUEST.get('selection_name') is not None:
html_string += '&nbsp;&nbsp;<a href="%s?field_id=%s&form_id=%s&selection_name=%s&selection_index=%s"><img src="%s/images/jump.png"></a>' \ html_string += '&nbsp;&nbsp;<a href="%s?field_id=%s&form_id=%s&selection_name=%s&selection_index=%s"><img src="%s/images/jump.png"></a>' \
% (field.get_value('jump_method'), field.id, field.aq_parent.id, REQUEST.get('selection_name'), REQUEST.get('selection_index'),portal_url_string) % (field.get_value('jump_method'), field.id, field.aq_parent.id, REQUEST.get('selection_name'), REQUEST.get('selection_index'),portal_url_string)
...@@ -178,6 +178,9 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, RelationField.R ...@@ -178,6 +178,9 @@ class MultiRelationStringFieldWidget(Widget.LinesTextAreaWidget, RelationField.R
""" """
Render text field. Render text field.
""" """
if field.get_value('jump_allowed') == 0 :
return Widget.LinesTextAreaWidget.render_view(self, field, value)
REQUEST = get_request() REQUEST = get_request()
here = REQUEST['here'] here = REQUEST['here']
......
...@@ -53,7 +53,7 @@ class RelationStringFieldWidget(Widget.TextWidget, Widget.ListWidget): ...@@ -53,7 +53,7 @@ class RelationStringFieldWidget(Widget.TextWidget, Widget.ListWidget):
""" """
property_names = Widget.TextWidget.property_names + \ property_names = Widget.TextWidget.property_names + \
['update_method', 'jump_method', 'base_category', 'portal_type', 'catalog_index', ['update_method', 'jump_method', 'jump_allowed', 'base_category', 'portal_type', 'catalog_index',
'default_module', 'relation_setter_id', 'columns','sort','parameter_list','list_method', 'default_module', 'relation_setter_id', 'columns','sort','parameter_list','list_method',
'first_item', 'items', 'size', 'extra_item'] 'first_item', 'items', 'size', 'extra_item']
...@@ -72,6 +72,13 @@ class RelationStringFieldWidget(Widget.TextWidget, Widget.ListWidget): ...@@ -72,6 +72,13 @@ class RelationStringFieldWidget(Widget.TextWidget, Widget.ListWidget):
default="Base_jumpToRelatedDocument", default="Base_jumpToRelatedDocument",
required=1) required=1)
jump_allowed = fields.CheckBoxField('jump_allowed',
title='Jump Allowed',
description=(
"Do we allow to jump to the relation ?"),
default=1,
required=0)
base_category = fields.StringField('base_category', base_category = fields.StringField('base_category',
title='Base Category', title='Base Category',
description=( description=(
...@@ -182,7 +189,7 @@ class RelationStringFieldWidget(Widget.TextWidget, Widget.ListWidget): ...@@ -182,7 +189,7 @@ class RelationStringFieldWidget(Widget.TextWidget, Widget.ListWidget):
relation_field_index = getattr(field.aq_parent, '_v_relation_field_index', 0) relation_field_index = getattr(field.aq_parent, '_v_relation_field_index', 0)
field.aq_parent._v_relation_field_index = relation_field_index + 1 # Increase index field.aq_parent._v_relation_field_index = relation_field_index + 1 # Increase index
if value not in ( None, '' ) and not REQUEST.has_key(relation_item_id) and value == field.get_value('default'): if value not in ( None, '' ) and not REQUEST.has_key(relation_item_id) and value == field.get_value('default') and field.get_value('jump_allowed') == 1 :
if REQUEST.get('selection_name') is not None: if REQUEST.get('selection_name') is not None:
html_string += '&nbsp;&nbsp;<a href="%s/%s?field_id=%s&form_id=%s&selection_name=%s&selection_index=%s"><img src="%s/images/jump.png"></a>' \ html_string += '&nbsp;&nbsp;<a href="%s/%s?field_id=%s&form_id=%s&selection_name=%s&selection_index=%s"><img src="%s/images/jump.png"></a>' \
% (here.absolute_url(), field.get_value('jump_method'), field.id, field.aq_parent.id, REQUEST.get('selection_name'), REQUEST.get('selection_index'),portal_url_string) % (here.absolute_url(), field.get_value('jump_method'), field.id, field.aq_parent.id, REQUEST.get('selection_name'), REQUEST.get('selection_index'),portal_url_string)
...@@ -194,6 +201,8 @@ class RelationStringFieldWidget(Widget.TextWidget, Widget.ListWidget): ...@@ -194,6 +201,8 @@ class RelationStringFieldWidget(Widget.TextWidget, Widget.ListWidget):
def render_view(self, field, value): def render_view(self, field, value):
"""Render text input field. """Render text input field.
""" """
if field.get_value('jump_allowed') == 0 :
return Widget.TextWidget.render_view(self, field, value)
REQUEST = get_request() REQUEST = get_request()
here = REQUEST['here'] here = REQUEST['here']
html_string = Widget.TextWidget.render_view(self, field, value) html_string = Widget.TextWidget.render_view(self, field, value)
......
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