Commit 15d6ab02 authored by Sebastien Robin's avatar Sebastien Robin

2010-02-17 Seb

* Make Base_updateDialogForm and ListBox_initializeFastInput able
to support listbox with another id than "listbox"

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32662 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7ba7d282
...@@ -60,18 +60,19 @@ from string import zfill\n ...@@ -60,18 +60,19 @@ from string import zfill\n
\n \n
for k in kw.keys():\n for k in kw.keys():\n
v = kw[k]\n v = kw[k]\n
if k == \'listbox\':\n if k.endswith(\'listbox\'):\n
listbox = {}\n listbox = {}\n
listbox_key = "%s_key" % k\n
if v is not None:\n if v is not None:\n
i = 1\n i = 1\n
for line in v:\n for line in v:\n
if line.has_key(\'listbox_key\'):\n if line.has_key(listbox_key):\n
key = \'%s\' % line[\'listbox_key\']\n key = \'%s\' % line[listbox_key]\n
else:\n else:\n
key = str(zfill(i,3))\n key = str(zfill(i,3))\n
listbox[key] = line\n listbox[key] = line\n
i+=1\n i+=1\n
request.set(\'listbox\',listbox)\n request.set(k,listbox)\n
else:\n else:\n
request.set(\'my_%s\' % k, v)\n request.set(\'my_%s\' % k, v)\n
request.set(\'%s\' % k, v)\n request.set(\'%s\' % k, v)\n
...@@ -122,6 +123,7 @@ for k in kw.keys():\n ...@@ -122,6 +123,7 @@ for k in kw.keys():\n
<string>_getitem_</string> <string>_getitem_</string>
<string>v</string> <string>v</string>
<string>listbox</string> <string>listbox</string>
<string>listbox_key</string>
<string>None</string> <string>None</string>
<string>i</string> <string>i</string>
<string>line</string> <string>line</string>
......
...@@ -55,7 +55,8 @@ ...@@ -55,7 +55,8 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Document import newTempBase\n <value> <string>from Products.ERP5Type.Document import newTempBase\n
from string import zfill\n from string import zfill\n
\n if listbox_id is None:\n
listbox_id = \'listbox\'\n
\n \n
request = context.REQUEST\n request = context.REQUEST\n
\n \n
...@@ -69,9 +70,10 @@ first_empty_line_id = 1\n ...@@ -69,9 +70,10 @@ first_empty_line_id = 1\n
portal_object = context.getPortalObject()\n portal_object = context.getPortalObject()\n
int_len = 3\n int_len = 3\n
\n \n
if hasattr(request, \'listbox\'):\n if hasattr(request, listbox_id):\n
listbox_key = "%s_key" % listbox_id\n
# initialize the listbox \n # initialize the listbox \n
listbox=request[\'listbox\']\n listbox=request[listbox_id]\n
\n \n
keys_list = listbox.keys()\n keys_list = listbox.keys()\n
\n \n
...@@ -88,7 +90,7 @@ if hasattr(request, \'listbox\'):\n ...@@ -88,7 +90,7 @@ if hasattr(request, \'listbox\'):\n
for key in listbox[i]:\n for key in listbox[i]:\n
value = listbox[i][key]\n value = listbox[i][key]\n
# 0 was added because of checkbox field in some fast input\n # 0 was added because of checkbox field in some fast input\n
if (value not in [\'\',None,0]) and (key != \'listbox_key\'):\n if (value not in [\'\',None,0]) and (key != listbox_key):\n
is_empty = 0\n is_empty = 0\n
if (request.has_key(\'field_errors\')):\n if (request.has_key(\'field_errors\')):\n
is_empty = 0\n is_empty = 0\n
...@@ -119,7 +121,7 @@ return l\n ...@@ -119,7 +121,7 @@ return l\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>empty_line_number=0, **kw</string> </value> <value> <string>empty_line_number=0, listbox_id=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -139,18 +141,20 @@ return l\n ...@@ -139,18 +141,20 @@ return l\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>1</int> </value> <value> <int>2</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>empty_line_number</string> <string>empty_line_number</string>
<string>listbox_id</string>
<string>kw</string> <string>kw</string>
<string>Products.ERP5Type.Document</string> <string>Products.ERP5Type.Document</string>
<string>newTempBase</string> <string>newTempBase</string>
<string>string</string> <string>string</string>
<string>zfill</string> <string>zfill</string>
<string>None</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>request</string> <string>request</string>
...@@ -160,6 +164,7 @@ return l\n ...@@ -160,6 +164,7 @@ return l\n
<string>portal_object</string> <string>portal_object</string>
<string>int_len</string> <string>int_len</string>
<string>hasattr</string> <string>hasattr</string>
<string>listbox_key</string>
<string>listbox</string> <string>listbox</string>
<string>keys_list</string> <string>keys_list</string>
<string>int</string> <string>int</string>
...@@ -169,7 +174,6 @@ return l\n ...@@ -169,7 +174,6 @@ return l\n
<string>is_empty</string> <string>is_empty</string>
<string>key</string> <string>key</string>
<string>value</string> <string>value</string>
<string>None</string>
<string>range</string> <string>range</string>
<string>str</string> <string>str</string>
</tuple> </tuple>
...@@ -185,6 +189,7 @@ return l\n ...@@ -185,6 +189,7 @@ return l\n
<value> <value>
<tuple> <tuple>
<int>0</int> <int>0</int>
<none/>
</tuple> </tuple>
</value> </value>
</item> </item>
......
1475 1476
\ 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