diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-11-29 20:06:16 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-11-29 20:06:16 +0100 |
| commit | ce4cc24621bf6430d7d3a2d469b375b59120c200 (patch) | |
| tree | 3837b5fe41ff88b24136ab53c871bc01f965cab1 /addons/mail/static/src/js | |
| parent | 4d7aa97da38e497fef31a06543bfa5d2c8785708 (diff) | |
| parent | 82a1e1dcc33d7c123e50d3e1aacb5e127f57c521 (diff) | |
[MERGE] forward port branch 12.0 up to 82a1e1dcc33
Diffstat (limited to 'addons/mail/static/src/js')
| -rw-r--r-- | addons/mail/static/src/js/composers/mention_manager.js | 4 | ||||
| -rw-r--r-- | addons/mail/static/src/js/discuss.js | 8 | ||||
| -rw-r--r-- | addons/mail/static/src/js/models/threads/channel.js | 12 | ||||
| -rw-r--r-- | addons/mail/static/src/js/models/threads/mailbox.js | 21 | ||||
| -rw-r--r-- | addons/mail/static/src/js/models/threads/multi_user_channel.js | 10 | ||||
| -rw-r--r-- | addons/mail/static/src/js/services/mail_manager.js | 14 | ||||
| -rw-r--r-- | addons/mail/static/src/js/systray/systray_messaging_menu.js | 4 | ||||
| -rw-r--r-- | addons/mail/static/src/js/tour.js | 38 |
8 files changed, 83 insertions, 28 deletions
diff --git a/addons/mail/static/src/js/composers/mention_manager.js b/addons/mail/static/src/js/composers/mention_manager.js index 7acecadc062..907263328cc 100644 --- a/addons/mail/static/src/js/composers/mention_manager.js +++ b/addons/mail/static/src/js/composers/mention_manager.js @@ -378,9 +378,9 @@ var MentionManager = Widget.extend({ var textInput = this._composer.$input.val(); var id = $(ev.currentTarget).data('id'); var suggestions = _.flatten(this.get('mention_suggestions')); - var selectedSuggestion = _.find(suggestions, function (s) { + var selectedSuggestion = _.clone(_.find(suggestions, function (s) { return s.id === id; - }); + })); var substitution = selectedSuggestion.substitution; if (!substitution) { // no substitution string given, so use the mention name instead diff --git a/addons/mail/static/src/js/discuss.js b/addons/mail/static/src/js/discuss.js index 032ab1bddef..2cb9fe749d7 100644 --- a/addons/mail/static/src/js/discuss.js +++ b/addons/mail/static/src/js/discuss.js @@ -852,7 +852,7 @@ var Discuss = AbstractAction.extend(ControlPanelMixin, { // Update control panel before focusing the composer, otherwise // focus is on the searchview - self.set("title", '#' + self._thread.getName()); + self.set("title", self._thread.getTitle()); self._updateControlPanel(); self._updateControlPanelButtons(self._thread); @@ -1321,12 +1321,16 @@ var Discuss = AbstractAction.extend(ControlPanelMixin, { */ _onPostMessage: function (messageData) { var self = this; + var options = {}; if (this._selectedMessage) { messageData.subtype = this._selectedMessage.isNote() ? 'mail.mt_note': 'mail.mt_comment'; messageData.subtype_id = false; messageData.message_type = 'comment'; + + options.documentID = this._selectedMessage.getDocumentID(); + options.documentModel = this._selectedMessage.getDocumentModel(); } - this._thread.postMessage(messageData) + this._thread.postMessage(messageData, options) .then(function () { if (self._selectedMessage) { self._renderSnackbar('mail.discuss.MessageSentSnackbar', { diff --git a/addons/mail/static/src/js/models/threads/channel.js b/addons/mail/static/src/js/models/threads/channel.js index 808e8b7fbca..ff90ca8edfb 100644 --- a/addons/mail/static/src/js/models/threads/channel.js +++ b/addons/mail/static/src/js/models/threads/channel.js @@ -217,21 +217,11 @@ var Channel = SearchableThread.extend(ThreadTypingMixin, { return _.extend(result, { author: lastMessage ? lastMessage.getDisplayedAuthor() : '', body: lastMessage ? mailUtils.parseAndTransform(lastMessage.getBody(), mailUtils.inline) : '', - date: lastMessage ? lastMessage.getDate() : moment(), + date: lastMessage ? lastMessage.getDate() : undefined, isMyselfAuthor: this.hasMessages() && this.getLastMessage().isMyselfAuthor(), }); }, /** - * Returns the title to display in thread window's headers. - * For channels, the title is prefixed with "#". - * - * @override - * @returns {string|Object} the name of the thread by default (see getName) - */ - getTitle: function () { - return "#" + this._super.apply(this, arguments); - }, - /** * Get the UUID of the channel. * This is a string that uniquely links this channel to a server channel. * diff --git a/addons/mail/static/src/js/models/threads/mailbox.js b/addons/mail/static/src/js/models/threads/mailbox.js index 82d65bdd6cc..263072f575e 100644 --- a/addons/mail/static/src/js/models/threads/mailbox.js +++ b/addons/mail/static/src/js/models/threads/mailbox.js @@ -189,6 +189,27 @@ var Mailbox = SearchableThread.extend({ throw (_.str(_t("Missing domain for mailbox with ID '%s'"), this._id)); } }, + /** + * Post a message from inbox. This is used when using the 'reply' feature + * on a message that is linked to a document thread. + * + * @override + * @private + * @param {Object} messageData + * @param {Object} options + * @param {integer} options.documentID + * @param {string} options.documentModel + * @returns {$.Promise} + */ + _postMessage: function (messageData, options) { + var documentThread = this.call( + 'mail_service', + 'getDocumentThread', + options.documentModel, + options.documentID + ); + return documentThread.postMessage(messageData); + }, }); return Mailbox; diff --git a/addons/mail/static/src/js/models/threads/multi_user_channel.js b/addons/mail/static/src/js/models/threads/multi_user_channel.js index c1681744127..85d60fc1183 100644 --- a/addons/mail/static/src/js/models/threads/multi_user_channel.js +++ b/addons/mail/static/src/js/models/threads/multi_user_channel.js @@ -26,6 +26,16 @@ var MultiUserChannel = Channel.extend({ //-------------------------------------------------------------------------- /** + * Returns the title to display in thread window's headers. + * For channels, the title is prefixed with "#". + * + * @override + * @returns {string|Object} the name of the thread by default (see getName) + */ + getTitle: function () { + return "#" + this._super.apply(this, arguments); + }, + /** * States whether this thread has the mass mailing setting active or not. * This is a server-side setting, that determine the type of composer that * is used (basic or extended composer). diff --git a/addons/mail/static/src/js/services/mail_manager.js b/addons/mail/static/src/js/services/mail_manager.js index c21089b7095..6a49cdf0183 100644 --- a/addons/mail/static/src/js/services/mail_manager.js +++ b/addons/mail/static/src/js/services/mail_manager.js @@ -1108,8 +1108,9 @@ var MailManager = AbstractService.extend({ * Sort previews * * 1. unread, - * 2. two-user thread, - * 3. date, + * 2. dated previews + * 3. two-user thread, + * 4. date, * * @private * @param {Object[]} previews @@ -1118,13 +1119,10 @@ var MailManager = AbstractService.extend({ _sortPreviews: function (previews) { var res = previews.sort(function (p1, p2) { var unreadDiff = Math.min(1, p2.unreadCounter) - Math.min(1, p1.unreadCounter); + var datedDiff = !!p2.date - !!p1.date; var isTwoUserThreadDiff = p2.isTwoUserThread - p1.isTwoUserThread; - var dateDiff = (!!p2.date - !!p1.date) || - ( - p2.date && - p2.date.diff(p1.date) - ); - return unreadDiff || isTwoUserThreadDiff || dateDiff; + var dateDiff = p2.date && p2.date.diff(p1.date); + return unreadDiff || datedDiff || isTwoUserThreadDiff || dateDiff; }); return res; }, diff --git a/addons/mail/static/src/js/systray/systray_messaging_menu.js b/addons/mail/static/src/js/systray/systray_messaging_menu.js index d86e9e3913b..df35de47174 100644 --- a/addons/mail/static/src/js/systray/systray_messaging_menu.js +++ b/addons/mail/static/src/js/systray/systray_messaging_menu.js @@ -102,8 +102,8 @@ var MessagingMenu = Widget.extend({ var channelUnreadCounters = _.map(channels, function (channel) { return channel.getUnreadCounter(); }); - var unreadChannelCounter = _.reduce(channelUnreadCounters, function (c1, c2) { - return c1 + c2; + var unreadChannelCounter = _.reduce(channelUnreadCounters, function (acc, c) { + return c > 0 ? acc + 1 : acc; }, 0); var inboxCounter = this.call('mail_service', 'getMailbox', 'inbox').getMailboxCounter(); var mailFailureCounter = this.call('mail_service', 'getMailFailures').length; diff --git a/addons/mail/static/src/js/tour.js b/addons/mail/static/src/js/tour.js index 10ee548b00b..6b7160f2aa6 100644 --- a/addons/mail/static/src/js/tour.js +++ b/addons/mail/static/src/js/tour.js @@ -6,21 +6,53 @@ var tour = require('web_tour.tour'); var _t = core._t; -tour.register('mail_tour', [{ +tour.register('mail_tour', { + url: "/web", +}, [tour.STEPS.SHOW_APPS_MENU_ITEM, { + trigger: '.o_app[data-menu-xmlid="mail.menu_root_discuss"]', + content: _t('Want to <b>get in touch</b> with your contacts? <i>Discuss with them here.</i>'), + position: 'right', + edition: 'community', +}, { + trigger: '.o_app[data-menu-xmlid="mail.menu_root_discuss"]', + content: _t('Want to <b>get in touch</b> with your contacts? <i>Discuss with them here.</i>'), + position: 'bottom', + edition: 'enterprise', +}, { trigger: '.o_mail_discuss .o_mail_discuss_sidebar .o_add[data-type="public"]', content: _t("<p>Channels make it easy to organize information across different topics and groups.</p> <p>Try to <b>create your first channel</b> (e.g. sales, marketing, product XYZ, after work party, etc).</p>"), position: 'bottom', }, { + trigger: '.o_mail_discuss .o_mail_discuss_sidebar .o_mail_add_thread[data-type="public"]', + content: _t("<p>Create a channel here.</p>"), + position: 'right', + run: function (actions) { + var t = new Date().getTime(); + actions.text("SomeChannel_" + t, this.$anchor.find("input")); + }, +}, { + trigger: ".ui-menu-item > a", + auto: true, + in_modal: false, +}, { trigger: '.o_mail_discuss .o_composer_text_field', content: _t("<p><b>Write a message</b> to the members of the channel here.</p> <p>You can notify someone with <i>'@'</i> or link another channel with <i>'#'</i>. Start your message with <i>'/'</i> to get the list of possible commands.</p>"), position: "top", width: 350, + run: function (actions) { + var t = new Date().getTime(); + actions.text("SomeText_" + t, this.$anchor); + }, +}, { + trigger: '.o_mail_discuss .o_thread_composer .o_composer_button_send', + content: _t("Post your message on the thread"), + position: "top", }, { - trigger: ".o_mail_discuss .o_mail_thread .o_thread_message_star", + trigger: '.o_mail_discuss .o_mail_thread .o_thread_message_star', content: _t("Messages can be <b>starred</b> to remind you to check back later."), position: "right", }, { - trigger: '.o_mail_discuss .o_mail_item_item[data-thread-id="mailbox_starred"]', + trigger: '.o_mail_discuss .o_mail_discuss_item[data-thread-id="mailbox_starred"]', content: _t("Once a message has been starred, you can come back and review it at any time here."), position: "bottom", }, { |
