summaryrefslogtreecommitdiff
path: root/addons/sms/static/src/js/thread_widget.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-04-17 09:53:05 +0000
committerSébastien Theys <seb@odoo.com>2020-04-17 12:17:57 +0000
commitdea52493b819939ae16391d8b19c2f404c7ec143 (patch)
treeda5729bab3ff9bc36825480f54c838b17fced580 /addons/sms/static/src/js/thread_widget.js
parent69b51ce05e855b2b95e75919ac97996a1ff5e136 (diff)
[IMP] mail, sms, snailmail, test_mail_full: adapt mail.notification
The purpose is to have more common code for failure and notifications, with less override in `sms` and `snailmail`. task-2176017 closes odoo/odoo#44170 Related: odoo/enterprise#9140 Related: odoo/upgrade#918 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/sms/static/src/js/thread_widget.js')
-rw-r--r--addons/sms/static/src/js/thread_widget.js86
1 files changed, 12 insertions, 74 deletions
diff --git a/addons/sms/static/src/js/thread_widget.js b/addons/sms/static/src/js/thread_widget.js
index 4655732b34d..b64d6b064f0 100644
--- a/addons/sms/static/src/js/thread_widget.js
+++ b/addons/sms/static/src/js/thread_widget.js
@@ -2,88 +2,26 @@ odoo.define('sms.widget.Thread', function (require) {
"use strict";
var ThreadWidget = require('mail.widget.Thread');
-var core = require('web.core');
-
-var QWeb = core.qweb;
ThreadWidget.include({
- events: _.extend({}, ThreadWidget.prototype.events, {
- 'click .o_thread_message_sms_error': '_onClickSMSError'
- }),
- /**
- * @override
- */
- init: function () {
- this._super.apply(this, arguments);
- this._enabledOptions = _.defaults(this._enabledOptions, {
- displaySmsIcons: true,
- });
- this._disabledOptions = _.defaults(this._disabledOptions, {
- displaySmsIcons: false,
- });
- },
- /**
- * @override
- */
- render: function (thread, options) {
- this._super.apply(this, arguments);
- var messages = _.clone(thread.getMessages({domain: options.domain || []}));
- this._renderMessageSmsPopover(messages);
- },
-
- //--------------------------------------------------------------------------
- // Private
- //--------------------------------------------------------------------------
-
- /**
- * Render the popover when mouse-hovering on the mail icon of a message
- * in the thread. There is at most one such popover at any given time.
- *
- * @private
- * @param {mail.model.AbstractMessage[]} messages list of messages in the
- * rendered thread, for which popover on mouseover interaction is
- * permitted.
- */
- _renderMessageSmsPopover: function (messages) {
- if (this._messageSmsPopover) {
- this._messageSmsPopover.popover('hide');
- }
- if (!this.$('.o_thread_sms_tooltip').length) {
- return;
- }
- this._messageSmsPopover = this.$('.o_thread_sms_tooltip').popover({
- html: true,
- boundary: 'viewport',
- placement: 'auto',
- trigger: 'hover',
- offset: '0, 1',
- content: function () {
- var messageID = $(this).data('message-id');
- var message = _.find(messages, function (message) {
- return message.getID() === messageID;
- });
- return QWeb.render('sms.widget.Thread.Message.SmsTooltip', {
- data: message.getSmsIds()
- });
- },
- });
- },
-
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
- * @private
- * @param {MouseEvent} ev
+ * @override
*/
- _onClickSMSError: function (ev) {
- var messageID = $(ev.currentTarget).data('message-id');
- this.do_action('sms.sms_resend_action', {
- additional_context: {
- default_mail_message_id: messageID
- }
- });
+ _onClickMessageNotificationError(ev) {
+ if ($(ev.currentTarget).data('message-type') === 'sms') {
+ var messageID = $(ev.currentTarget).data('message-id');
+ this.do_action('sms.sms_resend_action', {
+ additional_context: {
+ default_mail_message_id: messageID
+ }
+ });
+ } else {
+ this._super(...arguments);
+ }
},
});
});