Commit 460cacbf authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: add push_history_stored_state router command

Add a new document in the history while trying to show its latest state
parent 1493f7c1
...@@ -54,6 +54,8 @@ ...@@ -54,6 +54,8 @@
COMMAND_HISTORY_PREVIOUS = "history_previous", COMMAND_HISTORY_PREVIOUS = "history_previous",
// Store the current document in history and display the next one // Store the current document in history and display the next one
COMMAND_PUSH_HISTORY = "push_history", COMMAND_PUSH_HISTORY = "push_history",
// Store the current document in history and display the next one latest state stored
COMMAND_PUSH_HISTORY_STORED_STATE = "push_history_stored_state",
// Change UI language // Change UI language
COMMAND_CHANGE_LANGUAGE = "change_language", COMMAND_CHANGE_LANGUAGE = "change_language",
VALID_URL_COMMAND_DICT = {}, VALID_URL_COMMAND_DICT = {},
...@@ -78,6 +80,7 @@ ...@@ -78,6 +80,7 @@
VALID_URL_COMMAND_DICT[COMMAND_SELECTION_NEXT] = null; VALID_URL_COMMAND_DICT[COMMAND_SELECTION_NEXT] = null;
VALID_URL_COMMAND_DICT[COMMAND_HISTORY_PREVIOUS] = null; VALID_URL_COMMAND_DICT[COMMAND_HISTORY_PREVIOUS] = null;
VALID_URL_COMMAND_DICT[COMMAND_PUSH_HISTORY] = null; VALID_URL_COMMAND_DICT[COMMAND_PUSH_HISTORY] = null;
VALID_URL_COMMAND_DICT[COMMAND_PUSH_HISTORY_STORED_STATE] = null;
VALID_URL_COMMAND_DICT[COMMAND_LOGIN] = null; VALID_URL_COMMAND_DICT[COMMAND_LOGIN] = null;
VALID_URL_COMMAND_DICT[COMMAND_RAW] = null; VALID_URL_COMMAND_DICT[COMMAND_RAW] = null;
VALID_URL_COMMAND_DICT[COMMAND_RELOAD] = null; VALID_URL_COMMAND_DICT[COMMAND_RELOAD] = null;
...@@ -485,10 +488,9 @@ ...@@ -485,10 +488,9 @@
}); });
} }
function execPushHistoryCommand(gadget, previous_options, next_options) { function execPushHistoryCommand(gadget, previous_options, next_options, use_stored_state) {
var jio_key = next_options.jio_key, var jio_key = next_options.jio_key,
history_options; history_options;
delete next_options.jio_key;
if (previous_options.hasOwnProperty('cancel')) { if (previous_options.hasOwnProperty('cancel')) {
history_options = JSON.parse(previous_options.cancel); history_options = JSON.parse(previous_options.cancel);
history_options.selection = previous_options.selection; history_options.selection = previous_options.selection;
...@@ -501,10 +503,18 @@ ...@@ -501,10 +503,18 @@
return addHistory(gadget, history_options) return addHistory(gadget, history_options)
.push(function (id) { .push(function (id) {
next_options.history = id; next_options.history = id;
if (use_stored_state === true) {
return execDisplayStoredStateCommand(gadget, next_options, {});
}
delete next_options.jio_key;
return addNavigationHistoryAndDisplay(gadget, jio_key, next_options); return addNavigationHistoryAndDisplay(gadget, jio_key, next_options);
}); });
} }
function execPushHistoryStoredStateCommand(gadget, previous_options, next_options) {
return execPushHistoryCommand(gadget, previous_options, next_options, true);
}
function execKeepHistoryAndDisplayCommand(gadget, previous_options, next_options, create_cancel_url) { function execKeepHistoryAndDisplayCommand(gadget, previous_options, next_options, create_cancel_url) {
next_options.selection = previous_options.selection; next_options.selection = previous_options.selection;
next_options.history = previous_options.history; next_options.history = previous_options.history;
...@@ -925,6 +935,9 @@ ...@@ -925,6 +935,9 @@
if (command_options.path === COMMAND_PUSH_HISTORY) { if (command_options.path === COMMAND_PUSH_HISTORY) {
return execPushHistoryCommand(gadget, previous_options, next_options); return execPushHistoryCommand(gadget, previous_options, next_options);
} }
if (command_options.path === COMMAND_PUSH_HISTORY_STORED_STATE) {
return execPushHistoryStoredStateCommand(gadget, previous_options, next_options);
}
if (command_options.path === COMMAND_LOGIN) { if (command_options.path === COMMAND_LOGIN) {
return execLoginCommand(gadget, previous_options, next_options); return execLoginCommand(gadget, previous_options, next_options);
} }
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>986.32404.49746.11571</string> </value> <value> <string>986.54215.48934.33570</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1600953905.18</float> <float>1600958141.18</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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