summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/thread.js
AgeCommit message (Collapse)Author
2018-07-19[RENAME] im_livechat,mail: rename widget 'thread.js' file to 'thread_widget.js'Alexandre Kühn
It is a bit annoying to have two files named 'thread.js', one being the widget and the other the mail model.
2018-07-02[REF] mail: JS mail refactoringAlexandre Kühn
---------------------- 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.
2018-06-07[ADD] mail, mass_mailing: allow a user to resend a mail with failuresXavierDo
When a mail is in failure state, a red envelope appears next to the message in a thread but it was difficult to send the mail again. This tasks will allow users to send mail again easily, or mark notification as cancelled if the user want to ignore this failure. A notification will appear in sender systray while mail are in failure. Task: #46158 PR: #24628
2018-06-06[IMP] mail: add moderation on channelsMathieu Duckaerts-Antoine
Purpose of this commit is to allow moderation on incoming messages in discussion channels. On some channels on which moderation is required messages should be in a pending moderation stage. Moderators can accept or refuse messages as well as always allow or ban messages coming from a given set of emails. Channels now have an option to be moderated. Moderators can be added on channels. They have access to a specific UI in Discuss to see and take action on messages waiting for moderation. Concerning mail.thread message that are pending moderation are not notified. It means nobody receives a notification about them. Moderation process calls the notification once the message is validated. Various features included in this commit : * a model is added to store the decision about emails, allow or ban; * access rights are updated so that only moderators can modify moderation fields on message; * specific bus notifications are send to moderated people as well as to moderators on incoming emails as well as when a decision is taken; * options are added on channels to send explanations to moderated emails; * options are added on channels to write and send guidelines explaining why and how moderation is performed; * a reminder is send daily to moderators with remaining messages to moderate; * discuss UI is adapted and a new channel is added below Inbox and Starred giving access to moderation tools; * chanenl UI is adapted allowing to moderate directly inside channels; This commit is linked to task ID 29521. Closes #21921.
2018-05-09[MERGE] forward port branch saas-11.2 up to aae54ecc159Christophe Simonis
2018-05-04[MERGE] forward port branch 11.0 up to 8dade01e2c5Christophe Simonis
2018-05-03[FIX] mail: Do not close chat widnow if ESCAPE key is pressed on document ↵Akash Bhavsar
viewer and keep focus on chat window input when document viewer is closed (#22741) If document viewer is opened from chat window and when document viewer is opened then focus remains on it's modal, pressing escape should set focus back to chat window's input element, if file selecor dialog is opened and if user press ESCAPE on file selector dialog to cancel file selector dialog then it should not close chat window instead it should set focus on chat window input and on second ESCAPE key chat window should be closed also increase z-index of document viewer dialog so image remain on top of cht window OPW: 1777937
2018-04-06[IMP] mail: attachments list designstefanorigano
With this commit, the attachments displayed in a thread (typically a chatter) are properly styled.
2018-03-30[IMP] mail: Discuss: load older messages automaticallydbh
After this rev., in Discuss, messages are automatically loaded when the user scrolls to the top of the channel. Task 33958 Co-authored-by: Aaron Bohy <aab@odoo.com>
2018-03-20[MERGE] forward port branch 11.0 up to 2835d299792Christophe Simonis
2018-03-13[FIX] mail: redirect: prevent double-clicksAaron Bohy
This rev. increases the wait interval of the redirect handler called when a document is clicked in a mail thread (e.g. in the 'Inbox' in Discuss). This increases the protection against double-clicks (preventing the document from being opened twice, thus making twice the required RPCs, and from appearing twice in the breadcrumbs). A more robust solution (at the ActionManager level) will be developed for saas-11.2 (where the ActionManager has been refactored and is testable).
2018-02-22[MERGE] forward port branch saas-11.1 up to e750bb6e114Christophe Simonis
2018-02-21[MERGE] forward port branch saas-16 up to 49f85485571Christophe Simonis
2018-02-21[FIX] mail: no view edit on forum link in notifNicolas Lempereur
When sending notification from the frontend, if a template is rendered for it and the user has the group "website.group_website_publisher" he will get inherit_branding adding on elements things like: data-oe-id="42" data-oe-model="ir.ui.view" data-oe-field="arch" but the chatter system has feature automatically redirecting an element that have attribute "data-oe-id": this caused for example that a link notification towards the forum would instead be redirecting to editing the view of the notification. This fix distinguish the inherit_branding in the chatter feature and ignore them. opw-813333 closes #23225
2018-02-01[REF][IMP] *: mail js refactoringAaron Bohy
This commit improves the JS code of the mail module, which comes maily from the new coding guidelines and the addition of "JS services". JS services are important objects that do not fit well in the component tree, such as chat_manager or ajax. The benefits of JS services are improved readability of the code, reduced coupling, and more testable modules. In particular, discuss was hard to Summary of the changes: - ClientAction has been renamed into Discuss - Clear instantiation of chatManager - New coding guidelines in most mail modules - JS Services can interact with each other - Chat Manager and Window Manager are services - Window Manager renamed to Chat Window Manager - bus.bus is now encapsulated in Bus Service (a service) - The test infrastructure has been tweaked with JS Services - Chat Mixin has been removed A future improvement would be to translate some 'trigger' into 'trigger_up'.
2018-01-17[IMP] mail: chatter creation message in formviewAlexandre Kühn
Before this commit, when we create a new object (e.g. task, product, ...), the part of the form for the chatter was blank. After this commit, it displays the chatter with a single temporary message 'Creating a new record...' This message is only visible by the user that is creating the task, and goes away when saving the newly created task. Any interaction with the chatter (buttons and widgets at the top of the chatter, including the message itself) are disabled, so that no interaction from the user is possible.
2017-12-05[FIX] web,*: time format from user's languageAlexandre Kühn
Before this fix, the chatter always showed dates of messages in military time format. This was not the expected behavior, as the user could have had customize the date and time format in the settings of the current language. Steps to reproduce the issue: 1. Set Odoo in English 2. Settings > Translations > Languages > English 2.1. Set Date Format to %m/%d/%Y 2.2. Set Time Format to %I:%M:%S %p 3. CRM > (Select any opportunity with at least one message) > Mouse hover on elapsed time (e.g. "an hour ago") Expected: - It shows the customized time format (e.g. 11/07/2017 5:33:36 PM) Results: - It shows the military time format (e.g. Tue Nov 07 2017 17:33:36 GMT+0100) opw-781647
2017-09-18[FIX] *: fix a bunch of incorrectly documented docstringXavier Morel
Fix a bunch of ill-documented/incomplete/incorrect method docs Without this, the automatic doc generation does not work.
2017-09-05[IMP] mail: Add a preview popup for attachmentsjpr-odoo
Purpose ======= The goal is that when you click on an attachment, you should get a preview of it and then you get the possibility to download it.
2017-07-19[FIX] mail: fix wrong adjustment in the chat window Mahendra Barad
In the chat, there is an indication of when a message was sent, This indication gets updated as time passes. When the last one in the conversation is updated to an indication that takes more space (e.g. from 'now' to 'a minute ago'), the text below is pushed lower (as expected) but the chatter does not scroll down. As a result, we do not see new messages, unless manually scrolling down. (PR #17469)
2016-09-01[IMP] mail: improve notification management for customersThibault Delavallée
Currently it is impossible in Discuss to know whether an email has been sent to a customer and whether it failed or bounced. A notified partner has an entry in the needaction m2m table. In this commit we decorate this table to add fields about the email notification: is an email sent, did it failed, did it bounce. This information is kept only for customers. Internal users does not use this information. Moreover their notification is deleted once the message is read in the Chatter. This avoids having a notification table that grows quickly. Chatter now holds a new icon for email details. It allows to know on a thread status of emails sent to customers.
2016-08-26[MERGE] forward port branch saas-10 up to 7a4116cChristophe Simonis
2016-08-25[MERGE] forward port branch 9.0 up to c578fb7Christophe Simonis
2016-08-23[FIX] mail: preprocess tracking fields of type date/datetime only onceJeremy Kersten
Before this commit, if a message thread was loaded 2 times, the first time the date was well formatted, the second time that fail because momentjs cannot parse the localized date from some locale. Luckily, it was not bugged by default in english, because moment was able to reparse a localized US date. But in some local as french, momentjs cannot parse the localized date and return 'Invalid date' Now, we move the code, to be processed only once by the chat manager, and not in each process of the thread. This commit closes issue #13258 Courtesy of @aab-odoo
2016-06-15[MERGE] forward port of branch saas-10 up to baf494cChristophe Simonis
# Conflicts: # addons/hr_timesheet/project_timesheet.py # addons/sale_layout/i18n/es_PE.po # addons/sale_layout/i18n/hu.po # addons/sale_layout/i18n/lo.po # addons/sale_layout/i18n/pl.po # addons/sale_service/i18n/es_MX.po # addons/sale_service/i18n/es_PE.po # addons/sale_service/i18n/lo.po # addons/stock/stock.py # addons/stock/stock_view.xml # addons/warning/i18n/es_PE.po # addons/warning/i18n/lo.po # addons/warning/i18n/ru.po # addons/web/i18n/cs.po # addons/web/i18n/ja.po # addons/web/i18n/lo.po # addons/web/i18n/th.po
2016-06-15[MERGE] forward port of branch saas-9 up to 1d81bb0Christophe Simonis
# Conflicts: # addons/account_extra_reports/i18n/ca.po # addons/account_extra_reports/i18n/fi.po # addons/account_extra_reports/i18n/pl.po # addons/account_extra_reports/i18n/te.po # addons/account_extra_reports/i18n/zh_CN.po # addons/account_full_reconcile/i18n/hu.po # addons/account_full_reconcile/i18n/pl.po # addons/crm/crm_lead_menu.xml # addons/crm_claim/i18n/es_PE.po # addons/crm_claim/i18n/hu.po # addons/crm_claim/i18n/ja.po # addons/crm_claim/i18n/pl.po # addons/delivery/views/delivery_view.xml # addons/product/product_view.xml # addons/project_timesheet/i18n/es_PE.po # addons/stock/stock_view.xml
2016-06-09[FIX] mail: display date and datetime in tracking value with the right timzeone.Jeremy Kersten
When tracking value is converted to be rendered as a message_post, we convert the date/datetime with the current local from momentjs. Related to #12327 Courtesy of @aab-odoo for help and review.
2016-05-26[MERGE] forward port of branch saas-10 up to 57944dbChristophe Simonis
2016-05-26[FIX] mail: multiple read more - better heuristicAdrien Dieudonne
- wildcard selector for stopSpelling - <br> tags must not split read more/read less
2016-05-25[FIX] mail: mutiple read moreAdrien Dieudonne
A read more was added to every node having a mail-quote tag. However all quotes and their child nodes are tagged, leading to numerous unnecessary read more / read less. Now, all consecutive mail-quote are joined in one 'read more/read less'.
2016-05-03[ADD] mail: commands supportAaron Bohy
Use the mention mechanism to autocomplete on commands (keyword /). A first command /help has been implemented.
2016-04-06[FIX] mail: Fix read more link navigation issueJigar Patel
2016-03-03[FIX] mail: only update timestamps periodicallyGéry Debongnie
the messages in a thread were previously rerendered every minutes to update their timestamps. This commit only update the timestamps, not all the message. This will allow us to keep expanded/folded state in messages without collapsing them every minutes. [IMP] mail: add read more/read less support client side Messages are cleaned up and tagged server sides, with a attribute data-o-mail-quote. This commit replace their content with a clickable read more link, which toggle its display.
2016-03-03[CLEAN] tools, mail: remove html_email_cleanThibault Delavallée
Remove html_email_clean in tools. Remove shorten in mail.
2016-02-08[FIX] mail: don't display subject of messages written in a chatterAaron Bohy
This was working fine until rev. 4bab99bd which accidentaly changes the condition.
2016-02-05[FIX] mail: various UI fixesGéry Debongnie
- correct template for undo snackbar - better padding for chat windows - recent messages now display 'now' instead of 'a few seconds ago'
2016-02-03[FIX] mail: users can now reply directly in documents from channelsGéry Debongnie
A missing feature in discuss was the possibility to directly reply to a message from a channel without opening the document. This commit add that feature. Now, there is a small 'reply' icon in channels (including inbox/starred) if the message comes from another document. This icon opens an extended composer, which will post the message in the document chatter.
2016-02-02[FIX] mail: keep expanded messages expanded after refreshAaron Bohy
Commit c04103f re-renders the thread every minute to update messages' date. As a consequence, the expanded messages are lost (they are shortened again). This rev. makes sure to keep those messages expanded.
2016-02-01[FIX] mail: don't notify 'join/left' messagesAaron Bohy
Messages of type 'notification' and whose model is 'mail.channel' are considered as 'system notifications'. This is the case of 'join/left' messages. They aren't taken into account when computing unread messages anymore. Also use the same heuristic to decide whether or not to display the message's star, so from now on pure notifications (not system notifications), like status change on a document, can be starred.
2016-01-29[FIX] mail: various UI fixes/improvementsAaron Bohy
- don't print chat windows - add missing 'width: 100%' on composer and Discuss sidebar inputs (required for community edition) - center the Discuss sidebar inputs - Discuss sidebar items layout: one line, text ellipsis if name is too long - hide chatter in 'create' mode (messages wrote in the chatter need a res_model and a res_id, the latter is not yet existing if we are in 'create' mode) - revert 2d2dacc: print chatter by default (classname 'hidden-print' can be used for specific models for which we don't want the chatter to be printed) - thread: ensure the displayed message's date is in the past - re-render threads every minutes to update dates - don't squash messages in mass mailing channels
2016-01-14[IMP] mail: various UI improvementsGéry Debongnie
- don't add 'New message from' in the title of notifications when an author name is defined - use a simple O icon instead of the full Odoo logo when a notification is natively displayed - don't scroll to bottom if the thread is not already at bottom - don't mark a channel read if thread is not at the bottom - add # in front of channel name in chat windows and in invite dialog - accept anonymous names in channel (for ex, livechat channels) - always go to the next line with shift+enter - always send message with ctrl+enter - pressing enter sends message or go to next line depending of context - don't allow to detach mass mailing channels
2015-12-16[FIX] mail: correctly redirect to channelsAaron Bohy
Clicking on a channel link should open that channel in Discuss, not the channel form view.
2015-12-11[FIX] mail: various UI improvements to chat interfaceGéry Debongnie
- don't display user name in chat windows - scroll to the new messages separator if it exists (in client action) - increase sidebar width - add correct link href in threads - hide chat window in mobile mode - mail: ignore o_mail_redirect or o_channel_redirect, but redirect anyway
2015-12-09[FIX] mail: various ui improvements/fixesAaron Bohy
- display full content of messages in Discuss - no content helpers in inbox and starred improved - mark as read tooltip instead of mark ad done - decrease font size in chat windows - increase chat windows dimensions - display avatars in chat windows - chat window background is now white - notes are displayed with a darker background
2015-12-08[FIX] mail: localized timeNicolas Martinelli
Time is now localized in the discussion.
2015-12-08[FIX] mail: thread: oe_mail_expand: execute handler onceAaron Bohy
The read_more button displayed in long messages is an <a> inside a <span>, both having classname oe_mail_expand, and an handler in bound on that classname since rev. 169f819a. This handler was executed twice when clicking on that button, toggling twice the message's bodies long and short, thus doing nothing.
2015-12-07[FIX] mail: read more: prevent defaultAaron Bohy
Long messages are not displayed entirely, but a 'read more' button is displayed and allows to show the whole message. This button is an <a> inside a <span>, both having classname 'oe_mail_expand'. Also note that messages are html, not plain text. Sometimes, the long message is truncated at some point that the 'read more' is inserted inside an <a>, which is not html valid (nested links). In this case, the browser automatically moves the inner <a> out of the outer one. Unfortunately, when that happens, clicking on 'read more' redirects to the app switcher because of missing prevent_default(), as the event handler was bound on the <span> clicked, not the inner <a>. This rev. simply binds the handler on 'oe_mail_expand', not specifically on its <span>.
2015-12-07[IMP] mail: various improvementGéry Debongnie
- don't display subject for messages coming from chatter - better tooltip on the leave channel button in client action sidebar - don't squash nearby messages in chatter - reduce margin of date separator in chat windows
2015-11-27[FIX] mail: various improvements/fixesGéry Debongnie
- display appropriate message when no results are found in a search - don't display 'you have been invited' notif when creating private channel - correctly join when a user was invited in a public channel - display a message when a user join a channel through an invitation - don't display subject for message of type notification (still a mystery why it happens in test.odoo.com for channel of type mailing) - better heuristic on when to display message subject - tweak sidebar text color (slightly whiter) - add ... to the placeholder of the text area in the composer - invert send and icons for attach/smiley in composer - don't display 'read less' on expanded messages - exclude livechat channels from channel mention suggestions
2015-11-26[FIX] mail, im_livechat: correctly displayed message dateGéry Debongnie
Messages are required to be displayed in a smarter way: relative to the current date, if it's a recent message, or absolute if not. This commits rework most of the date processing code to comply with these requirements. Messages were preprocessed each time a thread is rendered, which is stupid. It should be preprocessed only when the message is created. This was a small problem because livechat does not use the chat manager, so a simplified version of the preprocessing had to be done.