summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/xml
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-08-11 20:30:51 +0200
committerAlexandre Kühn <aku@odoo.com>2018-08-13 14:17:27 +0200
commitf2302dfb27dd7f6a0dee7c65ab75b62a01706264 (patch)
treed58fef9e2e8a5b98c0680f28fc92e24992236029 /addons/mail/static/src/xml
parent3de97f168956a7c22c3af6b72950cf28554f4139 (diff)
[REF][FIX] mail, im_livechat: various improvements (JS)
This commit makes a lot of small improvements of the JS of mail and related modules. A. Mail Manager --------------- im_support: - [REF] Slightly more robust way to determine a support message, so that it more reliably falls back on default kind of message (i.e. support channel UUID should be clearly set). mail: - [REF] Improved method names for readability purposes. Some examples: - `fetchFromServer` becomes `fetchMailStateFromServer` - `_initialize{*}` becomes `_update{*}FromServer` - `_isModerator` becomes `_isMyselfModerator` - [REF] Use 'template' pattern design to make Include on Mail Manager much more robust. In particular, the flow is always as follow: 1. Initialize internal state. 2. Listen on buses. 3. Fetch mail data from server. - [REF] Improved workflow for thread window workflow (Shorter & more readable). B. Mail Tests ------------- - [REF] Thread Window Tests crashes with clean message when there are some thread windows open before running the tests. C. (Model) Message ------------------ - [REF] Improved method names for readability purposes (e.g. `isAuthor` becomes `isMyselfAuthor`). D. (Model) Thread ----------------- - [REF] Improved `init` parameters on each kind of thread. - [REF] 'Thread With Cache' has been renamed to 'Searchable Thread': it embraces all kinds of threads that can be used with the search view. - [REF] 'DM' has been renamed to 'DM Chat' (for clarity). - [IMP] New Livechat model in the backend. - [REF] No more direct instances of the Channel class: public and private channels are now 'Multi-User' channels, while DM Chat and Livechat are 'Two-User' channels: This change has been made so that instances of classes always have direct classes as "leaf" in the Class modeling. It eases making changes to a certain model without being too constrained by another model. - [REF] As a consequence of above changed, the method `isChat` has been renamed to `isTwoUserThread`. This is to avoid confusion with the terminology 'chat', which is more like a shortcut for 'quick real- time conversation'. In other words, the property of 'chat' depends of the way to interact on a thread, not of the intrinsic type of the thread. Still, some parts have kept the terminology 'chat', such as in the systray messagin menu. - [IMP] Added `message_added` and `message_posted` hooks, which may be useful to easily hook on those events. E. Thread Widget ---------------- - [REF] Now uses a `mail.model.AbstractThread` for the rendering of a thread, instead of a list of `{mail.model.AbstractMessage}`. - [FIX] Stick thread scroll height to bottom on new rendering, if it was previously at the bottom of the thread. - [REF] Option ORDER has its meaning changed: it now refers to the chronological order of messages in the thread, in which DESC means 'from top to bottom', while ASC means 'from bottom to top'. - [REF] Improved doc on templates, in particular with the option `ORDER`. F. Thread Window ---------------- - [REF] Moved more logic to thread windows, which were previously in Mail Window Manager. - [REF] Now hides the thread widget attribute. So instead of `threadWindow.threadWidget.isAtBottom()`, it uses `threadWindow.isAtBottom()`. - [FIX] New received messages when not having focus on Odoo tab should always make the corresponding thread windows "passive" (i.e. windows that keep threads unread until click on them). - [FIX] Blank thread window (i.e. 'New message' TW) correctly opens Discuss with 'Inbox' when clicking on 'Expand' Button in the title - [FIX] Do not display the composer for channels with property 'mass-mailing' set in thread windows. G. (Website) Livechat --------------------- - [REF] Some `trigger` have been turned into `trigger_up`. - [REF] Some logic has been moved to models (e.g. `{im_livechat.model.WebsiteLivechat}`), from `{im_livechat.im_livechat.LivechatButton}`. - [FIX] New messages should be received in real-time. The longpolling was broken with a recent refactoring on bus service (6448420c5dd160470e465dee7729d19d8d5e7bab).
Diffstat (limited to 'addons/mail/static/src/xml')
-rw-r--r--addons/mail/static/src/xml/abstract_thread_window.xml2
-rw-r--r--addons/mail/static/src/xml/discuss.xml14
-rw-r--r--addons/mail/static/src/xml/thread.xml97
3 files changed, 90 insertions, 23 deletions
diff --git a/addons/mail/static/src/xml/abstract_thread_window.xml b/addons/mail/static/src/xml/abstract_thread_window.xml
index e62cdba042b..af72d5dd36c 100644
--- a/addons/mail/static/src/xml/abstract_thread_window.xml
+++ b/addons/mail/static/src/xml/abstract_thread_window.xml
@@ -15,7 +15,7 @@
</div>
<div class="o_thread_window_content">
</div>
- <div t-if='widget.hasThread()' class="o_thread_composer o_chat_mini_composer">
+ <div t-if="widget.needsComposer()" class="o_thread_composer o_chat_mini_composer">
<input class="o_composer_text_field" t-att-placeholder="widget.options.placeholder"/>
</div>
</div>
diff --git a/addons/mail/static/src/xml/discuss.xml b/addons/mail/static/src/xml/discuss.xml
index ad9a809ba03..eb03e3c0c55 100644
--- a/addons/mail/static/src/xml/discuss.xml
+++ b/addons/mail/static/src/xml/discuss.xml
@@ -40,7 +40,7 @@
<t t-set="counter" t-value="starredCounter"/>
<t t-call="mail.discuss.SidebarCounter"/>
</div>
- <div t-if="isModerator" t-attf-class="o_mail_discuss_title_main o_mail_discuss_item #{(activeThreadID == 'mailbox_moderation') ? 'o_active': ''}"
+ <div t-if="isMyselfModerator" 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"/>
@@ -58,7 +58,7 @@
<t t-set="inputPlaceholder">Add a channel</t>
</t>
- <t t-set="type" t-value="'dm'"/>
+ <t t-set="type" t-value="'dm_chat'"/>
<t t-call="mail.discuss.SidebarTitle">
<t t-set="title">Direct Messages</t>
<t t-set="icon" t-value="fa-user"/>
@@ -133,7 +133,7 @@
<input type="text" class="o_input" t-attf-placeholder="#{inputPlaceholder}"/>
</div>
<t t-foreach="threads" t-as="thread">
- <t t-set="counter" t-value="thread.getType() === 'mailbox' ? thread.getMailboxCounter() : thread.isChat() ? thread.getUnreadCounter() : thread.getNeedactionCounter()"/>
+ <t t-set="counter" t-value="thread.getType() === 'mailbox' ? thread.getMailboxCounter() : thread.isTwoUserThread() ? 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">
@@ -221,7 +221,7 @@
<span class="fa fa-inbox"/>
<span class="o_tab_title">Inbox</span>
</div>
- <div class="o_mail_mobile_tab" data-type="dm">
+ <div class="o_mail_mobile_tab" data-type="dm_chat">
<span class="fa fa-user"/>
<span class="o_tab_title">Chat</span>
</div>
@@ -246,7 +246,7 @@
<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="inputPlaceholder" t-if="type == 'private' || type == 'public'">Add a channel</t>
- <t t-set="inputPlaceholder" t-if="type == 'dm'">Open chat</t>
+ <t t-set="inputPlaceholder" t-if="type == 'dm_chat'">Open chat</t>
<input type="text" t-attf-placeholder="#{inputPlaceholder}"/>
</div>
<t t-foreach="previews" t-as="preview">
@@ -266,7 +266,7 @@
@param {string} [preview.documentModel]
@param {string|integer} preview.id
@param {string} [preview.imageSRC]
- @param {boolean} [preview.isAuthor]
+ @param {boolean} [preview.isMyselfAuthor]
@param {moment} [preview.date]
@param {string} [preview.author]
@param {string} [preview.body]
@@ -293,7 +293,7 @@
<span class="o_last_message_date"> <t t-esc="preview.date ? preview.date.fromNow() : ''"/> </span>
</div>
<div t-if="preview.body" class="o_last_message_preview">
- <t t-if="preview.isAuthor">
+ <t t-if="preview.isMyselfAuthor">
<span class="fa fa-mail-reply" role="img" aria-label="Reply"/> You:
</t>
<t t-elif="preview.author">
diff --git a/addons/mail/static/src/xml/thread.xml b/addons/mail/static/src/xml/thread.xml
index b3443418c2b..b33452382ac 100644
--- a/addons/mail/static/src/xml/thread.xml
+++ b/addons/mail/static/src/xml/thread.xml
@@ -3,22 +3,13 @@
<!--
@param {mail.model.AbstractThread} thread
+ @param {Object} options
@param {boolean} [options.displayEmptyThread]
- @param {boolean} [options.displayLoadMore]
@param {boolean} [options.displayNoMatchFound]
- @param {integer} [options.displayOrder] 1 or -1
- @param {Object} ORDER
- @param {integer} ORDER.ASC=1
- @param {integer} ORDER.DESC=-1
-->
<t t-name="mail.widget.Thread">
<t t-if="thread.hasMessages()">
- <t t-set="messages" t-value="thread.getMessages()"/>
- <t t-if="options.displayLoadMore and options.displayOrder == ORDER.ASC"
- t-call="mail.widget.Thread.LoadMore"/>
<t t-call="mail.widget.Thread.Content"/>
- <t t-if="options.displayLoadMore and options.displayOrder == ORDER.DESC"
- t-call="mail.widget.Thread.LoadMore"/>
</t>
<t t-elif="options.displayEmptyThread">
<t t-call="mail.widget.Thread.Empty" />
@@ -134,14 +125,90 @@
</div>
<!--
- @param {mail.model.AbstractMessage[]} messages messages ordered by increasing IDs
+ @param {mail.model.AbstractThread} thread
+ @param {Object} options
+ @param {integer} [options.displayOrder] 1 or -1 chronological order for the thread messages
+ @param {Object} ORDER
+ @param {integer} ORDER.ASC=1 messages are ordered by increasing IDs, from bottom to top
+ @param {integer} ORDER.DESC=-1 messages are ordered by increasing IDs, from top to bottom
+
+ Ordering of messages in the thread, messages are indexed by increasing IDs:
+ _____________ _____________
+ | | | |
+ | message 1 | | message n |
+ | message 2 | | ... |
+ | ... | | message 2 |
+ | message n | | message 1 |
+ |_____________| |_____________|
+
+ ORDER: DESC ASC
+
+ -->
+ <t t-name="mail.widget.Thread.Content">
+ <t t-set="messages" t-value="thread.getMessages()"/>
+ <t t-if="options.displayOrder === ORDER.ASC" t-call="mail.widget.Thread.Content.ASC"/>
+ <t t-else="" t-call="mail.widget.Thread.Content.DESC"/>
+ </t>
+
+ <!--
+ @param {mail.model.AbstractThread} thread
+ @param {Object} options
+ @param {boolean} [options.displayLoadMore=false]
@param {string|integer} [options.messagesSeparatorPosition] 'top' or
message ID, the separator is placed just after this message.
+
+ _____________
+ | |
+ | message n |
+ | ... |
+ | message 2 |
+ | message 1 |
+ |_____________|
+
+ ASC Order
+
-->
- <t t-name="mail.widget.Thread.Content">
- <t t-if="options.messagesSeparatorPosition == 'top'" t-call="mail.MessagesSeparator"/>
+ <t t-name="mail.widget.Thread.Content.ASC">
+ <div class="o_mail_thread_content_asc">
+ <t t-if="options.messagesSeparatorPosition == 'top'" t-call="mail.MessagesSeparator"/>
+ <t t-set="messages" t-value="messages.slice().reverse()"/>
+ <t t-call="mail.widget.Thread.Messages"/>
+ <t t-if="options.displayLoadMore" t-call="mail.widget.Thread.LoadMore"/>
+ </div>
+ </t>
+
+ <!--
+ @param {mail.model.AbstractThread} thread
+ @param {Object} options
+ @param {boolean} [options.displayBottomThreadFreeSpace=false]
+ @param {boolean} [options.displayLoadMore=false]
+
+ _____________
+ | |
+ | message 1 |
+ | message 2 |
+ | ... |
+ | message n |
+ |_____________|
+
+ DESC Order
+ -->
+ <t t-name="mail.widget.Thread.Content.DESC">
+ <div class="o_mail_thread_content_desc">
+ <t t-if="options.displayLoadMore" t-call="mail.widget.Thread.LoadMore"/>
+ <t t-call="mail.widget.Thread.Messages"/>
+ <t t-if="options.displayBottomThreadFreeSpace">
+ <div class="o_thread_bottom_free_space"/>
+ </t>
+ </div>
+ </t>
+
+ <!--
+ @param {mail.model.AbstractMessage[]} messages messages are ordered based
+ on desired display order
+ -->
+ <t t-name="mail.widget.Thread.Messages">
<t t-set="current_day" t-value="0"/>
- <t t-if="options.displayOrder === ORDER.DESC" t-set="messages" t-value="messages.slice().reverse()"/>
<t t-foreach="messages" t-as="message">
<div t-if="current_day !== message.getDateDay()" class="o_thread_date_separator">
<span class="o_thread_date">
@@ -261,7 +328,7 @@
<t t-if="message.needsModerationByUser()">
<t t-call="mail.MessageModerationDecision"/>
</t>
- <t t-elif="message.isAuthor()">
+ <t t-elif="message.isMyselfAuthor()">
<t t-call="mail.MessageModerationFeedback"/>
</t>
</t>