changeset e2b40d5d11b2 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=e2b40d5d11b2
description:
        Decode board action the same way as window action

        The evaluation code should be the same to ensure same behavior.

        issue9275
        review303761007
diffstat:

 src/board.js |  118 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 59 insertions(+), 59 deletions(-)

diffs (159 lines):

diff -r becbdd5a8e5e -r e2b40d5d11b2 src/board.js
--- a/src/board.js      Fri Jun 19 00:18:04 2020 +0200
+++ b/src/board.js      Fri Jun 19 00:20:27 2020 +0200
@@ -62,70 +62,79 @@
             if (context === undefined) {
                 context = {};
             }
-            var model, action_prm, act_window;
-            var decoder, search_context, search_value;
 
+            var session = Sao.Session.current_session;
             this.name = attributes.name;
-            this.context = jQuery.extend({}, context);
 
-            act_window = new Sao.Model('ir.action.act_window');
-            this.action_prm = act_window.execute('get', [this.name],
-                    this.context);
-            this.action_prm.done(function(action) {
-                var i, len;
-                var view_ids, decoder, search_context;
-                var screen_attributes, action_modes;
+            this.el = jQuery('<div/>', {
+                'class': 'board-action panel panel-default',
+            });
+            this.title = jQuery('<div/>', {
+                'class': 'panel-heading',
+            });
+            this.el.append(this.title);
+            this.body = jQuery('<div/>', {
+                'class': 'panel-body',
+            });
+            this.el.append(this.body);
 
+            var act_window = new Sao.Model('ir.action.act_window');
+            this.action_prm = act_window.execute('get', [this.name], {});
+            this.action_prm.done(function(action) {
+                var params = {};
                 this.action = action;
-                this.action.mode = [];
-                view_ids = [];
-                if ((this.action.views || []).length > 0) {
-                    for (i = 0, len = this.action.views.length; i < len; i++) {
-                        view_ids.push(this.action.views[i][0]);
-                        this.action.mode.push(this.action.views[i][1]);
-                    }
-                } else if (this.action.view_id !== undefined) {
-                    view_ids = [this.action.view_id[0]];
-                }
-
-                if ('mode' in attributes) {
-                    this.action.mode = attributes.mode;
+                params.view_ids = [];
+                params.mode = null;
+                if (!jQuery.isEmptyObject(action.views)) {
+                    params.view_ids = [];
+                    params.mode = [];
+                    action.views.forEach(function(x) {
+                        params.view_ids.push(x[0]);
+                        params.mode.push(x[1]);
+                    });
+                } else if (!jQuery.isEmptyObject(action.view_id)) {
+                    params.view_ids = [action.view_id[0]];
                 }
 
                 if (!('pyson_domain' in this.action)) {
                     this.action.pyson_domain = '[]';
                 }
+                var ctx = {};
+                ctx = jQuery.extend(ctx, session.context);
+                ctx._user = session.user_id;
+                var decoder = new Sao.PYSON.Decoder(ctx);
+                params.context = jQuery.extend(
+                    {}, context,
+                    decoder.decode(action.pyson_context || '{}'));
+                ctx = jQuery.extend(ctx, params.context);
 
-                jQuery.extend(this.context,
-                        Sao.Session.current_session.context);
-                this.context._user = Sao.Session.current_session.user_id;
-                decoder = new Sao.PYSON.Decoder(this.context);
-                jQuery.extend(this.context,
-                        decoder.decode(this.action.pyson_context || '{}'));
-                decoder = new Sao.PYSON.Decoder(this.context);
-                jQuery.extend(this.context,
-                        decoder.decode(this.action.pyson_context || '{}'));
+                ctx.context = ctx;
+                decoder = new Sao.PYSON.Decoder(ctx);
+                params.domain = decoder.decode(action.pyson_domain);
+                params.order = decoder.decode(action.pyson_order);
+                params.search_value = decoder.decode(
+                    action.pyson_search_value || '[]');
+                params.tab_domain = [];
+                action.domains.forEach(function(element, index) {
+                    params.tab_domain.push(
+                        [element[0], decoder.decode(element[1]), element[2]]);
+                });
+                params.context_model = action.context_model;
+                params.context_domain = action.context_domain;
+                if (action.limit !== null) {
+                    params.limit = action.limit;
+                } else {
+                    params.limit = Sao.config.limit;
+                }
 
+                this.context = ctx;
                 this.domain = [];
                 this.update_domain([]);
 
-                search_context = jQuery.extend({}, this.context);
-                search_context.context = this.context;
-                search_context._user = Sao.Session.current_session.user_id;
-                decoder = new Sao.PYSON.Decoder(search_context);
-                search_value = decoder.decode(
-                        this.action.pyson_search_value || '[]');
+                params.row_activate = this.row_activate.bind(this);
 
-                screen_attributes = {
-                    mode: this.action.mode,
-                    context: this.context,
-                    view_ids: view_ids,
-                    domain: this.domain,
-                    search_value: search_value,
-                    row_activate: this.row_activate.bind(this),
-                };
                 this.screen = new Sao.Screen(this.action.res_model,
-                        screen_attributes);
+                        params);
 
                 if (attributes.string) {
                     this.title.html(attributes.string);
@@ -137,17 +146,6 @@
                     this.screen.search_filter();
                 }.bind(this));
             }.bind(this));
-            this.el = jQuery('<div/>', {
-                'class': 'board-action panel panel-default',
-            });
-            this.title = jQuery('<div/>', {
-                'class': 'panel-heading',
-            });
-            this.el.append(this.title);
-            this.body = jQuery('<div/>', {
-                'class': 'panel-body',
-            });
-            this.el.append(this.body);
         },
         row_activate: function() {
             var record_ids, win;
@@ -172,7 +170,9 @@
                     } else {
                         this.screen.current_record.cancel();
                     }
-                }.bind(this));
+                }.bind(this), {
+                'title': this.title.text(),
+                });
             }
         },
         set_value: function() {

Reply via email to