Commit 97c22f2d authored by Ivan Tyagov's avatar Ivan Tyagov
Browse files

Enable instant switching to new pad (i.e. without page refresh).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41091 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 177c5981
master allow_login_change allow_login_change_differentiate_id_and_login allow_login_change_wip arnau arnau-TM-components-products-migration arnau-TM-jabber-client-desktop-notifications arnau-kns arnau-kns-without-property-mapping arnau-merge arnau-poc arnau-real-time-inventory-accounting auto_extend_select_list autoflake average_lowest_value_test backup_erp5_workflow bk_erp5ish_actions_tool bk_sqlcatalog boc-interaction-drop bt5_config buce buce-2021 cache callable-jupyter-storage catalog_filter catalog_fulltext catalog_fulltext_old cedric cedriclen cedriclen-eos certificate_authority cherry-pick-243c2f03 cherry-pick-4a8e045d cleanJSByJSLint clean_up_upgrader cleanup_acquisition_base_category cmfactivity-getcurrentnode-getserveraddress compact_title_no_reference credential_update_action datetimefield deferred_listbox delivery_item_barcode douglas_forum dream_distributor drop-legacy-simulation dsn-phase3 eos-dev erp5-component erp5-data-notebook erp5-forum erp5-preference erp5-release erp5-slapos-upgrade erp5-util-testing erp5-vifib erp5-vifib-cleanup erp5_calendar erp5_catalog erp5_catalog_final erp5_free_subscription erp5_workflow erp5testnode_max_timeout eteri_master_latest eteri_master_latest_dev experiment/coding_style_test_suite feat/accounting_stop_using_getObject feat/accounting_translate_gap feat/olapy feat/pdm_content_translation feat/test_inventory_api_domain_selection feat/trade_shipment_report feat/wendelin-py-data feature/accounting-reports-stats feature/hal-actions-support feature/hal-support-update feature/jio-accounting-reports feature/jio-action-accounting feature/jio-selection-actions feature/jio-selection-actions-with-history feature/json-allows-all-jio-actions feature/renderjs-matrixbox feature/renderjs-ui-no-header feature/rjs-listbox-stats feature/rjs-mass-transition feature/rjs-print-action fix/consistency_check_alarm fix/full_text_script_conflict fix/login_validate_check_consistency fix/multiple_small_fixes_to_zodb_history_tab fix_system_processes_ownership for_testrunner_1 for_testrunner_2 for_testrunner_3 gabriel gabriel-fix-rounding-in-accounting-generation gabriel-fix-rounding-in-accounting-generation2 gadget-json-value heads/fix/notification_tool_unauthorized hotfix/accounting-test-timeout hotfix/callable_tool hotfix/field-keeps-request hotfix/jio-mass-transition hotfix/jio_view hotfix/pdm-test hotfix/rjs-accounting-tests hotfix/rjs-editability hotfix/rjs-form-less-invasive hotfix/rjs-formfields-padding hotfix/rjs-listbox-mutex hotfix/rjs-replace-query-with-uids hotfix/tests-cleanup http_cache_fix improve_default_caching_policy_manager initsite intentionaly_broken_cloudooo interaction-drop isDeletable item_tracking_graph_editor ivan jerome-bt-reference-doc jerome/buce-report-alarms jerome_graph_editor_renderjs jerome_new_style_solve_divergence jerome_user_preference_time_zone jio jm/form-action-guard joblib-activity js-ui kns kns-kr lazy_simulation_causality lignan lingnan listbox-generator listbox_url macros_fix mame mame-bt5-cleanup mame-erp5_project-cleanup mame-naming-convention mame-naming-convention-list_method mame-test-stock-indexation mame-work mame2 maste_copy master-erp5-test-result-scalability master-erp5-test-result-scalability-rebase master-test-fix-additionalbt5path master_calendar_wip_patches master_calendar_wip_patches_extend_security master_no_guard_on_workflow_transition master_no_guard_on_workflow_transition_plus_calendar_wip_patchs master_w merge_xhtml_jquery mic_construction mic_wind mic_wind_rebase mmariani-inventory monitoring monitoring-graph mrp new-render-presentation nexedi-erp5-jp no_longer_simulated_state officejs officejs_clean officejs_zip ojs_wip pere portal_callables portal_solver_process_security_configuration presentation rebased_mrp refactor/base_edit refactor/renderjs reindex_calendar_after_change_calendar_exception reverse_logistics revert-38554dbe revert-6c89fe9b rewrite_test_21_AcquiredPortalType rjs_item romain-fulltext scalability-master scalability-master2 scalability-master2-rebase scalability-rebase scalability-roque scalability-roque-2 scalability-run-command shop-box simulation sms_more_than_140_characters solve_divergence_dialog_renderjs_ui strict_catalog sws_fix syncml taskdistribution-xmlrpc-binary test_page testnode_software_link timezones tmp/getInstalledBusinessTemplate_never_installed_bt tristan tristan-merge tristan-performance ttrm upgradeSite view-aggregated-amounts vivekpab_erp5webrenderjs_layoutconfig vivekpab_jabberclient vivekpab_renderjs_interfaces wenjie wenjie_branch wip workflowtool yryr yryr-components-cp yryr-inventory-cache yryr-test yryr-with-components yusei test-ui test-rjsacc test-rjs renderjs-test erp5.util-0.4.49 erp5.util-0.4.46 erp5.util-0.4.44 erp5.util-0.4.43 erp5.util-0.4.41 erp5.util-0.4.40 erp5.util-0.4.37 erp5.util-0.4.1 erp5.util-0.4 erp5.util-0.3 erp5.util-0.2 erp5.util-0.1
No related merge requests found
Showing with 138 additions and 29 deletions
+138 -29
......@@ -186,16 +186,16 @@
<li tal:attributes="id dom_id;\n
class python: test(is_active, \'tab tab_selected\', \'tab\')">\n
\n
<a tal:attributes="href string:\n
<!-- \n
<a tal:attributes="href string:\n
ERP5Site_toggleActiveKnowledgePad?knowledge_pad_url=${knowledge_pad_relative_url}&amp;mode=${mode}">\n
<span tal:attributes="id pad_title_dom_id;"\n
tal:content="knowledge_pad/getTitle"/>\n
</a>\n
</a>-->\n
\n
\n
<!-- <span tal:attributes="id pad_title_dom_id;\n
<span tal:attributes="id pad_title_dom_id;\n
onclick string:loadPadFromServer(\'${knowledge_pad_relative_url}\', \'${dom_id}\', \'${mode}\')" \n
tal:content="knowledge_pad/getTitle"/>-->\n
tal:content="knowledge_pad/getTitle"/>\n
\n
<div class="pad-actions"\n
tal:attributes="style python: test(is_active, \'display:block\', \'display:none\')">\n
......@@ -292,7 +292,14 @@
</div>\n
</div>\n
</tal:block>\n
\n
<tal:block metal:define-macro="loading_message">\n
<div id="loading-wrapper" style="display:none;">\n
<img src="ajax-loader.gif" title="Loading" alt="Loading"/>\n
<p i18n:translate="" i18n:domain="ui"> Please wait until your changes are being applied. </p>\n
</div>\n
\n
</tal:block>
]]></unicode> </value>
</item>
......
......@@ -64,6 +64,7 @@
<div id="pad-navigation-wrapper">\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/navigation"/>\n
</div>\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/loading_message"/>\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/knowledge_pad_security_check"/> \n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/disable_server_integration"/>\n
<span metal:use-macro="container/Base_viewKnowledgePadMacroLibrary/macros/disable_server_integration"/> \n
......
......@@ -60,7 +60,7 @@
# asynchronous request and server can set it in context.REQUEST\n
from Products.ERP5Type.JSONEncoder import encodeInJson\n
current_web_section_url = \'\'\n
current_web_section = context.REQUEST.get(\'current_web_section\', None)\n
current_web_section = context.REQUEST.get(\'current_web_section\', context.getWebSiteValue())\n
if current_web_section is not None:\n
current_web_section_url = current_web_section.getRelativeUrl()\n
if params is None:\n
......@@ -132,8 +132,8 @@ return s\n
<string>Products.ERP5Type.JSONEncoder</string>
<string>encodeInJson</string>
<string>current_web_section_url</string>
<string>None</string>
<string>current_web_section</string>
<string>None</string>
<string>isinstance</string>
<string>str</string>
<string>box_relative_url</string>
......
......@@ -51,10 +51,8 @@
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Render an entire PAD plus navigation (XXX)\n
Used to in AJAX calls for instan PAD switching.\n
XXX: rather than return HTML we should return JSON as some parts like JS needs to be evaluated explicitly by\n
browser.\n
Render an entire Pad and needed JavaScript code.\n
Used to make instant Pad switching.\n
"""\n
pad = context.restrictedTraverse(pad_relative_url)\n
\n
......@@ -64,14 +62,26 @@ body = pad.KnowledgePad_viewDashboardWidget(real_context=context)\n
# toggle new active pad \n
context.ERP5Site_toggleActiveKnowledgePad(pad_relative_url, mode, redirect=False)\n
\n
# XXX: generate all JS updater code\n
javascript = \'\'\'updater(\'http://localhost/km/ERP5Site_viewRssGadget\', \'knowledge_pad_module/65/2\', \'visual_2\', \'web_site_module/km_test_web_site\', \'0\', {});\n
updater(\'http://localhost/km/ERP5Site_viewRssGadget\', \'knowledge_pad_module/64/3\', \'visual_3\', \'\', \'0\', {}); \'\'\'\n
\n
# generate needed JavaScript code\n
javascript_list = []\n
for box in pad.objectValues():\n
gadget = box.getSpecialiseValue()\n
gadget_type = gadget.getRenderType()\n
if box.getValidationState() in [\'visible\', \'invisible\'] \\\n
and gadget_type==\'asynchronous\':\n
edit_form_id=gadget.getEditFormId()\n
view_form_id=gadget.getViewFormId()\n
base_url = \'%s/%s\' %(context.absolute_url(), view_form_id) \n
box_dom_id = box.getRelativeUrl().replace(\'/\', \'_\')\n
view_form_dom_id = \'%s_content\' %box_dom_id;\n
javascript_code = pad.KnowledgePad_generateAjaxCall(base_url, box, \\\n
view_form_dom_id, ignore_security_check=1)\n
javascript_list.append(javascript_code)\n
javascript = \'\'.join(javascript_list)\n
# return JSON\n
result = {\'body\': body,\n
\'javascript\': javascript }\n
return \'%s\' % result\n
\'javascript\': javascript}\n
return result\n
</string> </value>
</item>
<item>
......@@ -115,6 +125,17 @@ return \'%s\' % result\n
<string>pad</string>
<string>body</string>
<string>False</string>
<string>javascript_list</string>
<string>_getiter_</string>
<string>box</string>
<string>gadget</string>
<string>gadget_type</string>
<string>edit_form_id</string>
<string>view_form_id</string>
<string>base_url</string>
<string>box_dom_id</string>
<string>view_form_dom_id</string>
<string>javascript_code</string>
<string>javascript</string>
<string>result</string>
</tuple>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Image" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts91383226.96</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>ajax-loader.gif</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>image/gif</string> </value>
</item>
<item>
<key> <string>data</string> </key>
<value> <string encoding="base64">R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH+GkNyZWF0ZWQgd2l0aCBhamF4
bG9hZC5pbmZvACH5BAAKAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAEAAQAAADMwi63P4wyklr
E2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQACgABACwAAAAA
EAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUk
KhIAIfkEAAoAAgAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9
HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkEAAoAAwAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYum
CYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkEAAoABAAsAAAAABAAEAAAAzII
unInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQACgAF
ACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJ
ibufbSlKAAAh+QQACgAGACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFG
xTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAAKAAcALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdce
CAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==</string> </value>
</item>
<item>
<key> <string>height</string> </key>
<value> <int>16</int> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>size</string> </key>
<value> <int>673</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ajax-loader.gif</string> </value>
</item>
<item>
<key> <string>width</string> </key>
<value> <int>16</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts91368675.54</string> </value>
<value> <string>ts91384188.54</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -40,6 +40,22 @@
margin-top: 0.5em;\n
}\n
\n
#loading-wrapper{ \n
position:absolute; \n
width:250px; \n
top:80px; \n
left:50%; \n
margin-left:-150px; \n
text-align:center; \n
padding:7px 0 0 0; \n
background-color: #FFF; \n
z-index:1000;\n
} \n
#loading-wrapper p{\n
font-weight: bold;\n
font-size: 90%;\n
}\n
\n
/* 3 columng gadget layout */\n
div.portal-column {\n
float: left;\n
......@@ -497,7 +513,7 @@ div.gadget-rss-reader .body {\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>8253</int> </value>
<value> <int>8519</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -12,7 +12,7 @@
</item>
<item>
<key> <string>_EtagSupport__etag</string> </key>
<value> <string>ts91368480.41</string> </value>
<value> <string>ts91383963.02</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......@@ -272,14 +272,15 @@ function showRenamePadPopup(knowledge_pad_relative_url, knowledge_pad_title_dom_
getElement("new_knowledge_pad_title").value = getElement(knowledge_pad_title_dom_id).innerHTML;\n
// show rename dialog\n
toggleElementById(\'rename_tab_dialog\');\n
// set focus on new Pad title after toggle effect is over \n
setTimeout("MochiKit.DOM.getElement(\'new_knowledge_pad_title\').focus()", 500 );\n
// set focus on new Pad title after toggle effect is over \n
setTimeout("MochiKit.DOM.getElement(\'new_knowledge_pad_title\').focus()", 500 );\n
}\n
\n
function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n
/* Load Pad from server */\n
// XXX: show some animation ?\n
\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
......@@ -291,7 +292,6 @@ function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n
old_selected_pad = getFirstElementByTagAndClassName("li", "tab_selected", pads_container);\n
old_selected_pad.setAttribute("class", "tab");\n
pad_actions = getFirstElementByTagAndClassName("div", "pad-actions", old_selected_pad);\n
\n
pad_actions.style.display="none";\n
\n
// set new selected pad class \n
......@@ -314,9 +314,10 @@ function loadPadFromServer(pad_relative_url, selected_pad_dom_id, mode){\n
body_element.innerHTML = body;\n
// init new Pad\n
initialize();\n
// execute JS code\n
// execute JS code provided by server\n
eval(javascript);\n
\n
// give some timeout as we can be sometimes two fast loading a tab\n
setTimeout("getElement(\'loading-wrapper\').style.display=\'none\';", 250 );\n
}\n
}\n
\n
......@@ -500,7 +501,7 @@ MochiKit.DOM.addLoadEvent(initialize);\n
</item>
<item>
<key> <string>size</string> </key>
<value> <int>18522</int> </value>
<value> <int>18734</int> </value>
</item>
<item>
<key> <string>title</string> </key>
......
641
\ No newline at end of file
642
\ 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