Commit 34076a9e authored by Ivan Tyagov's avatar Ivan Tyagov

Create new pad in synchronous fashion, rather than a mix of an asynchronous...

Create new pad in synchronous fashion, rather than a mix of an asynchronous request in browser and  redirect afterwards.
Clean up some comments.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41645 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b44d900e
......@@ -110,7 +110,7 @@
value="" \n
name="pad_title" \n
id="new_pad_title"\n
tal:attributes="onkeypress string:addPadOnServerOnEnter(event, \'ERP5Site_addNewKnowledgePad\', \'${mode}\', \'view\')"/>\n
tal:attributes="onkeypress string: return addPadOnServerOnEnter(event, \'ERP5Site_addNewKnowledgePad\', \'${mode}\', \'view\')"/>\n
<br/>\n
<br/>\n
<button type="button"\n
......
......@@ -50,29 +50,29 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if pad_title != \'\':\n
pad = context.knowledge_pad_module.newContent(portal_type=\'Knowledge Pad\',\n
<value> <string>pad = context.knowledge_pad_module.newContent(portal_type=\'Knowledge Pad\',\n
title = pad_title)\n
# for web mode\n
if mode in (\'web_front\', \'web_section\',):\n
# for web mode\n
if mode in (\'web_front\', \'web_section\',):\n
# in Web Mode we can have a temporary Web Site objects created based on current language\n
real_context = context\n
if context.isTempObject():\n
real_context = context.getParentValue()\n
pad.setPublicationSectionValue(real_context)\n
# set it as active\n
context.ERP5Site_toggleActiveKnowledgePad(pad, mode=mode, redirect=False)\n
message = \'Pad added.\'\n
else:\n
message = \'Missing pad title.\'\n
\n
# adding is done though AJAX call\n
return pad.getRelativeUrl()\n
# set it as active\n
context.ERP5Site_toggleActiveKnowledgePad(pad, mode=mode, redirect=False)\n
\n
if redirect_url is not None:\n
context.REQUEST.RESPONSE.redirect(\'%s?active_pad_url=%s\' %(redirect_url, pad.getRelativeUrl()))\n
else:\n
# adding is done though either AJAX call or programatically\n
return pad.getRelativeUrl()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>pad_title, mode=None</string> </value>
<value> <string>pad_title, mode=None, redirect_url=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts92483701.94</string> </value>
<value> <string>ts93010596.68</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -301,13 +301,12 @@ function showRenamePadPopup(knowledge_pad_relative_url, knowledge_pad_title_dom_
\n
function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n
/* Load Pad from server */\n
// XXX: show some animation ?\n
// show some animation\n
getElement("loading-wrapper").style.display="block";\n
\n
d = MochiKit.Async.loadJSONDoc(\'KnowledgePag_getPadAsJSON\', \n
{\'pad_relative_url\':pad_relative_url,\n
\'mode\':mode});\n
//d.addCallback(handleServerSuccess);\n
d.addCallbacks(handleServerSuccess, metadataFetchFailed);\n
\n
// set old pad to not selected\n
......@@ -357,24 +356,17 @@ function addPadOnServerOnEnter(event, create_url, mode, cancel_url){\n
/* Catch and submit form when ENTER is pressed */\n
if(event.keyCode == 13){\n
addPadOnServer(create_url, mode, cancel_url);\n
return false;\n
}\n
}\n
\n
function addPadOnServer(create_url,\n
mode,\n
cancel_url){\n
/* add pad on server and set cookie as its relative url this way we \n
can show it immediately in UI */\n
/* add pad on server */\n
pad_title = getElement(\'new_pad_title\');\n
pad_title_value = pad_title.value\n
d = doSimpleXMLHttpRequest(\n
create_url, \n
{\'pad_title\': pad_title_value,\n
\'mode\': mode});\n
d.addCallbacks(handleServerSuccess, handleServerError);\n
function handleServerSuccess(res){\n
window.location = cancel_url+\'?active_pad_url=\'+res.responseText;\n
};\n
window.location = create_url + \'?redirect_url=\' + cancel_url + \'&mode=\' + mode + \'&pad_title=\'+pad_title_value ;\n
};\n
\n
function removeKnowledgePadFromServer(knowledge_pad_relative_url, mode){\n
......@@ -402,9 +394,6 @@ function renameKnowledgePadToServer(){\n
showCreateDefaultKnowledgePadWarningMessage();}\n
else{\n
// rename it locally and update server asynchonously\n
\n
// --title_id, input_id, knowledge_pad_relative_url\n
\n
title_element = getElement(active_knowledge_pad_title_dom_id)\n
input_element = getElement("new_knowledge_pad_title")\n
var knowledge_pad_title = input_element.value;\n
......@@ -532,7 +521,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>19989</int> </value>
<value> <int>19630</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
664
\ No newline at end of file
665
\ 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