From cdff3ac73cb1d0f6b87269c3667d9040904e5290 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 12 Oct 2012 16:53:20 +0200 Subject: [PATCH] [IMP] mail: top bar button bzr revid: chm@openerp.com-20121012145320-tu28t0xgm5hcl304 --- addons/mail/static/src/css/mail.css | 8 ++++ addons/mail/static/src/js/mail.js | 62 ++++++++++++++++++++++++++++- addons/mail/static/src/xml/mail.xml | 10 +++++ 3 files changed, 79 insertions(+), 1 deletion(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 1592d79e18d..0dcb3b8bcd0 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -422,3 +422,11 @@ position: absolute; } +/* ------------------------------------------------------------ */ +/* Topbar button +/* ------------------------------------------------------------ */ + +.openerp .oe_topbar .oe_topbar_compose_full_email { + float: right; + margin: 3px 25px 0 0; +} \ No newline at end of file diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index edbd2f18ef8..39035dfb402 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -49,7 +49,6 @@ openerp.mail = function(session) { }, }); - /** * ------------------------------------------------------------ * ChatterUtils @@ -1278,4 +1277,65 @@ openerp.mail = function(session) { this.$("button.oe_write_onwall:first").click(function(){ self.thread.ComposeMessage.$el.toggle(); }); } }); + + + /** + * ------------------------------------------------------------ + * UserMenu + * ------------------------------------------------------------ + * + * add a link on the top user bar for write a full mail + */ + session.web.ComposeMessageTopButton = session.web.Widget.extend({ + + template:'mail.compose_message.button_top_bar', + + init: function (parent, options) { + this._super.apply(this, options); + this.options = this.options || {}; + this.options.domain = this.options.domain || []; + this.options.context = { + 'default_res_id': 0, + 'default_model': 'mail.thread', + 'default_is_private': true, + 'default_res_model': false, + 'default_res_id': 0, + 'default_content_subtype': 'html', + 'default_is_private': true, + 'default_parent_id': 0 + }; + }, + + start: function(parent, params) { + var self = this; + this.$el.on('click', 'button', self.on_compose_message ); + this._super(parent, params); + }, + + on_compose_message: function(event){ + event.stopPropagation(); + var action = { + type: 'ir.actions.act_window', + res_model: 'mail.compose.message', + view_mode: 'form', + view_type: 'form', + action_from: 'mail.ThreadComposeMessage', + views: [[false, 'form']], + target: 'new', + context: this.options.context, + }; + session.client.action_manager.do_action(action); + }, + + }); + + session.web.UserMenu = session.web.UserMenu.extend({ + start: function(parent, params) { + var render = new session.web.ComposeMessageTopButton(); + render.insertAfter(this.$el); + this._super(parent, params); + } + + }); + }; diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 2d1ebb96924..a9c32649026 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -251,6 +251,16 @@ + + +
+ +
+
+