Commit 30d1e660 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Router gadget should handle application redirection

The router gadget handles all URL interaction (generation, parsing). It is also responsible to handle redirection (as redirecting for hash and HTML5 pushState is different).

Ensure that redirect "block" the application until cancellation of the current page rendering.
This will prevent unexpected result for function calling redirect (in case of 401 for example)
parent 2a0e2a01
......@@ -422,11 +422,7 @@
.allowPublicAcquisition("redirect", function (param_list) {\n
return this.getDeclaredGadget(\'router\')\n
.push(function (router_gadget) {\n
return router_gadget.getCommandUrlFor.apply(router_gadget,\n
param_list);\n
})\n
.push(function (hash) {\n
window.location.replace(hash);\n
return router_gadget.redirect.apply(router_gadget, param_list);\n
});\n
})\n
.allowPublicAcquisition(\'reload\', function () {\n
......@@ -775,7 +771,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -789,7 +785,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.38651.7361.44032</string> </value>
<value> <string>946.46191.44015.43298</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -807,8 +803,8 @@
</tuple>
<state>
<tuple>
<float>1445593354.44</float>
<string>GMT</string>
<float>1446546583.8</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
......@@ -132,6 +132,7 @@
COMMAND_SELECTION_NEXT = "selection_next",\n
COMMAND_HISTORY_PREVIOUS = "history_previous",\n
COMMAND_PUSH_HISTORY = "push_history",\n
REDIRECT_TIMEOUT = 5000,\n
VALID_URL_COMMAND_DICT = {};\n
VALID_URL_COMMAND_DICT[COMMAND_DISPLAY_STATE] = null;\n
VALID_URL_COMMAND_DICT[COMMAND_CHANGE_STATE] = null;\n
......@@ -154,7 +155,7 @@
// prevent returning unexpected response\n
// wait for the hash change to occur\n
// fail if nothing happens\n
return RSVP.timeout(\'5000\');\n
return RSVP.timeout(REDIRECT_TIMEOUT);\n
}\n
\n
//////////////////////////////////////////////////////////////////\n
......@@ -371,7 +372,7 @@
(error.status_code === 404)) {\n
return synchronousChangeState(\n
getCommandUrlFor(gadget, COMMAND_HISTORY_PREVIOUS, previous_options)\n
); \n
);\n
}\n
throw error;\n
});\n
......@@ -412,7 +413,7 @@
(error.status_code === 404)) {\n
return synchronousChangeState(\n
getCommandUrlFor(gadget, COMMAND_HISTORY_PREVIOUS, previous_options)\n
); \n
);\n
}\n
throw error;\n
});\n
......@@ -479,7 +480,7 @@
return {\n
url: "gadget_erp5_page_" + command_options.args.page + ".html",\n
// XXX Drop this options thing.\n
// Implement a "getSelection" method \n
// Implement a "getSelection" method\n
options: command_options.args\n
// options: {}\n
};\n
......@@ -629,6 +630,18 @@
}\n
return getCommandUrlFor(this, \'error\', options);\n
})\n
\n
.declareMethod(\'redirect\', function (options) {\n
return this.getCommandUrlFor(options)\n
.push(function (hash) {\n
window.location.replace(hash);\n
\n
// prevent returning unexpected response\n
// wait for the hash change to occur\n
// fail if nothing happens\n
return RSVP.timeout(REDIRECT_TIMEOUT);\n
});\n
})\n
\n
.declareMethod(\'getUrlParameter\', function (key) {\n
return this.props.options[key];\n
......@@ -792,7 +805,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>romain</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -806,7 +819,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.39127.64259.52206</string> </value>
<value> <string>946.56060.60572.31044</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -824,8 +837,8 @@
</tuple>
<state>
<tuple>
<float>1445531098.26</float>
<string>GMT</string>
<float>1446547226.97</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
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