changeset 3fdae12ed04b in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=3fdae12ed04b
description:
Add context to export URL
issue9304
review317361002
diffstat:
CHANGELOG | 2 ++
src/sao.js | 1 +
src/session.js | 33 +++++++++++++++++++++++++--------
3 files changed, 28 insertions(+), 8 deletions(-)
diffs (74 lines):
diff -r e27a5c86fe71 -r 3fdae12ed04b CHANGELOG
--- a/CHANGELOG Tue May 19 18:47:53 2020 +0200
+++ b/CHANGELOG Tue May 19 18:57:53 2020 +0200
@@ -1,3 +1,5 @@
+* Keep context in sessionStorage
+* Use existing context for get_preferences
* Allow changes to editable tree checkboxes without first selecting the line
Version 5.6.0 - 2020-05-04
diff -r e27a5c86fe71 -r 3fdae12ed04b src/sao.js
--- a/src/sao.js Tue May 19 18:47:53 2020 +0200
+++ b/src/sao.js Tue May 19 18:57:53 2020 +0200
@@ -594,6 +594,7 @@
jQuery('#user-logout').empty();
jQuery('#menu').empty();
new Sao.Window.Preferences(function() {
+ Sao.Session.current_session.reset_context();
Sao.get_preferences().then(function(preferences) {
Sao.menu(preferences);
Sao.user_menu(preferences);
diff -r e27a5c86fe71 -r 3fdae12ed04b src/session.js
--- a/src/session.js Tue May 19 18:47:53 2020 +0200
+++ b/src/session.js Tue May 19 18:57:53 2020 +0200
@@ -17,9 +17,8 @@
this.database = database;
this.login = login;
this.restore();
- this.context = {
- client: Sao.Bus.id,
- };
+ this.context = {};
+ this.restore_context();
if (!Sao.Session.current_session) {
Sao.Session.current_session = this;
}
@@ -82,15 +81,33 @@
reload_context: function() {
var args = {
'method': 'model.res.user.get_preferences',
- 'params': [true, {}]
+ 'params': [true, this.context]
};
+ this.reset_context();
+ var prm = Sao.rpc(args, this);
+ return prm.then(function(context) {
+ jQuery.extend(this.context, context);
+ this.store_context();
+ }.bind(this));
+ },
+ reset_context: function() {
this.context = {
client: Sao.Bus.id,
};
- var prm = Sao.rpc(args, this);
- return prm.then(function(context) {
- jQuery.extend(this.context, context);
- }.bind(this));
+ },
+ restore_context: function() {
+ this.reset_context();
+ var context = sessionStorage.getItem('sao_context_' +
this.database);
+ if (context !== null) {
+ jQuery.extend(
+ this.context,
Sao.rpc.convertJSONObject(JSON.parse(context)));
+ }
+ },
+ store_context: function() {
+ var context = jQuery.extend({}, this.context);
+ delete context.client;
+ context = JSON.stringify(Sao.rpc.prepareObject(context));
+ sessionStorage.setItem('sao_context_' + this.database, context);
},
restore: function() {
if (this.database && !this.session) {