changeset c6d4386ad622 in sao:5.0 details: https://hg.tryton.org/sao?cmd=changeset;node=c6d4386ad622 description: Remove unnecessary calls to fields_view_get
Screen.count_tab_domain should be called after the switch_view as it is done in tryton. This avoid to trigger a call to fields_view_get for the domain_parser. Screen.switch_view is performing one extra loop compared to tryton. This trigger and extra call fields_view_get. issue8167 review60581002 (grafted from 46f47d631ee2530b43854ff86e954476ac6c1313) diffstat: src/screen.js | 51 ++++++++++++++++++++++++++++++++++----------------- src/tab.js | 1 + 2 files changed, 35 insertions(+), 17 deletions(-) diffs (96 lines): diff -r 995a3dd59041 -r c6d4386ad622 src/screen.js --- a/src/screen.js Fri Mar 08 18:38:16 2019 +0100 +++ b/src/screen.js Fri Mar 15 11:14:16 2019 +0100 @@ -739,7 +739,9 @@ this.tab = null; this.message_callback = null; this.switch_callback = null; - this.count_tab_domain(); + // count_tab_domain is called in Sao.Tab.Form.init after + // switch_view to avoid unnecessary call to fields_view_get by + // domain_parser. }, load_next_view: function() { if (!jQuery.isEmptyObject(this.view_to_load)) { @@ -838,11 +840,35 @@ } }.bind(this); var _switch = function() { - var switch_current_view = (function() { + var set_container = function() { + this.screen_container.set(this.current_view.el); + return this.display().done(function() { + this.set_cursor(); + if (this.switch_callback) { + this.switch_callback(); + } + }.bind(this)); + }.bind(this); + var continue_loop = function() { + if (!view_type && (view_id === null)) { + return false; + } + if (view_type && !view_id && !this.view_to_load.length) { + return false; + } + return true; + }.bind(this); + var set_current_view = function() { this.current_view = this.views[this.views.length - 1]; - return _switch(); + }.bind(this); + var switch_current_view = (function() { + set_current_view(); + if (continue_loop()) { + return _switch(); + } else { + return set_container(); + } }.bind(this)); - var is_view_id = function(view) { return view.view_id == view_id; }; @@ -852,27 +878,18 @@ return this.load_next_view().then(switch_current_view); } else if ((view_id !== null) && !this.views.find(is_view_id)) { - return this.add_view_id(view_id, view_type).then( - switch_current_view); + return this.add_view_id(view_id, view_type) + .then(set_current_view); } else { var i = this.views.indexOf(this.current_view); this.current_view = this.views[ (i + 1) % this.views.length]; } - if (!view_id && (view_id === null)) { - break; - } - if (view_type && !view_id && !this.view_to_load.length) { + if (!continue_loop()) { break; } } - this.screen_container.set(this.current_view.el); - return this.display().done(function() { - this.set_cursor(); - if (this.switch_callback) { - this.switch_callback(); - } - }.bind(this)); + return set_container(); }.bind(this); return _switch(); }, diff -r 995a3dd59041 -r c6d4386ad622 src/tab.js --- a/src/tab.js Fri Mar 08 18:38:16 2019 +0100 +++ b/src/tab.js Fri Mar 15 11:14:16 2019 +0100 @@ -490,6 +490,7 @@ this.set_buttons_sensitive(); this.view_prm = this.screen.switch_view().done(function() { + this.screen.count_tab_domain(); this.set_name(attributes.name || ''); this.content.append(screen.screen_container.el); if (attributes.res_id) {