summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/scss/abstract_thread_window.scss
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-06-12 15:46:46 +0200
committerAlexandre Kühn <aku@odoo.com>2018-07-02 15:06:54 +0200
commitcd34f6de727d5b3858420cff3c9d3c5995c4e75c (patch)
tree8d25861f98a038b71728355375d634a5c178290e /addons/mail/static/src/scss/abstract_thread_window.scss
parentee9c1f52c316c83775969a3c9038e7e9f560f7e7 (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/scss/abstract_thread_window.scss')
-rw-r--r--addons/mail/static/src/scss/abstract_thread_window.scss156
1 files changed, 156 insertions, 0 deletions
diff --git a/addons/mail/static/src/scss/abstract_thread_window.scss b/addons/mail/static/src/scss/abstract_thread_window.scss
new file mode 100644
index 00000000000..c55662f4bb3
--- /dev/null
+++ b/addons/mail/static/src/scss/abstract_thread_window.scss
@@ -0,0 +1,156 @@
+$o-mail-thread-window-zindex: $zindex-modal + 1 !default;
+
+.o_thread_window {
+ @include o-flex-display;
+ @include o-flex-flow(column, nowrap);
+ position: fixed;
+ width: $o-mail-thread-window-width;
+ max-width: 100%;
+ height: 400px;
+ max-height: 100%;
+ font-size: 12px;
+ background-color: $o-mail-thread-window-bg;
+ border-radius: 6px 6px 0 0;
+ z-index: $o-mail-thread-window-zindex;
+ box-shadow: -5px -5px 10px rgba(black, 0.18);
+
+ @media (max-width: $screen-xs-max) {
+ width: 100%;
+ height: 100%!important;
+ box-shadow: none;
+ &.o_folded {
+ display: none;
+ }
+ }
+
+ @media print {
+ display: none;
+ }
+
+ .o_thread_window_header {
+ @include o-flex-display;
+ @include o-flex(0, 0, auto);
+ color: white;
+ padding: $o-mail-chatter-gap*0.5 $o-mail-chatter-gap;
+ border-radius: 3px 3px 0 0;
+ border-bottom: 1px solid $gray-lighter-dark;
+ background-color: $o-brand-primary;
+ padding: 8px;
+
+ @media (max-width: $screen-xs-max) {
+ height: $o-mail-chat-header-height;
+ padding-top: 12px;
+ border-radius: 0px;
+ .o_thread_window_title {
+ font-size: 16px;
+ margin-left: 10px;
+ }
+
+ .o_thread_window_close {
+ font-size: 17px;
+ color: white;
+ }
+ }
+
+ .o_thread_window_title {
+ cursor: pointer;
+ @include o-flex(1, 1, auto);
+ @include o-text-overflow;
+ }
+
+ .o_thread_window_buttons {
+ @include o-flex(0, 0, auto);
+ .o_thread_window_close, .o_thread_window_expand {
+ color: white;
+ padding: 3px;
+ margin-left: 5px;
+ @include o-hover-opacity(0.7, 1);
+ }
+ }
+
+ }
+
+ .o_mail_thread {
+ @include o-flex(1, 1, auto);
+ overflow: auto;
+ -webkit-overflow-scrolling: touch; // smooth scrolling in iOS app (Safari)
+ .o_thread_date_separator {
+ margin: 0px 0px 15px 0px;
+ .o_thread_date {
+ background-color: $o-mail-thread-window-bg;
+ }
+ }
+ .o_thread_message {
+ padding: 4px 5px;
+ .o_thread_message_sidebar {
+ margin-right: 5px;
+ }
+ }
+ }
+
+ .o_thread_composer input {
+ width: 100%;
+ }
+}
+
+.o_thread_window_dropdown {
+ width: auto;
+ height: 28px;
+ color: white;
+ background-color: $gray-dark;
+ cursor: pointer;
+ box-shadow: none;
+
+ @media (max-width: $screen-xs-max) {
+ display: none;
+ }
+
+ .o_thread_window_header {
+ border-radius: 0;
+ }
+
+ .o_thread_window_dropdown_toggler {
+ padding: 5px;
+
+ .o_total_unread_counter {
+ @include o-position-absolute(-10px, 0, auto, auto);
+ background-color: $o-brand-optional;
+ padding: 0 2px;
+ font-size: smaller;
+ }
+ }
+ &.open .o_thread_window_dropdown_toggler .o_total_unread_counter, .o_thread_window_expand {
+ display: none;
+ }
+
+ > ul {
+ max-width: $o-mail-thread-window-width;
+ padding: 0;
+
+ > li.o_thread_window_header {
+ font-size: 12px;
+ padding: 3px 5px;
+ &~li.o_thread_window_header {
+ border-top: 1px solid white;
+ }
+ &:hover {
+ background-color: darken($o-brand-primary, 10%);
+ }
+ }
+ }
+}
+
+.o_ui_blocked .o_thread_window {
+ // We cannot put the z-index of thread windows directly to be greater than
+ // blockUI's as ui-autocomplete dropdowns (which are below blockUI) would
+ // appear under the thread windows (and ui-autocomplete is used to choose the
+ // person you want to chat with). So we only raise the z-index value when
+ // the ui is really blocked (in that case, the ui-autocomplete dropdowns
+ // will disappear under the thread windows but this is not really an issue as
+ // there should not be any at that time).
+ z-index: 1101; // blockUI's z-index is 1100
+}
+
+.o_no_thread_window .o_thread_window {
+ display: none;
+}