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/discuss.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/discuss.xml')
| -rw-r--r-- | addons/mail/static/src/xml/discuss.xml | 316 |
1 files changed, 190 insertions, 126 deletions
diff --git a/addons/mail/static/src/xml/discuss.xml b/addons/mail/static/src/xml/discuss.xml index 7901a870ea3..493d3c918aa 100644 --- a/addons/mail/static/src/xml/discuss.xml +++ b/addons/mail/static/src/xml/discuss.xml @@ -1,12 +1,16 @@ <?xml version="1.0" encoding="UTF-8"?> <templates xml:space="preserve"> - <!-- Discuss --> + <!-- + Discuss Main template + + @param {mail.discuss} widget + --> <t t-name="mail.discuss"> - <div class="o_mail_chat"> - <div class="o_mail_chat_sidebar"/> - <div class="o_mail_chat_content"> - <t t-if="widget.notification_bar"> + <div class="o_mail_discuss"> + <div class="o_mail_discuss_sidebar"/> + <div class="o_mail_discuss_content"> + <t t-if="widget.displayNotificationBar"> <div class="o_mail_annoying_notification_bar"> <span class="o_mail_request_permission">Odoo needs your permission to <a href="#"> enable desktop notifications</a>.</span> <span class="fa fa-close" role="button" aria-label="Close" title="Close"></span> @@ -15,145 +19,184 @@ </div> </div> </t> - <t t-name="mail.chat.Sidebar"> - <div class="o_mail_chat_sidebar"> - <div t-attf-class="o_mail_chat_title_main o_mail_chat_channel_item #{(active_channel_id === 'channel_inbox') ? 'o_active': ''}" - data-channel-id="channel_inbox"> - <span class="o_channel_name fa fa-inbox mr8">Inbox</span> - <t t-set="counter" t-value="needaction_counter"/> - <t t-call="mail.chat.SidebarNeedaction"/> + + <!-- + @param {string|integer} activeThreadID + @param {integer} moderationCounter + @param {integer} needactionCounter + @param {integer} starredCounter + --> + <t t-name="mail.discuss.Sidebar"> + <div class="o_mail_discuss_sidebar"> + <div t-attf-class="o_mail_discuss_title_main o_mail_discuss_item #{(activeThreadID === 'mailbox_inbox') ? 'o_active': ''}" + data-thread-id="mailbox_inbox"> + <span class="o_thread_name fa fa-inbox mr8">Inbox</span> + <t t-set="counter" t-value="needactionCounter"/> + <t t-call="mail.discuss.SidebarCounter"/> </div> - <div t-attf-class="o_mail_chat_title_main o_mail_chat_title_starred o_mail_chat_channel_item #{(active_channel_id === 'channel_starred') ? 'o_active': ''}" - data-channel-id="channel_starred"> - <span class="o_channel_name fa fa-star-o mr8">Starred</span> - <t t-set="counter" t-value="starred_counter"/> - <t t-call="mail.chat.SidebarNeedaction"/> + <div t-attf-class="o_mail_discuss_title_main o_mail_mailbox_title_starred o_mail_discuss_item #{(activeThreadID === 'mailbox_starred') ? 'o_active': ''}" + data-thread-id="mailbox_starred"> + <span class="o_thread_name fa fa-star-o mr8">Starred</span> + <t t-set="counter" t-value="starredCounter"/> + <t t-call="mail.discuss.SidebarCounter"/> </div> - <div t-if="isModerator" t-attf-class="o_mail_chat_title_main o_mail_chat_channel_item #{(active_channel_id == 'channel_moderation') ? 'o_active': ''}" - data-channel-id="channel_moderation"> - <span class="o_channel_name"> <i class="fa fa-envelope mr8"/>Moderation Queue</span> + <div t-if="isModerator" t-attf-class="o_mail_discuss_title_main o_mail_discuss_item #{(activeThreadID == 'mailbox_moderation') ? 'o_active': ''}" + data-thread-id="mailbox_moderation"> + <span class="o_thread_name"> <i class="fa fa-envelope mr8"/>Moderation Queue</span> <t t-set="counter" t-value="moderationCounter"/> - <t t-call="mail.chat.SidebarNeedaction"/> + <t t-call="mail.discuss.SidebarCounter"/> </div> <hr class="mb8"/> - <t t-set="channel_type" t-value="'public'"/> - <t t-call="mail.chat.SidebarTitle"> - <t t-set="channel_title">Channels</t> - <t t-set="channel_icon" t-value="fa-users"/> + <t t-set="type" t-value="'public'"/> + <t t-call="mail.discuss.SidebarTitle"> + <t t-set="title">Channels</t> + <t t-set="icon" t-value="fa-users"/> </t> - <t t-call="mail.chat.SidebarItems"> - <t t-set="display_hash" t-value="true"/> - <t t-set="input_placeholder">Add a channel</t> + <t t-call="mail.discuss.SidebarItems"> + <t t-set="displayHash" t-value="true"/> + <t t-set="inputPlaceholder">Add a channel</t> </t> - <t t-set="channel_type" t-value="'dm'"/> - <t t-call="mail.chat.SidebarTitle"> - <t t-set="channel_title">Direct Messages</t> - <t t-set="channel_icon" t-value="fa-user"/> + <t t-set="type" t-value="'dm'"/> + <t t-call="mail.discuss.SidebarTitle"> + <t t-set="title">Direct Messages</t> + <t t-set="icon" t-value="fa-user"/> </t> - <t t-call="mail.chat.SidebarItems"> - <t t-set="display_status" t-value="true"/> - <t t-set="input_placeholder">User name</t> + <t t-call="mail.discuss.SidebarItems"> + <t t-set="displayStatus" t-value="true"/> + <t t-set="inputPlaceholder">User name</t> </t> - <t t-set="channel_type" t-value="'private'"/> - <t t-call="mail.chat.SidebarTitle"> - <t t-set="channel_title">Private Channels</t> - <t t-set="channel_icon" t-value="fa-eye-slash"/> + <t t-set="type" t-value="'private'"/> + <t t-call="mail.discuss.SidebarTitle"> + <t t-set="title">Private Channels</t> + <t t-set="icon" t-value="fa-eye-slash"/> </t> - <t t-call="mail.chat.SidebarItems"> - <t t-set="input_placeholder">Add a private channel</t> - <t t-set="display_hash" t-value="true"/> + <t t-call="mail.discuss.SidebarItems"> + <t t-set="inputPlaceholder">Add a private channel</t> + <t t-set="displayHash" t-value="true"/> </t> </div> </t> - <t t-name="mail.chat.SidebarNeedaction"> + + <!-- + @param {integer} counter + --> + <t t-name="mail.discuss.SidebarCounter"> <span t-attf-class="o_mail_sidebar_needaction badge #{(!counter ? 'hide' : '')}"> <t t-esc="counter"/> </span> </t> - <t t-name="mail.chat.SidebarTitle"> - <!-- Don't display the channel type if there is no channel of such type - and the 'add a channel' option is disabled for this type --> - <t t-if="disable_add_channel"> + + <!-- + Don't display the thread type if there is no thread of such type + and the 'add a channel' option is disabled for this type + + @param {mail.model.Thread[]} threads + @param {boolean} [disableAddThread] whether the 'Add thread' action should disabled or not for the considered discuss item category + @param {string} [icon] classname to add on title to display icon + @param {string} title the displayed type of the discuss items (e.g. "Private Channels") + @param {string} type the type of the thread + --> + <t t-name="mail.discuss.SidebarTitle"> + <t t-if="disableAddThread"> <t t-set="empty" t-value="true"/> - <t t-foreach="channels" t-as="channel"> - <t t-if="channel.type === channel_type"> + <t t-foreach="threads" t-as="thread"> + <t t-if="thread.getType() === type"> <t t-set="empty" t-value="false"/> </t> </t> </t> - <t t-if="!disable_add_channel || !empty"> + <t t-if="!disableAddThread || !empty"> <div class="o_mail_sidebar_title"> - <h4 t-att-class="channel_type == 'public' ? 'o_mail_open_channels' : ''"> - <i t-if="channel_icon" t-attf-class="mr4 fa-fw fa #{channel_icon}" role="img" aria-label="Channel" title="Channel"></i> - <b><t t-esc="channel_title"/></b> + <h4 t-att-class="type == 'public' ? 'o_mail_open_channels' : ''"> + <i t-if="icon" t-attf-class="mr4 fa-fw fa #{icon}" role="img" aria-label="Channel" title="Channel"></i> + <b><t t-esc="title"/></b> </h4> - <span t-if="!disable_add_channel" class="fa fa-plus o_add" title="Add" t-attf-data-type="#{channel_type}" role="img" aria-label="Add"/> + <span t-if="!disableAddThread" class="fa fa-plus o_add" title="Add" t-attf-data-type="#{type}" role="img" aria-label="Add"/> </div> </t> </t> - <t t-name="mail.chat.SidebarItems"> - <div t-if="!disable_add_channel" class="o_mail_add_channel" t-attf-data-type="#{channel_type}"> - <span t-if="display_hash">#</span> - <input type="text" class="o_input" t-attf-placeholder="#{input_placeholder}"/> + + <!-- + @param {string|integer} activeThreadID + @param {mail.model.Thread[]} threads + @param {boolean} disableAddThread whether the 'Add thread' action should be disable or not for the considered discuss item category + @param {boolean} [displayHash] whether the hash ('#') character should be displayed as a prefix for item's name + @param {boolean} [displayStatus] whether the item should display its status (should be the case only for chats) + @param {string} inputPlaceholder text placeholder on showing input in a sidebar category + --> + <t t-name="mail.discuss.SidebarItems"> + <div t-if="!disableAddThread" class="o_mail_add_thread" t-attf-data-type="#{type}"> + <span t-if="displayHash">#</span> + <input type="text" class="o_input" t-attf-placeholder="#{inputPlaceholder}"/> </div> - <t t-foreach="channels" t-as="channel"> - <t t-set="counter" t-value="channel.is_chat ? channel.unread_counter : channel.needaction_counter"/> - <div t-if="channel.type === channel_type" t-att-data-channel-id="channel.id" t-att-title="channel.name" - t-attf-class="o_mail_chat_channel_item #{channel.unread_counter ? ' o_unread_message' : ''} #{(active_channel_id == channel.id) ? 'o_active': ''}"> - <span class="o_channel_name"> - <span t-if="display_status"> - <t t-call="mail.chat.UserStatus"> - <t t-set="status" t-value="channel.status"/> + <t t-foreach="threads" t-as="thread"> + <t t-set="counter" t-value="thread.getType() === 'mailbox' ? thread.getMailboxCounter() : thread.isChat() ? thread.getUnreadCounter() : thread.getNeedactionCounter()"/> + <div t-if="thread.getType() === type" t-att-data-thread-id="thread.getID()" t-att-title="thread.getName()" + t-attf-class="o_mail_discuss_item #{thread.hasUnreadMessages() ? ' o_unread_message' : ''} #{(activeThreadID == thread.getID()) ? 'o_active': ''}"> + <span class="o_thread_name"> + <span t-if="displayStatus"> + <t t-call="mail.UserStatus"> + <t t-set="status" t-value="thread.getStatus()"/> </t> </span> - <span t-if="display_hash" class="o_mail_hash">#</span> - <t t-esc="channel.name"/> - <i t-if="channel.mass_mailing" class="fa fa-envelope-o" title="Sends messages by email" role="img" aria-label="Send by mail"/> + <span t-if="displayHash" class="o_mail_hash">#</span> + <t t-esc="thread.getName()"/> + <i t-if="thread.isMassMailing()" class="fa fa-envelope-o" title="Sends messages by email" role="img" aria-label="Send by mail"/> </span> <span t-attf-class="fa fa-cog o_mail_channel_settings" - title="Channel settings" role="img" aria-label="Channel settings" t-att-data-channel-id="channel.id"/> - <t t-call="mail.chat.SidebarNeedaction"/> - <span t-if="! channel.group_based_subscription" t-attf-class="fa fa-times o_mail_partner_unpin #{counter ? 'hide' : ''}" - title="Leave this channel" role="img" aria-label="Leave this channel" t-att-data-channel-id="channel.id"/> + title="Channel settings" role="img" aria-label="Channel settings" t-att-data-thread-id="thread.getID()"/> + <t t-call="mail.discuss.SidebarCounter"/> + <span t-if="!thread.isGroupBasedSubscription()" t-attf-class="fa fa-times o_mail_partner_unpin #{counter ? 'hide' : ''}" + title="Leave this channel" role="img" aria-label="Leave this channel" t-att-data-thread-id="thread.getID()"/> </div> </t> </t> - <t t-name="mail.chat.UserStatus"> + <!-- + @param {string} status + --> + <t t-name="mail.UserStatus"> <i t-if="status == 'online'" class="o_mail_user_status o_user_online fa fa-circle" title="Online" role="img" aria-label="User is online"/> <i t-if="status == 'away'" class="o_mail_user_status o_user_idle fa fa-circle" title="Idle" role="img" aria-label="User is idle"/> <i t-if="status == 'offline'" class="o_mail_user_status fa fa-circle-o" title="Offline" role="img" aria-label="User is offline"/> </t> - <t t-name="mail.chat.MessageSentSnackbar"> + <!-- + @param {string} documentName + --> + <t t-name="mail.discuss.MessageSentSnackbar"> <div class="alert o_mail_snackbar" data-dismiss="alert" role="alert"> - Message sent in "<t t-esc="record_name"/>". + Message sent in "<t t-esc="documentName"/>". </div> </t> - <!-- Buttons of the Control Panel --> - <t t-name="mail.chat.ControlButtons"> + <!-- + Buttons of the Control Panel + + @param {boolean} [disableAddThread] whether the 'Add channel' action should be disabled or not for the considered discuss item category + --> + <t t-name="mail.discuss.ControlButtons"> <div> - <button type="button" class="btn btn-primary btn-sm o_mail_chat_button_invite hidden-xs" title="Invite people">Invite</button> - <button type="button" class="btn btn-default btn-sm o_mail_chat_button_mark_read hidden-xs" title="Mark all as read">Mark all read</button> - <button type="button" class="btn btn-default btn-sm o_mail_chat_button_unstar_all" title="Unstar all messages">Unstar all</button> - <button type="button" class="btn btn-default btn-sm o_mail_chat_button_dm visible-xs" title="New Message">New Message</button> - <button t-if="!disable_add_channel" type="button" class="btn btn-default btn-sm o_mail_chat_button_public o_mail_chat_button_private visible-xs" title="New Channel">New Channel</button> - <button type="button" class="btn btn-default btn-sm o_hidden o_mail_chat_button_select_all" title="Select all messages to moderate">Select All</button> - <button type="button" class="btn btn-default btn-sm o_hidden o_mail_chat_button_unselect_all" title="Unselect all messages to moderate">Unselect All</button> - <button type="button" data-decision="accept" class="btn btn-default btn-sm o_mail_chat_button_moderate_all" title="Accept selected messages">Accept</button> - <button type="button" data-decision="reject" class="btn btn-default btn-sm o_mail_chat_button_moderate_all" title="Reject selected messages">Reject</button> - <button type="button" data-decision="discard" class="btn btn-default btn-sm o_mail_chat_button_moderate_all" title="Discard selected messages">Discard</button> + <button type="button" class="btn btn-primary btn-sm o_mail_discuss_button_invite hidden-xs" title="Invite people">Invite</button> + <button type="button" class="btn btn-default btn-sm o_mail_discuss_button_mark_all_read hidden-xs" title="Mark all as read">Mark all read</button> + <button type="button" class="btn btn-default btn-sm o_mail_discuss_button_unstar_all" title="Unstar all messages">Unstar all</button> + <button type="button" class="btn btn-default btn-sm o_mail_discuss_button_dm visible-xs" title="New Message">New Message</button> + <button t-if="!disableAddThread" type="button" class="btn btn-default btn-sm o_mail_discuss_button_public o_mail_discuss_button_private visible-xs" title="New Channel">New Channel</button> + <button type="button" class="btn btn-default btn-sm o_hidden o_mail_discuss_button_select_all" title="Select all messages to moderate">Select All</button> + <button type="button" class="btn btn-default btn-sm o_hidden o_mail_discuss_button_unselect_all" title="Unselect all messages to moderate">Unselect All</button> + <button type="button" data-decision="accept" class="btn btn-default btn-sm o_mail_discuss_button_moderate_all" title="Accept selected messages">Accept</button> + <button type="button" data-decision="reject" class="btn btn-default btn-sm o_mail_discuss_button_moderate_all" title="Reject selected messages">Reject</button> + <button type="button" data-decision="discard" class="btn btn-default btn-sm o_mail_discuss_button_moderate_all" title="Discard selected messages">Discard</button> </div> </t> <!-- Invite dialog's content --> <div t-name="mail.PartnerInviteDialog"> - <input type="text" class="o_input o_mail_chat_partner_invite_input" id="mail_search_partners"/> + <input type="text" class="o_input o_mail_discuss_partner_invite_input" id="mail_search_partners"/> </div> <div t-name="mail.ModeratorRejectMessageDialog"> @@ -163,17 +206,18 @@ <!-- Mobile templates --> <t t-name="mail.discuss_mobile"> - <div class="o_mail_chat"> - <div class="o_mail_chat_mobile_inbox_buttons"> - <button type="button" class="btn btn-primary btn-sm visible-xs-inline o_channel_inbox_item" title="Inbox" data-type="channel_inbox"> + <div class="o_mail_discuss"> + <div class="o_mail_discuss_mobile_mailboxes_buttons"> + <button type="button" class="btn btn-primary btn-sm visible-xs-inline o_mailbox_inbox_item" title="Inbox" data-type="mailbox_inbox"> Inbox - </button><button type="button" class="btn btn-default btn-sm visible-xs-inline o_channel_inbox_item" title="Starred" data-type="channel_starred"> + </button> + <button type="button" class="btn btn-default btn-sm visible-xs-inline o_mailbox_inbox_item" title="Starred" data-type="mailbox_starred"> Starred </button> </div> - <div class="o_mail_chat_content"/> + <div class="o_mail_discuss_content"/> <div class="o_mail_mobile_tabs"> - <div class="o_mail_mobile_tab" data-type="channel_inbox"> + <div class="o_mail_mobile_tab" data-type="mailbox_inbox"> <span class="o_tab_title fa fa-inbox">Inbox</span> </div> <div class="o_mail_mobile_tab" data-type="dm"> @@ -189,51 +233,71 @@ </div> </t> - <t t-name="mail.chat.MobileTabPane"> - <div class="o_mail_chat_tab_pane" t-att-data-type="type"> - <div t-if="!disable_add_channel" class="o_mail_add_channel" t-att-data-type="type"> + <!-- + @param {boolean} [disableAddThread] whether the 'Add thread' action should be disabled or not for the considered discuss item category + @param {Object[]} previews valid objects for preview rendering (see mail.Preview template) + --> + <t t-name="mail.discuss.MobileTabPane"> + <div class="o_mail_discuss_tab_pane" t-att-data-type="type"> + <div t-if="!disableAddThread" class="o_mail_add_thread" t-att-data-type="type"> <span t-if="type == 'private' || type == 'public'">#</span> - <t t-set="input_placeholder" t-if="type == 'private' || type == 'public'">Add a channel</t> - <t t-set="input_placeholder" t-if="type == 'dm'">Open chat</t> - <input type="text" t-attf-placeholder="#{input_placeholder}"/> + <t t-set="inputPlaceholder" t-if="type == 'private' || type == 'public'">Add a channel</t> + <t t-set="inputPlaceholder" t-if="type == 'dm'">Open chat</t> + <input type="text" t-attf-placeholder="#{inputPlaceholder}"/> </div> - <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> </div> </t> - <!-- The ChannelPreview template is used by the discuss in mobile, and by the systray menu --> - <t t-name="mail.chat.ChannelPreview"> - <div t-attf-class="o_mail_channel_preview #{channel.unread_counter ? 'o_channel_unread' : ''}" - t-att-data-channel_id="channel.id" t-att-data-res_id="channel.res_id" t-att-data-res_model="channel.model"> - <div t-attf-class="o_mail_channel_image #{channel.model? 'o_mail_channel_app' : ''}"> - <img class="o_mail_channel_image" t-att-src="channel.image_src" alt="Channel"/> - <i t-if="channel.status === 'online'" class="o_mail_user_status o_user_online fa fa-circle" title="Online" role="img" aria-label="User is online"/> - <i t-if="channel.status === 'away'" class="o_mail_user_status o_user_idle fa fa-circle" title="Idle" role="img" aria-label="User is idle"/> + <!-- + The preview template is used by the discuss in mobile, and by the systray menu + In order to show preview of threads + + FIXME: it is shared with systray, so it should not be in discuss.xml + + @param {Object} preview a valid object for preview rendering + @param {integer} [preview.documentID] + @param {string} [preview.documentModel] + @param {string|integer} preview.id + @param {string} [preview.imageSRC] + @param {boolean} [preview.isAuthor] + @param {moment} [preview.date] + @param {string} [preview.author] + @param {string} [preview.body] + @param {string} [preview.title] + @param {string} [preview.status] + @param {integer} [preview.unreadCounter] + --> + <t t-name="mail.Preview"> + <div t-attf-class="o_mail_preview #{preview.unreadCounter > 0 ? 'o_preview_unread' : ''}" + t-att-data-preview-id="preview.id" t-att-data-document-id="preview.documentID" t-att-data-document-model="preview.documentModel"> + <div t-attf-class="o_mail_preview_image #{preview.documentModel ? 'o_mail_preview_app' : ''}"> + <img class="o_mail_preview_image" t-att-src="preview.imageSRC" alt="Channel"/> + <i t-if="preview.status === 'online'" class="o_mail_user_status o_user_online fa fa-circle" title="Online" role="img" aria-label="User is online"/> + <i t-if="preview.status === 'away'" class="o_mail_user_status o_user_idle fa fa-circle" title="Idle" role="img" aria-label="User is idle"/> </div> - <div class="o_channel_info"> - <div class="o_channel_title"> - <span class="o_channel_name"> - <t t-esc="channel.name"/> + <div class="o_preview_info"> + <div class="o_preview_title"> + <span class="o_preview_name"> + <t t-esc="preview.title"/> </span> - <span class="o_channel_counter"> - <t t-if="channel.unread_counter">&nbsp;(<t t-esc="channel.unread_counter"/>)</t> + <span class="o_preview_counter"> + <t t-if="preview.unreadCounter > 0">&nbsp;(<t t-esc="preview.unreadCounter"/>)</t> </span> - <span class="o_last_message_date"> <t t-esc="channel.last_message_date"/> </span> + <span class="o_last_message_date"> <t t-esc="preview.date ? preview.date.fromNow() : ''"/> </span> </div> - <div t-if="channel.last_message" class="o_last_message_preview"> - <t t-if="channel.last_message.is_author"> + <div t-if="preview.body" class="o_last_message_preview"> + <t t-if="preview.isAuthor"> <span class="fa fa-mail-reply" role="img" aria-label="Reply"/> You: </t> - <t t-else=""> - <t t-if="channel.last_message.displayed_author"> - <t t-esc="channel.last_message.displayed_author"/>: - </t> + <t t-elif="preview.author"> + <t t-esc="preview.author"/>: </t> - <t t-raw="channel.last_message_preview"/> + <t t-raw="preview.body"/> </div> - <span t-att-data-channel_id="channel.id" t-att-data-res_id="channel.res_id" t-att-data-model="channel.model" title="Mark as Read" class="o_discuss_icon o_mail_channel_mark_read fa fa-check" t-if="channel.unread_counter"/> + <span title="Mark as Read" class="o_discuss_icon o_mail_preview_mark_as_read fa fa-check" t-if="preview.unreadCounter"/> </div> </div> </t> |
