Commit 481a3557 authored by Alexandre Boeglin's avatar Alexandre Boeglin

Base_getFieldParameterDict:

* add suport for list fields
* rename id to field_id to prevent overloading
Base_viewFieldLibrary/my_multi_relation_field
* use Base_getFieldParameterDict to guess some field values (similar to my_relation_field)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18904 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a309cadb
......@@ -69,19 +69,26 @@
Get default relation string field parameters\n
based on its id\n
"""\n
id = context.getId()\n
if not id.startswith(\'my_\'): return {} # this should not happen\n
field_id = context.getId()\n
if not field_id.startswith(\'my_\'): return {} # this should not happen\n
\n
if id.endswith(\'_relative_url\'): idx = 2\n
elif id.endswith(\'_title\'): idx = 1\n
is_list = 0\n
if field_id.endswith(\'_relative_url\'): idx = 2\n
elif field_id.endswith(\'_title\'): idx = 1\n
elif field_id.endswith(\'_title_list\'):\n
idx = 2\n
is_list = 1\n
else: idx = 0\n
\n
# can it be translated title, or something else?\n
\n
pieces = id.split(\'_\')\n
pieces = field_id.split(\'_\')\n
parameter_dict = dict()\n
parameter_dict[\'base_category\'] = \'_\'.join(pieces[1:-idx])\n
parameter_dict[\'catalog_index\'] = \'_\'.join(pieces[-idx:])\n
if is_list == 0:\n
parameter_dict[\'catalog_index\'] = \'_\'.join(pieces[-idx:])\n
else:\n
parameter_dict[\'catalog_index\'] = \'_\'.join(pieces[-idx:-1]) \n
return parameter_dict\n
</string> </value>
</item>
......@@ -97,6 +104,12 @@ return parameter_dict\n
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
......@@ -127,7 +140,8 @@ return parameter_dict\n
<tuple>
<string>_getattr_</string>
<string>context</string>
<string>id</string>
<string>field_id</string>
<string>is_list</string>
<string>idx</string>
<string>pieces</string>
<string>dict</string>
......
......@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ERP5Form.MultiRelationField</string>
<string>MultiRelationStringField</string>
</tuple>
<none/>
<global name="MultiRelationStringField" module="Products.ERP5Form.MultiRelationField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......@@ -232,11 +229,15 @@
</item>
<item>
<key> <string>base_category</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>catalog_index</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>columns</string> </key>
......@@ -293,7 +294,7 @@
<item>
<key> <string>height</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
......@@ -371,7 +372,7 @@
<item>
<key> <string>width</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -395,11 +396,11 @@
</item>
<item>
<key> <string>base_category</string> </key>
<value> <string>(To be defined in proxy field)</string> </value>
<value> <string>(tales)</string> </value>
</item>
<item>
<key> <string>catalog_index</string> </key>
<value> <string>(To be defined in proxy field)</string> </value>
<value> <string>(tales)</string> </value>
</item>
<item>
<key> <string>columns</string> </key>
......@@ -563,18 +564,15 @@
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: preferences.getPreference(\'preferred_text_area_height\', 4)</string> </value>
<value> <string>python: field.Base_getFieldParameterDict()[\'base_category\']</string> </value>
</item>
</dictionary>
</pickle>
......@@ -582,11 +580,40 @@
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: field.Base_getFieldParameterDict()[\'catalog_index\']</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: preferences.getPreference(\'preferred_text_area_height\', 4)</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
......
694
\ No newline at end of file
695
\ No newline at end of file
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