Commit f6383b34 authored by Ivan Tyagov's avatar Ivan Tyagov

When user clicks save gadget preferences form we should pass to where user...

When user clicks save gadget preferences form we should pass to where user should be redirected after saving (if it happens synchronously).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41331 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8548db23
...@@ -2,10 +2,7 @@ ...@@ -2,10 +2,7 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
...@@ -62,13 +59,13 @@ request = context.REQUEST\n ...@@ -62,13 +59,13 @@ request = context.REQUEST\n
form = request.form\n form = request.form\n
fields = filter(lambda x: x.startswith(form_fields_main_prefix), form.keys())\n fields = filter(lambda x: x.startswith(form_fields_main_prefix), form.keys())\n
box = context.restrictedTraverse(box_relative_url)\n box = context.restrictedTraverse(box_relative_url)\n
portal_selection = context.getPortalObject().portal_selections\n
\n \n
# get interesting for us fields and save\n # get interesting for us fields and save\n
listbox_selection_field_prefix = \'%s_my_listbox_selection_\' %form_fields_main_prefix\n listbox_selection_field_prefix = \'%s_my_listbox_selection_\' %form_fields_main_prefix\n
for field in fields:\n for field in fields:\n
#if it\'s a fied in a lisbox gadget it modifies directly the selection\n #if it\'s a fied in a lisbox gadget it modifies directly the selection\n
if field.startswith(listbox_selection_field_prefix):\n if field.startswith(listbox_selection_field_prefix):\n
portal_selection = getattr(context, \'portal_selections\')\n
selection_name = context.Base_getListboxGadgetSelectionName(box_relative_url)\n selection_name = context.Base_getListboxGadgetSelectionName(box_relative_url)\n
selection = portal_selection.getSelectionFor(selection_name)\n selection = portal_selection.getSelectionFor(selection_name)\n
if selection is not None:\n if selection is not None:\n
...@@ -78,17 +75,16 @@ for field in fields:\n ...@@ -78,17 +75,16 @@ for field in fields:\n
kw[field.replace(\'%s_my_\' %form_fields_main_prefix, \'\')] = form[field]\n kw[field.replace(\'%s_my_\' %form_fields_main_prefix, \'\')] = form[field]\n
\n \n
# determine redirect URL as passed from gadget preference form\n # determine redirect URL as passed from gadget preference form\n
redirect_url = kw.pop(\'%s_cancel_url\' %form_fields_main_prefix, None)\n if gadget_redirect_url is None:\n
if redirect_url is None:\n
# taking URL1 as the base of the original URL. \n # taking URL1 as the base of the original URL. \n
# it works for both synchronous and asynchronous gadgets\n # it works for both synchronous and asynchronous gadgets\n
redirect_url = request[\'URL1\']\n gadget_redirect_url = request[\'URL1\']\n
\n \n
# edit\n # edit\n
box.edit(**kw)\n box.edit(**kw)\n
\n \n
request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n
%(redirect_url, \n %(gadget_redirect_url, \n
context.Base_translateString(\'Preference updated.\')))\n context.Base_translateString(\'Preference updated.\')))\n
</string> </value> </string> </value>
</item> </item>
...@@ -100,7 +96,7 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n ...@@ -100,7 +96,7 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>form_fields_main_prefix, box_relative_url</string> </value> <value> <string>form_fields_main_prefix, box_relative_url, gadget_redirect_url=None</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -120,7 +116,7 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n ...@@ -120,7 +116,7 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>2</int> </value> <value> <int>3</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
...@@ -128,6 +124,7 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n ...@@ -128,6 +124,7 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n
<tuple> <tuple>
<string>form_fields_main_prefix</string> <string>form_fields_main_prefix</string>
<string>box_relative_url</string> <string>box_relative_url</string>
<string>gadget_redirect_url</string>
<string>kw</string> <string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
...@@ -136,11 +133,10 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n ...@@ -136,11 +133,10 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n
<string>filter</string> <string>filter</string>
<string>fields</string> <string>fields</string>
<string>box</string> <string>box</string>
<string>portal_selection</string>
<string>listbox_selection_field_prefix</string> <string>listbox_selection_field_prefix</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>field</string> <string>field</string>
<string>getattr</string>
<string>portal_selection</string>
<string>selection_name</string> <string>selection_name</string>
<string>selection</string> <string>selection</string>
<string>None</string> <string>None</string>
...@@ -148,7 +144,6 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n ...@@ -148,7 +144,6 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n
<string>str</string> <string>str</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>_write_</string> <string>_write_</string>
<string>redirect_url</string>
<string>_apply_</string> <string>_apply_</string>
</tuple> </tuple>
</value> </value>
...@@ -161,7 +156,9 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n ...@@ -161,7 +156,9 @@ request.RESPONSE.redirect(\'%s?portal_status_message=%s\'\n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<tuple>
<none/> <none/>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</item> </item>
<item> <item>
<key> <string>_EtagSupport__etag</string> </key> <key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts91383963.02</string> </value> <value> <string>ts91990881.97</string> </value>
</item> </item>
<item> <item>
<key> <string>__name__</string> </key> <key> <string>__name__</string> </key>
...@@ -180,6 +180,12 @@ function submitSynchronousGadgetPreferenceForm(\n ...@@ -180,6 +180,12 @@ function submitSynchronousGadgetPreferenceForm(\n
INPUT({\'value\':form_fields_main_prefix, \n INPUT({\'value\':form_fields_main_prefix, \n
\'name\': \'form_fields_main_prefix\', \n \'name\': \'form_fields_main_prefix\', \n
\'type\':\'hidden\'}));\n \'type\':\'hidden\'}));\n
// append current return URL so we know where to redirect user\n
redirect_url = window.location.protocol + "//" + window.location.host + window.location.pathname\n
appendChildNodes(document.forms[0], \n
INPUT({\'value\':redirect_url, \n
\'name\': "gadget_redirect_url", \n
\'type\':\'hidden\'}));\n
clickSaveButton(\'KnowledgeBox_baseEdit\');\n clickSaveButton(\'KnowledgeBox_baseEdit\');\n
};\n };\n
\n \n
...@@ -501,7 +507,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n ...@@ -501,7 +507,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n
</item> </item>
<item> <item>
<key> <string>size</string> </key> <key> <string>size</string> </key>
<value> <int>18734</int> </value> <value> <int>19090</int> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
644 645
\ 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