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