From 05d0ef1c023bc5586ea8fe01644cf4c301465ac4 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 4 Jan 2012 19:21:12 +0100 Subject: [PATCH] [imp] modified web client to be able to logout without reloading bzr revid: nicolas.vanhoren@openerp.com-20120104182112-znsij1ogfu70paoe --- addons/web/static/src/js/chrome.js | 18 +++++++++--------- addons/web/static/src/js/core.js | 5 +++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 54718a5c50b..285c3661583 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -239,6 +239,7 @@ openerp.web.Loading = openerp.web.Widget.extend(/** @lends openerp.web.Loading# stop: function() { this.session.on_rpc_request.remove(this.request_call); this.session.on_rpc_response.remove(this.response_call); + this.on_rpc_event(-this.count); this._super(); }, on_rpc_event : function(increment) { @@ -1060,19 +1061,18 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie }, start: function() { var self = this; + if (jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) { + this.$element.addClass("kitten-mode-activated"); + this.$element.delegate('img.oe-record-edit-link-img', 'hover', function(e) { + self.$element.toggleClass('clark-gable'); + }); + } this.session.bind().then(function() { - if (jQuery.param != undefined && jQuery.deparam(jQuery.param.querystring()).kitten != undefined) { - this.$element.addClass("kitten-mode-activated"); - this.$element.delegate('img.oe-record-edit-link-img', 'hover', function(e) { - self.$element.toggleClass('clark-gable'); - }); - } - if (!self.session.session_is_valid()) { self.show_login(); } }); - this.session.ready.then(function() { + this.session.on_session_valid.add(function() { self.show_application(); self.header.do_update(); @@ -1121,6 +1121,7 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie _.each(_.clone(this.widget_children), function(el) { el.stop(); }); + this.$element.children().remove(); }, do_reload: function() { return this.session.session_init().pipe(_.bind(function() {this.menu.do_reload();}, this)); @@ -1139,7 +1140,6 @@ openerp.web.WebClient = openerp.web.Widget.extend(/** @lends openerp.web.WebClie $(window).unbind('hashchange', this.on_hashchange); this.do_push_state({}); this.show_login(); - window.location.reload(); }, bind_hashchange: function() { $(window).bind('hashchange', this.on_hashchange); diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js index e59c6d417ae..819385288a7 100644 --- a/addons/web/static/src/js/core.js +++ b/addons/web/static/src/js/core.js @@ -385,7 +385,6 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. this.context = {}; this.shortcuts = []; this.active_id = null; - this.ready = $.Deferred(); return this.session_init(); }, /** @@ -595,6 +594,8 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. session_logout: function() { this.set_cookie('session_id', ''); }, + on_session_valid: function() { + }, /** * Called when a rpc call fail due to an invalid session. * By default, it's a noop @@ -658,7 +659,7 @@ openerp.web.Connection = openerp.web.CallbackEnabled.extend( /** @lends openerp. }); }) ).then(function() { - self.ready.resolve(); + self.on_session_valid(); }); }); },