From 17896a92da39d265fda7b0e2f32479a18d0b8ace Mon Sep 17 00:00:00 2001 From: Aaron Bohy <aab@odoo.com> Date: Fri, 11 Dec 2015 17:40:24 +0100 Subject: [PATCH] [FIX] mail: various ui improvements/fixes * chat windows: - input was kicked out of the window on chrome 43 - don't animate if folded by default (e.g. after a refresh) - width and height 100% like in the frontend - z-index to make sure that they are over bootstrap active btn, but below notifications, and modals * chatter: - internal note: send button renammed to 'Log' - send button is the first button again - remove annoying form view widget's tooltip * client action: focus on composer on channel change --- addons/im_livechat/static/src/less/im_livechat.less | 5 +---- addons/mail/models/mail_thread.py | 3 +-- addons/mail/static/src/js/chat_window.js | 9 +++++++-- addons/mail/static/src/js/chatter.js | 3 +++ addons/mail/static/src/js/client_action.js | 3 ++- addons/mail/static/src/js/composer.js | 1 + addons/mail/static/src/less/chat_window.less | 12 +++++++++--- addons/mail/static/src/less/client_action.less | 3 +++ addons/mail/static/src/xml/composer.xml | 2 +- 9 files changed, 28 insertions(+), 13 deletions(-) diff --git a/addons/im_livechat/static/src/less/im_livechat.less b/addons/im_livechat/static/src/less/im_livechat.less index ce1a25a02fc6..c0940977da29 100644 --- a/addons/im_livechat/static/src/less/im_livechat.less +++ b/addons/im_livechat/static/src/less/im_livechat.less @@ -19,10 +19,7 @@ } .o_chat_window { - display: flex; - max-height: 100%; - max-width: 100%; - z-index: 1000; // to go over the navbar + z-index: 1002; // to go over the navbar .o_thread_date_separator { display: none; } diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 9f9e7294146d..ce91a0d81fe3 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -95,8 +95,7 @@ class MailThread(models.AbstractModel): compute='_get_followers', search='_search_follower_channels') message_ids = fields.One2many( 'mail.message', 'res_id', string='Messages', - domain=lambda self: [('model', '=', self._name)], auto_join=True, - help="Messages and communication history") + domain=lambda self: [('model', '=', self._name)], auto_join=True) message_last_post = fields.Datetime('Last Message Date', help='Date of the last message posted on the record.') message_unread = fields.Boolean( 'Unread Messages', compute='_get_message_unread', diff --git a/addons/mail/static/src/js/chat_window.js b/addons/mail/static/src/js/chat_window.js index 4edc8a23c44b..ca36b4307911 100644 --- a/addons/mail/static/src/js/chat_window.js +++ b/addons/mail/static/src/js/chat_window.js @@ -8,6 +8,9 @@ var Widget = require('web.Widget'); var _t = core._t; +var HEIGHT_OPEN = '400px'; +var HEIGHT_FOLDED = '28px'; + return Widget.extend({ template: "mail.ChatWindow", events: { @@ -40,7 +43,9 @@ return Widget.extend({ this.thread.on('redirect_to_channel', null, this.trigger.bind(this, 'redirect_to_channel')); this.thread.on('redirect', null, this.trigger.bind(this, 'redirect')); - this.fold(); + if (this.folded) { + this.$el.css('height', HEIGHT_FOLDED); + } var def = this.thread.appendTo(this.$content); return $.when(this._super(), def); }, @@ -63,7 +68,7 @@ return Widget.extend({ fold: function () { this.update_header(); this.$el.animate({ - height: this.folded ? "28px" : "400px" + height: this.folded ? HEIGHT_FOLDED : HEIGHT_OPEN }); }, toggle_fold: function (fold) { diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index c99e958929ed..94f3773258ba 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -445,6 +445,9 @@ var ChatterComposer = ChatComposer.extend({ is_log: false, internal_subtypes: [], }); + if (this.options.is_log) { + this.options.send_text = _('Log'); + } this.events = _.extend(this.events, { 'click .o_composer_button_full_composer': 'on_open_full_composer', }); diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index 14682f49a4ed..1a12ff36912f 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -382,6 +382,8 @@ var ChatAction = Widget.extend(ControlPanelMixin, { self.thread.scroll_to({offset: new_channel_scrolltop}); } + // Update control panel before focusing the composer, otherwise focus is on the searchview + self.update_cp(); if (!config.device.touch) { self.composer.focus(); } @@ -389,7 +391,6 @@ var ChatAction = Widget.extend(ControlPanelMixin, { self.$('.o_mail_chat_sidebar').hide(); } - self.update_cp(); self.action_manager.do_push_state({ action: self.action.id, active_id: self.channel.id, diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index 971c2e99c69d..4112a8498cf2 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -330,6 +330,7 @@ var Composer = Widget.extend({ input_max_height: 150, input_min_height: 28, mention_fetch_limit: 8, + send_text: _('Send'), }); this.context = this.options.context; diff --git a/addons/mail/static/src/less/chat_window.less b/addons/mail/static/src/less/chat_window.less index f37b66f85ffc..ca2e8ca74f1e 100644 --- a/addons/mail/static/src/less/chat_window.less +++ b/addons/mail/static/src/less/chat_window.less @@ -5,11 +5,14 @@ .o-flex-flow(column, nowrap); position: fixed; width: 300px; + max-width: 100%; height: 400px; + max-height: 100%; font-size: 12px; background-color: @o-chat-window-bg; border: 1px solid gray; border-radius: 3px; + z-index: 2; @media (max-width: @screen-xs-max) { display:none; @@ -56,8 +59,11 @@ } } - .o_chat_input > input { - padding: 5px; - width: 100%; + .o_chat_input { + .o-flex(0, 0, auto); + > input { + padding: 5px; + width: 100%; + } } } diff --git a/addons/mail/static/src/less/client_action.less b/addons/mail/static/src/less/client_action.less index b23d7d373aa2..408f3074311d 100644 --- a/addons/mail/static/src/less/client_action.less +++ b/addons/mail/static/src/less/client_action.less @@ -106,6 +106,9 @@ .o_composer_buttons { .o-flex(0, 0, auto); + .o_composer_button_send { + float: right; + } } } } diff --git a/addons/mail/static/src/xml/composer.xml b/addons/mail/static/src/xml/composer.xml index d199c0d5fdf2..71afe4d16957 100644 --- a/addons/mail/static/src/xml/composer.xml +++ b/addons/mail/static/src/xml/composer.xml @@ -6,9 +6,9 @@ <div class="o_composer"> <textarea class="o_composer_input" placeholder="Write something..."/> <div class="btn-group o_composer_buttons"> + <button class="btn btn-sm btn-primary o_composer_button_send" type="button"><t t-esc="widget.options.send_text"/></button> <button class="btn btn-sm btn-icon fa fa-smile-o o_composer_button_emoji" type="button" data-toggle="popover"/> <button class="btn btn-sm btn-icon fa fa-paperclip o_composer_button_add_attachment" type="button"/> - <button class="btn btn-sm btn-primary o_composer_button_send" type="button">Send</button> </div> </div> -- GitLab