diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-06-12 15:46:46 +0200 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-07-02 15:06:54 +0200 |
| commit | cd34f6de727d5b3858420cff3c9d3c5995c4e75c (patch) | |
| tree | 8d25861f98a038b71728355375d634a5c178290e /addons/mail/static/src/xml/systray.xml | |
| parent | ee9c1f52c316c83775969a3c9038e7e9f560f7e7 (diff) | |
[REF] mail: JS mail refactoring
----------------------
Summary
----------------------
The purpose of this commit is to improve the JS code of the `mail` module.
It applies the new coding guidelines and makes some changes on the design
of some modules, such as the old ChatManager module.
Here is a short summary of the changes that have been made:
1. New coding guidelines
- snake_case to camelCase
- prefix private attributes and methods with '_'
- jsdoc on most methods
- one class per module
2. Rename/Merge some classes
- 'chat manager' becomes 'mail manager' (internal) and 'mail service' (external)
- 'chat window manager' is now included in mail manager
- 'thread' widget now named 'thread widget'
3. New model abstraction for mail objects:
- modules 'mail.model.*'
- modeling:
0..1 0..1 * *
ThreadWindow <------> Thread <-------> Message
/ \
/ \
Thread With Cache Document Thread
/ | \
/ | \
Mailbox Channel Support Channel
|
|
DM
- Thread: the superclass of threads.
- ThreadWindow: the window component of a thread.
- Message: mail objects representing messages.
- Thread With Cache: threads that can be used with search view (Discuss app compatible).
- Document Thread: represents the thread part of a chatter.
- Mailbox: represents what was previously called 'static' channel, e.g. 'Inbox'.
- Channel: mail objects representing channels, including livechat.
- DM: special kind of Channel for 1:1 communication in the backend.
- Support Channel: special channel for im_support module.
This new modeling approach let us easily add features on all threads, such as the
possibility to put any thread in a small window.
----------------------
Known issues
----------------------
[Already Present in Master]
1. When the Discuss app is in the background with 'Inbox' as the selected
Thread, when clicking on a document thread preview in the messaging menu
of the systray, the rainbow man appears.
2. When a document with the chatter is in the background, when receiving an
inbox notification from this document thread, the document thread is
automatically marked as read, which removes the notification right away.
3. Sometimes, opening a DM window from the "blank" thread window does not work.
4. Reply-to feature on Inbox is not working: no message is sent in the document
thread.
5. On the first login of admin user with demo data, the inbox counter is wrong
(it displays 6, instead of 3).
Explanation after investigation:
> On page load, it fetches the correct number of Inbox messages (3),
but the server notifies of 3 needaction messages right away,
so it wrongly assumes these are new needaction messages.
> Not possible for web client to detect that these messages should not
increment the Inbox counter while keeping same API.
6. Notifications for new document thread messages only work when the user sets
'handle with Odoo' for the Notification Management in the preferences.
> due to notifications on the longpoll bus for document thread
messages that come from needaction notifications.
> requires server-side changes to send notification on the longpoll
bus to mentionned user.
[New]
7. When receiving a message on a unjoined channel, thread window flickers
('open' > 'close' > 'open')
Explanation after investigation:
> JS logic:
a) On auto-join, ask server to join the channel and get channel infos.
b) The info tells the channel is not detached, but JS code makes decision
to detach it, and tells server the channel is now detached.
c) From (a), server notifies on longpoll bus the state of channel, which is
not detached. The web client thinks that the window state of the channel
has been changed somewhere else, and the channel is now closed.
d) From (b), server notifies on longpoll bus the state of channel, which is
detached. The web client opens the thread window of this channel.
> The flicker didn't occur before refactoring because the web client was only
updating the model of channel when it receives the longpoll notification.
> Server behaviour on 1st longpoll notification is necessary for cross-tab
synchronization for channel window state.
> New design implies that model and view should be synchronized, hence the
issue now.
> Solution: remove server-side thread window synchronization and replace with
client-side synchronization.
----------------------
Hacks
----------------------
The module `im_livechat` now uses mail objects that are compatible with Message
and Window objects:
Modeling for messages:
AbstractMessage
/ \
/ \
LivechatMessage Message
- AbstractMessage: message compatible with the thread widget.
- LivechatMessage: message used by im_livechat.
- Message: message used with the mail manager.
Modeling for thread windows:
AbstractThreadWindow
/ \
/ \
LivechatWindow ThreadWindow
- AbstractThreadWindow: behaviour share between all types of thread windows.
- LivechatWindow: window used by im_livechat.
- ThreadWindow: window used with mail_manager.
The reason for these hacks are twofold:
1. Use the thread widget in the frontend and livechat external lib bundles.
2. Do not have a dependency with the mail manager in the frontend and external
lib bundles.
Diffstat (limited to 'addons/mail/static/src/xml/systray.xml')
| -rw-r--r-- | addons/mail/static/src/xml/systray.xml | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/addons/mail/static/src/xml/systray.xml b/addons/mail/static/src/xml/systray.xml index 6350e07d2da..ae1d7f2879f 100644 --- a/addons/mail/static/src/xml/systray.xml +++ b/addons/mail/static/src/xml/systray.xml @@ -1,18 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> <templates> - <t t-name="mail.chat.MessagingMenu"> - <li class="o_mail_navbar_item"> + <!-- + @param {mail.systray.MessagingMenu} widget + --> + <t t-name="mail.systray.MessagingMenu"> + <li class="o_mail_systray_item"> <a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false" title="Conversations" href="#"> <i class="fa fa-comments" role="img" aria-label="Messages"/> <span class="o_notification_counter badge"/> </a> - <ul class="o_mail_navbar_dropdown dropdown-menu" role="menu"> - <li role="menuitem" t-if="widget.isMobile"> - <div class="o_mail_navbar_mobile_header"> + <ul class="o_mail_systray_dropdown dropdown-menu" role="menu"> + <li role="menuitem" t-if="widget.isMobile()"> + <div class="o_mail_systray_mobile_header"> <button type="button" class="btn btn-default btn-sm o_new_message"> New message </button> </div> </li> - <li role="menuitem" t-if="!widget.isMobile" class="o_mail_navbar_dropdown_top"> + <li role="menuitem" t-if="!widget.isMobile()" class="o_mail_systray_dropdown_top"> <div> <button type="button" class="btn btn-sm btn-link o_filter_button active"> All </button> <button type="button" class="btn btn-sm btn-link o_filter_button" data-filter='chat'> Chat </button> @@ -20,8 +23,8 @@ </div> <button type="button" class="btn btn-sm btn-link o_new_message"> New message </button> </li> - <li role="menuitem" class="o_mail_navbar_dropdown_channels"/> - <li role="menuitem" t-if="widget.isMobile"> + <li role="menuitem" class="o_mail_systray_dropdown_items"/> + <li role="menuitem" t-if="widget.isMobile()"> <div class="o_mail_mobile_tabs"> <div class="o_mail_mobile_tab o_filter_button active"> <span class="o_tab_title fa fa-envelope">All</span> @@ -38,31 +41,38 @@ </li> </t> - <t t-name="mail.chat.ChannelsPreview"> - <t t-if="_.isEmpty(channels)"> + <!-- + @param {Object} previews valid list of objects for preview rendering + (see mail.Preview template) + --> + <t t-name="mail.systray.MessagingMenu.Previews"> + <t t-if="_.isEmpty(previews)"> <li class="text-center o_no_activity mt16"> - <span>No discussion yet...</span> + <span>No conversation yet...</span> </li> </t> - <t t-foreach="channels" t-as="channel"> - <t t-call="mail.chat.ChannelPreview"/> + <t t-foreach="previews" t-as="preview"> + <t t-call="mail.Preview"/> </t> </t> - <t t-name="mail.chat.ActivityMenuPreview"> + <!-- + @param {Object[]} activities + --> + <t t-name="mail.systray.ActivityMenu.Previews"> <t t-if="_.isEmpty(activities)"> <li class="text-center o_no_activity"> <span>No activities planned.</span> </li> </t> <t t-foreach="activities" t-as="activity"> - <div class="o_mail_channel_preview" t-att-data-res_model="activity.model" t-att-data-model_name="activity.name" data-filter='my'> - <div class="o_mail_channel_image o_mail_channel_app"> + <div class="o_mail_preview" t-att-data-res_model="activity.model" t-att-data-model_name="activity.name" data-filter='my'> + <div class="o_mail_preview_image o_mail_preview_app"> <img t-att-src="activity.icon" alt="Activity"/> </div> - <div class="o_channel_info"> - <div class="o_channel_title"> - <span class="o_channel_name"> + <div class="o_preview_info"> + <div class="o_preview_title"> + <span class="o_preview_name"> <t t-esc="activity.name"/> </span> </div> @@ -79,13 +89,13 @@ </t> </t> - <t t-name="mail.chat.ActivityMenu"> - <li class="o_mail_navbar_item"> + <t t-name="mail.systray.ActivityMenu"> + <li class="o_mail_systray_item"> <a class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false" title="Activities" href="#"> <i class="fa fa-clock-o" role="img" aria-label="Activities"/> <span class="o_notification_counter badge"/> </a> - <ul class="o_mail_navbar_dropdown dropdown-menu" role="menu"> - <li role="menuitem" class="o_mail_navbar_dropdown_channels"/> + <ul class="o_mail_systray_dropdown dropdown-menu" role="menu"> + <li role="menuitem" class="o_mail_systray_dropdown_items"/> </ul> </li> </t> |
