diff options
| author | Aaron Bohy <aab@odoo.com> | 2015-06-30 14:37:14 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2015-07-01 11:36:32 +0200 |
| commit | b601ec66caa5bebdd97fc196af294c488dd78100 (patch) | |
| tree | fcefe67d97a2455e7c90ec6db39979d1494ad445 /addons/web/static/src/js/web_client.js | |
| parent | 3a511aaa700bc9965cd6967b2b8fb1b21ccdce8d (diff) | |
[IMP] web,mail: use of Modals to confirm changes discard
instead of the browser confirm dialogs, for the sake of uniformity.
Diffstat (limited to 'addons/web/static/src/js/web_client.js')
| -rw-r--r-- | addons/web/static/src/js/web_client.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/addons/web/static/src/js/web_client.js b/addons/web/static/src/js/web_client.js index c6fd30d6c13..496f83c7d3a 100644 --- a/addons/web/static/src/js/web_client.js +++ b/addons/web/static/src/js/web_client.js @@ -5,6 +5,7 @@ var ActionManager = require('web.ActionManager'); var core = require('web.core'); var crash_manager = require('web.crash_manager'); var data = require('web.data'); +var framework = require('web.framework'); var Loading = require('web.Loading'); var Menu = require('web.Menu'); var Model = require('web.Model'); @@ -100,12 +101,11 @@ var WebClient = Widget.extend({ this.set_content_full_screen(full_screen); }); }, - on_logo_click: function(ev){ - if (!this.has_uncommitted_changes()) { - return; - } else { - ev.preventDefault(); - } + on_logo_click: function(ev) { + ev.preventDefault(); + return this.clear_uncommitted_changes().then(function() { + framework.redirect("/web" + (core.debug ? "?debug" : "")); + }); }, show_common: function() { var self = this; @@ -133,10 +133,12 @@ var WebClient = Widget.extend({ toggle_bars: function(value) { this.$('tr:has(td.navbar),.oe_leftbar').toggle(value); }, - has_uncommitted_changes: function() { - var $e = $.Event('clear_uncommitted_changes'); - core.bus.trigger('clear_uncommitted_changes', $e); - return $e.isDefaultPrevented(); + clear_uncommitted_changes: function() { + var def = $.Deferred().resolve(); + core.bus.trigger('clear_uncommitted_changes', function chain_callbacks(callback) { + def = def.then(callback); + }); + return def; }, /** Sets the first part of the title of the window, dedicated to the current action. @@ -258,9 +260,9 @@ var WebClient = Widget.extend({ }, on_logout: function() { var self = this; - if (!this.has_uncommitted_changes()) { + this.clear_uncommitted_changes().then(function() { self.action_manager.do_action('logout'); - } + }); }, bind_hashchange: function() { var self = this; |
