diff options
| author | Christophe Simonis <chs@openerp.com> | 2012-07-18 15:10:04 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2012-07-18 15:10:04 +0200 |
| commit | 5a918cf01de012e45ac580b3fb55d010001129b7 (patch) | |
| tree | 72b1ef9fb042969bf7cd253898be6d82cf6b95ec /addons/web/static/src | |
| parent | c7491d99d873eb6159091cea7e0cbd65d03e6882 (diff) | |
[IMP] session_bind is done by openerp.init(). As result, Clients can have template like any other widget as qweb template are loaded. This make the code cleaner as show_common() does not return a deferred anymore.
bzr revid: chs@openerp.com-20120718131004-gvn63r3ihzxyzvy3
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/boot.js | 7 | ||||
| -rw-r--r-- | addons/web/static/src/js/chrome.js | 69 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 6 |
3 files changed, 33 insertions, 49 deletions
diff --git a/addons/web/static/src/js/boot.js b/addons/web/static/src/js/boot.js index 86f8077b151..9f426ee787c 100644 --- a/addons/web/static/src/js/boot.js +++ b/addons/web/static/src/js/boot.js @@ -21,10 +21,10 @@ * * @param {Array} modules list of modules to initialize */ - init: function(modules) { + init: function(modules, origin) { // By default only web will be loaded, the rest will be by loaded // by openerp.web.Session on the first session_authenticate - modules = modules || ["web"]; + modules = _.union(['web'], modules || []); var new_instance = { // links to the global openerp _openerp: openerp, @@ -39,6 +39,9 @@ for(var i=0; i < modules.length; i++) { openerp[modules[i]](new_instance,new_instance[modules[i]]); } + new_instance.connection.synchronized_mode(function() { + new_instance.connection.session_bind(origin); + }); return new_instance; } }; diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index b07c5d01dce..9eb8a238cec 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -857,31 +857,17 @@ instance.web.UserMenu = instance.web.Widget.extend({ }); instance.web.Client = instance.web.Widget.extend({ - name: 'Client', - init: function(parent, origin) { + init: function(parent) { if (instance.webclient) { throw new Error('Only one client per instance'); } instance.client = instance.webclient = this; this._super(parent); - this._origin = origin; }, start: function() { - var self = this; - return this.session.session_bind(this._origin).pipe(function() { - // now that we are bound, we can render the real template - var $e = undefined; - try { - $e = $(QWeb.render(self.name, {})); - } catch (e) {} - if ($e) { - self.$element.append($e); - } - - self.bind_events(); - return self.show_common(); - }); + this.bind_events(); + this.show_common(); }, bind_events: function() { @@ -928,7 +914,7 @@ instance.web.Client = instance.web.Widget.extend({ }); instance.web.WebClient = instance.web.Client.extend({ - name: 'WebClient', + template: 'WebClient', init: function(parent) { this._super(parent); this._current_state = null; @@ -947,8 +933,7 @@ instance.web.WebClient = instance.web.Client.extend({ }, start: function() { var self = this; - return this._super().pipe(function() { - self.$element.addClass("openerp openerp_webclient_container"); + return $.when(this._super()).pipe(function() { if (jQuery.param !== undefined && jQuery.deparam(jQuery.param.querystring()).kitten !== undefined) { $("body").addClass("kitten-mode-activated"); if ($.blockUI) { @@ -964,17 +949,16 @@ instance.web.WebClient = instance.web.Client.extend({ }, show_common: function() { var self = this; - return $.when(this._super()).pipe(function() { - window.onerror = function (message, file, line) { - self.crashmanager.on_traceback({ - type: _t("Client Error"), - message: message, - data: {debug: file + ':' + line} - }); - }; - self.login = new instance.web.Login(self); - self.login.on("login",self,self.show_application); - }); + this._super(); + window.onerror = function (message, file, line) { + self.crashmanager.on_traceback({ + type: _t("Client Error"), + message: message, + data: {debug: file + ':' + line} + }); + }; + self.login = new instance.web.Login(self); + self.login.on("login",self,self.show_application); }, show_login: function() { var self = this; @@ -1097,9 +1081,9 @@ instance.web.WebClient = instance.web.Client.extend({ }); instance.web.EmbeddedClient = instance.web.Client.extend({ - name: 'EmbedClient', - init: function(parent, origin, dbname, login, key, action_id, options) { - this._super(parent, origin); + template: 'EmbedClient', + init: function(parent, dbname, login, key, action_id, options) { + this._super(parent); this.dbname = dbname; this.login = login; @@ -1110,6 +1094,7 @@ instance.web.EmbeddedClient = instance.web.Client.extend({ start: function() { var self = this; return $.when(this._super()).pipe(function() { + return instance.connection.session_authenticate(self.dbname, self.login, self.key, true).pipe(function() { return self.rpc("/web/action/load", { action_id: self.action_id }, function(result) { var action = result.result; action.flags = _.extend({ @@ -1120,22 +1105,14 @@ instance.web.EmbeddedClient = instance.web.Client.extend({ //pager : false }, self.options, action.flags || {}); - self.am.do_action(action); + self.action_manager.do_action(action); + }); }); }); }, - - show_common: function() { - var self = this; - return $.when(this._super()).pipe(function() { - self.am = self.action_manager; - return instance.connection.session_authenticate(self.dbname, self.login, self.key, true); - }); - - }, }); -instance.web.embed = function (origin, dbname, login, key, action, options) { +instance.web.embed = function (dbname, login, key, action, options) { $('head').append($('<link>', { 'rel': 'stylesheet', 'type': 'text/css', @@ -1146,7 +1123,7 @@ instance.web.embed = function (origin, dbname, login, key, action, options) { var sc = document.getElementsByTagName('script'); currentScript = sc[sc.length-1]; } - var client = new instance.web.EmbeddedClient(null, origin, dbname, login, key, action, options); + var client = new instance.web.EmbeddedClient(null, dbname, login, key, action, options); client.insertAfter(currentScript); }; diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 546d1c45a35..5779a6801ee 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -371,6 +371,7 @@ </t> <t t-name="WebClient"> + <div class="openerp openerp_webclient_container"> <table class="oe_webclient"> <tr> <td colspan="2" class="oe_topbar"> @@ -394,10 +395,13 @@ </td> </tr> </table> + </div> </t> <t t-name="EmbedClient"> - <div class="oe_application"></div> + <div class="openerp"> + <div class="oe_application"></div> + </div> </t> <t t-name="ViewManager"> |
