From c04103f4da7f24df4010fdd68ac815e24c9c949a Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 27 Jan 2016 10:37:24 +0100 Subject: [PATCH] [FIX] mail: various UI fixes/improvements - don't print chat windows - add missing 'width: 100%' on composer and Discuss sidebar inputs (required for community edition) - center the Discuss sidebar inputs - Discuss sidebar items layout: one line, text ellipsis if name is too long - hide chatter in 'create' mode (messages wrote in the chatter need a res_model and a res_id, the latter is not yet existing if we are in 'create' mode) - revert 2d2dacc: print chatter by default (classname 'hidden-print' can be used for specific models for which we don't want the chatter to be printed) - thread: ensure the displayed message's date is in the past - re-render threads every minutes to update dates - don't squash messages in mass mailing channels --- addons/mail/static/src/js/chatter.js | 14 ++++++++++ addons/mail/static/src/js/client_action.js | 2 +- addons/mail/static/src/js/thread.js | 10 ++++++- addons/mail/static/src/less/chat_window.less | 4 +++ addons/mail/static/src/less/chatter.less | 6 ----- .../mail/static/src/less/client_action.less | 17 ++++++++---- addons/mail/static/src/less/composer.less | 1 + addons/mail/static/src/xml/client_action.xml | 26 ++++++++++--------- 8 files changed, 55 insertions(+), 25 deletions(-) diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index 6617ccb8666..7a653f1738c 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -726,6 +726,16 @@ var Chatter = form_common.AbstractField.extend({ start: function () { var self = this; + // Hide the chatter in 'create' mode + this.view.on("change:actual_mode", this, this.check_visibility); + this.check_visibility(); + var $container = this.$el.parent(); + if ($container.hasClass('oe_chatter')) { + this.$el + .addClass($container.attr("class")) + .unwrap(); + } + // Move the follower's widget (if any) inside the chatter this.followers = this.field_manager.fields.message_follower_ids; if (this.followers) { @@ -759,6 +769,10 @@ var Chatter = form_common.AbstractField.extend({ }); }, + check_visibility: function () { + this.set({"force_invisible": this.view.get("actual_mode") === "create"}); + }, + fetch_and_render_thread: function (ids, options) { var self = this; options = options || {}; diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index 82b36f3425d..e0acd48236b 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -435,7 +435,7 @@ var ChatAction = Widget.extend(ControlPanelMixin, { display_load_more: !chat_manager.all_history_loaded(this.channel, this.domain), display_needactions: this.channel.display_needactions, messages_separator_position: this.messages_separator_position, - squash_close_messages: this.channel.type !== 'static', + squash_close_messages: this.channel.type !== 'static' && !this.channel.mass_mailing, display_empty_channel: !messages.length && !this.domain.length, display_no_match: !messages.length && this.domain.length, display_subject: this.channel.mass_mailing || this.channel.id === "channel_inbox", diff --git a/addons/mail/static/src/js/thread.js b/addons/mail/static/src/js/thread.js index 439b1a8beb3..d0123c0457e 100644 --- a/addons/mail/static/src/js/thread.js +++ b/addons/mail/static/src/js/thread.js @@ -58,6 +58,8 @@ var Thread = Widget.extend({ }, render: function (messages, options) { + clearTimeout(this.auto_render_timeout); + var self = this; var msgs = _.map(messages, this._preprocess_message.bind(this)); if (this.options.display_order === ORDER.DESC) { msgs.reverse(); @@ -83,6 +85,12 @@ var Thread = Widget.extend({ options: options, ORDER: ORDER, })); + + this.auto_render_timeout = setTimeout(function () { + if (!self.isDestroyed()) { + self.render(messages, options); + } + }, 1000*60); // re-render the thread every minute to update dates }, on_click_redirect: function (event) { @@ -110,7 +118,7 @@ var Thread = Widget.extend({ _preprocess_message: function (message) { var msg = _.extend({}, message); - // Set the date in the browser timezone + msg.date = moment.min(msg.date, moment()); var date = msg.date.format('YYYY-MM-DD'); if (date === moment().format('YYYY-MM-DD')) { diff --git a/addons/mail/static/src/less/chat_window.less b/addons/mail/static/src/less/chat_window.less index a4024c93dc1..d6c69f8d688 100644 --- a/addons/mail/static/src/less/chat_window.less +++ b/addons/mail/static/src/less/chat_window.less @@ -23,6 +23,10 @@ } } + @media print { + display: none; + } + .o_chat_header { .o-flex-display(); .o-flex(0, 0, auto); diff --git a/addons/mail/static/src/less/chatter.less b/addons/mail/static/src/less/chatter.less index 839e419e88e..8ea43b8373e 100644 --- a/addons/mail/static/src/less/chatter.less +++ b/addons/mail/static/src/less/chatter.less @@ -131,9 +131,3 @@ list-style: none; } } - -@media print { - .oe_chatter { - display: none; - } -} diff --git a/addons/mail/static/src/less/client_action.less b/addons/mail/static/src/less/client_action.less index aee37ab5e9f..d7b72cb7453 100644 --- a/addons/mail/static/src/less/client_action.less +++ b/addons/mail/static/src/less/client_action.less @@ -67,10 +67,18 @@ } } .o_mail_chat_channel_item { + .o-flex-display(); width: 100%; padding: 2px 8px 2px 1.5*@odoo-horizontal-padding; // larger padding-left than titles - > .badge { - margin: 0; + .o_channel_name { + .o-flex(1, 1, auto); + .o-text-overflow(); + } + .o_mail_sidebar_needaction, .o_mail_partner_unpin { + .o-flex(0, 0, auto); + } + .o_mail_sidebar_needaction { + margin: 0 0 0 5px; } .o_mail_partner_unpin { padding: 2px 6px; @@ -82,10 +90,11 @@ } .o_mail_add_channel { width: 100%; - padding: 5px 8px 5px 1.5*@odoo-horizontal-padding; // larger padding-left than titles + padding: 5px 1.5*@odoo-horizontal-padding; // larger padding-left than titles position: relative; > input { + width: 100%; padding: 2px 5px; padding-left: 12px; } @@ -172,8 +181,6 @@ opacity: 0.9; .o_mail_chat_channel_item { - overflow: hidden; - text-overflow: ellipsis; cursor: pointer; &:hover { diff --git a/addons/mail/static/src/less/composer.less b/addons/mail/static/src/less/composer.less index 88b44fec311..31ae4725ef0 100644 --- a/addons/mail/static/src/less/composer.less +++ b/addons/mail/static/src/less/composer.less @@ -11,6 +11,7 @@ .o_composer { .o_composer_input > textarea { + width: 100%; resize: none; } } diff --git a/addons/mail/static/src/xml/client_action.xml b/addons/mail/static/src/xml/client_action.xml index 1e38fe3d6dd..78371340e36 100644 --- a/addons/mail/static/src/xml/client_action.xml +++ b/addons/mail/static/src/xml/client_action.xml @@ -19,13 +19,13 @@
- @ Inbox + Inbox
- Starred + Starred
@@ -57,7 +57,7 @@
- + @@ -82,18 +82,20 @@ -
- - - - + + + + + + + # + + - # - - -