From 84b5bf94bd59b3be528d2d667e9aa76d8a8fd957 Mon Sep 17 00:00:00 2001 From: Denis Ledoux <dle@odoo.com> Date: Thu, 15 Jan 2015 19:03:20 +0100 Subject: [PATCH] [IMP] mail: prevent leaving when composing a message --- addons/mail/static/src/js/mail.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 824a6397dff7..25a6c1e8e54f 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -408,6 +408,16 @@ openerp.mail = function (session) { this.is_log = false; this.recipients = []; this.recipient_ids = []; + session.web.bus.on('clear_uncommitted_changes', this, function(e) { + if (this.show_composer && !e.isDefaultPrevented()){ + if (!confirm(_t("You are currently composing a message, your message will be discarded.\n\nAre you sure you want to leave this page ?"))) { + e.preventDefault(); + } + else{ + this.on_cancel(); + } + } + }); }, start: function () { -- GitLab