diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/mail/static/src/widgets/messaging_menu/messaging_menu.js | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/mail/static/src/widgets/messaging_menu/messaging_menu.js')
| -rw-r--r-- | addons/mail/static/src/widgets/messaging_menu/messaging_menu.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/addons/mail/static/src/widgets/messaging_menu/messaging_menu.js b/addons/mail/static/src/widgets/messaging_menu/messaging_menu.js new file mode 100644 index 00000000..edfef630 --- /dev/null +++ b/addons/mail/static/src/widgets/messaging_menu/messaging_menu.js @@ -0,0 +1,56 @@ +odoo.define('mail/static/src/widgets/messaging_menu/messaging_menu.js', function (require) { +'use strict'; + +const components = { + MessagingMenu: require('mail/static/src/components/messaging_menu/messaging_menu.js'), +}; + +const SystrayMenu = require('web.SystrayMenu'); +const Widget = require('web.Widget'); + +/** + * Odoo Widget, necessary to instantiate component. + */ +const MessagingMenu = Widget.extend({ + template: 'mail.widgets.MessagingMenu', + /** + * @override + */ + init() { + this._super(...arguments); + this.component = undefined; + }, + /** + * @override + */ + destroy() { + if (this.component) { + this.component.destroy(); + } + this._super(...arguments); + }, + async on_attach_callback() { + const MessagingMenuComponent = components.MessagingMenu; + this.component = new MessagingMenuComponent(null); + await this.component.mount(this.el); + // unwrap + this.el.parentNode.insertBefore(this.component.el, this.el); + this.el.parentNode.removeChild(this.el); + }, +}); + +// Systray menu items display order matches order in the list +// lower index comes first, and display is from right to left. +// For messagin menu, it should come before activity menu, if any +// otherwise, it is the next systray item. +const activityMenuIndex = SystrayMenu.Items.findIndex(SystrayMenuItem => + SystrayMenuItem.prototype.name === 'activity_menu'); +if (activityMenuIndex > 0) { + SystrayMenu.Items.splice(activityMenuIndex, 0, MessagingMenu); +} else { + SystrayMenu.Items.push(MessagingMenu); +} + +return MessagingMenu; + +}); |
