summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/composers/basic_composer.js
AgeCommit message (Collapse)Author
2020-06-15[REF] mail, *: refactor messaging with OWLSébastien Theys
This commit is a significant rewriting of client-side discuss, chatter, chat window, and messaging menu using OWL. The behavior should be broadly the same, with some slight functional changes here and there. From a technical standpoint, the code of messaging is mainly organized in 2 main groups of modules: - models, which are logical entities that depict the client-side state of messaging as a whole. - components, which are in charge of displaying information from models. This refactoring also introduces new JS guidelines regarding folder structure (/static) and naming rules for JS modules. Community PR: https://github.com/odoo/odoo/pull/39023 Enterprise PR: https://github.com/odoo/enterprise/pull/6249 Task-1914207 This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier, with the precious help of Lucas to speed it up towards the end. closes odoo/odoo#39023 Related: odoo/enterprise#6249 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Alexandre Kühn <aku@odoo.com> Co-authored-by: Julien Giannone <jgi@odoo.com> Co-authored-by: Lucas Perais <lpe@odoo.com> Co-authored-by: Sébastien Theys <seb@odoo.com> Co-authored-by: Xavier Dubuc <xdu@odoo.com>
2020-06-12[IMP] *: update notifications to optional titleJulien Mougenot
closes odoo/odoo#52826 Related: odoo/enterprise#11084 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-05-18[FIX] mail: do not eat all document.body.drop eventNicolas Lempereur
In fb051d3420 there was some changes on drag and drop of chatter windows, but this would break the drag and drop of summernote because it wait for document.drop event for hiding the drop zone. opw-2259522 closes #51448 closes odoo/odoo#51478 X-original-commit: 4aaf5b1f562f4cd30e05b020741eb936f6e20a20 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-12-09[REV] mail: prevent message loss during connection issueAlexandre Kühn
This reverts commit e5479fcfdb76bdbf9301fb140d873483bafdb9e4. This commit prevented an issue of losing messages on post in case of connectivity loss. The implementation consists of keeping the content in the composer until the server acknowledges handling the message. However, this solution introduces significant issues. For instance, sending messages in quick succession will likely loose or duplicate some content, based on how fast/slow the RPC `message_post` is resolved. Plus, there was an issue on mobile because the input focus was lost during the RPC. As a consequence, the virtual keyboard flickered. The intent was to fix a rare issue, and since the problems of this solution clearly outweigh the gain, we decided to revert. closes odoo/odoo#41544 X-original-commit: 36b2e99e08bfc6d92a821d0346e783695580abf9 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-09-19[IMP] *: remove image_64 and clean viewsSébastien Theys
There are too many image sizes. Since they are stored resized this takes time to generate when saving a new image, it's more rows on the attachment table, more files on the disk, ... 64px is close enough to 128px that it can be removed without a big impact on download size. It will even reduce download and number of requests when both images are displayed because now only one has to be downloaded and then benefit from cache. The difference between the two is typically around 1.5kB which is negligible these days, especially when the request overhead is around 0.5kB already, not even taking into account other factors such as latency. If a 64px image must absolutely be returned, it is still possible to pass the size parameters to the image route. But the current guideline is to handle resizing in the views when necessary. Views ===== - remove width and height attributes when existing CSS rules are overriding them (eg. `.oe_kanban_avatar` in the right context) - add CSS rules instead of width and height attributes when possible - use `object-fit: cover;` where width and height are forced to avoid distortion of non-square images - for products, use `object-fit: contain;` instead, keep ratio but without crop - add new CSS rules where the expected size was max 64px*64px before due to the image size itself - remove `img-fluid` where using size classes to avoid conflicting rules task-2060865 closes odoo/odoo#36147 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2019-08-02[IMP] *: rename image fieldsSébastien Theys
image_original => image_1920 (now resized to 1920) image_big => image_1024 image_large => image_256 image_medium => image_128 image_small => image_64 image replaced by image_1920 (when writing) or by image_1024 (when displaying what was previously the big size) + add new intermediate format: image_512 PR: #34925
2019-07-12[MERGE] Forward port of saas-12.3 to saas-12.4 up to 87fc1554d6a1823Martin Trigaux
closes odoo/odoo#34820 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-12[MERGE] Forwardport of saas-12.2 to saas-12.3 up to 01365a3f625c9e7Martin Trigaux
closes odoo/odoo#34747 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-11[FIX] mail: removes unsupported usage of formData.deleteThanh Dodeur
This commit replaces the usage of `formData.delete()` as it is not supported by Internet Explorer and Safari Mobile. closes odoo/odoo#34787 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-06-14[MERGE] forward port branch saas-12.2 up to 498b4b4350dChristophe Simonis
2019-06-14[MERGE] forward port branch 12.0 up to 4870251f0b0Christophe Simonis
2019-06-17[MERGE] forward port branch saas-12.3 up to 48a9f5a6335Christophe Simonis
2019-06-13[FIX] mail: use correct variableChristophe Simonis
Oversight of previous forward-port.
2019-06-13[MERGE] forward port branch saas-11.3 up to 8a19a6a2a34Christophe Simonis
2019-02-28[MERGE] forward port branch saas-12.1 up to f9d3b5b7dfeChristophe Simonis
2019-02-21[FIX] mail: keep input focus on emoji selectionAlexandre Kühn
Before this commit, when adding an emoji from the emoji menu next to the composer, the focus was not automatically set on the input. The input was correctly focused during the event handler of the clicked emoji, but the browser default behaviour applied right after was focusing out the input. Task-ID 1943770 closes odoo/odoo#31325
2019-03-06[REF] mail: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-02-07[IMP] bus, mail, mail_bot: add im_status serviceXavierDo
This commit is a refactoring of im_status management. This commit also add im_status in two places, near the author in a mail thread and on each suggestion when using mentions. A service to manage im_status will have multiple benefits here: -centralise information, avoid to call the server multiple time for the same im_status -update all im_status at once and keep consistency in display. With this commit, the im_status updates are now done by rpc call. Updates where previously made with the bus but this has some drawback, since the bus will only give the information 50 seconds after the beginning of the request, in the worst case, we van wait 2*50 seconds to get an update. More than that, the im_status where only updates for pinned dm_chat. Dm chat are synchronized cross tabs, making the use of the bus possible for this purpose. Since we will need to display im_status not linked to dm_chat, the list to update will be different from tab to tab making the use of bus difficult for this purpose. Technical notes: -im_search has been moved from bus to mail addons since it concerns mail.channel -Update of an im_status should be reflected everywhere in the page. Since im_status is a rendered template used in multiple widget, we should add the correct logic to all concerened widget. The current solution is simple: use a jquery selector to find every place where im_status is rendered. -we add a new im_status: im_partner. This will indicate that that the partner has no user linked to him, making it possible to avoid to ask for status updates for this partner. -The update will only be done when the tab is focused. (and will be done asap once the tab get focus back)
2019-01-31[MERGE] forward port branch 12.0 up to cb8fefa8999Christophe Simonis
2019-01-30[FIX] mail: click on item from composer's emoji menuAlexandre Kühn
Before this commit, clicking on an item from the emoji menu of a composer was not putting the emoji in the input. Steps to reproduce: - Open discuss app - Select a conversation with a composer - click on emoji menu in the right-side of the composer - click on an emoji in the emoji menu > the emoji has not been put in the input of the composer This problem was caused by a race condition with the event `focusout` on the emoji button and the `click` on an emoji item. `focusout` always happens before `click`, and `click` event following a `focusout` event can only happen when the element is visible. This was not the case, because the emoji container is removed from the `focusout`, so no `click` is triggered on the emoji item. This commit fixes the issue by listening on `mousedown` on the emoji item instead of `click`, which is triggered before `focusout`. closes odoo/odoo#30694
2019-02-04[MERGE] forward port branch saas-12.1 up to 4524ad06a8aChristophe Simonis
2019-01-25[MERGE] forward port branch saas-11.3 up to 387d5cff90bChristophe Simonis
closes odoo/odoo#30566
2018-12-06[IMP] mail: put emoji in composer based on cursor positionAlexandre Kühn
Before this commit, when selecting an emoji from the composer, the emoji was put at the end of the composer content. With this commit, the selected emoji is now put in the composer based on the position of the cursor. It also focuses the input and set the cursor just after the newly inserted emoji. Task-ID 1881001
2018-12-06[IMP] im_livechat, mail: improved "is typing" notificationAlexandre Kühn
With this commit, the UI for "is typing..." notifications has changed. ** before **: In Discuss & chat windows, "is typing..." notification bar at the bottom of the thread, inside the conversation. ** after ** In chat windows, animated '...' next to conversation name. In Discuss, animated '...' next to conversation name in sidebar, and text below the composer. Task-ID 1881001
2018-11-26[IMP] mail: Allowing drag/drop files/images on mail composerDharmang Soni
By this commit user can upload attachments by drag and drop in chatter composer. This feature can be used from discuss UI, chat windows and form view chatter. Before this commit chatter unlinks the attachment if another attachment uploaded with same name. Criteria for removing duplicate attachment is changed with this commit. Now it will remove the attachment based on name and size of attachment. The reason for this change is, when you upload image with same name from different directory with old condition it was not possible to attach more then one image/file of same name. Related to task #32469 Closes #18914
2018-11-16[FIX] mail: easily mention followers and employees in chatterAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/cd34f6de727d5b3858420cff3c9d3c5995c4e75c Resulting of the mail JS refactoring, the list of prefetched suggestions has been changed as follow: - before: list of list of mention suggestions `{Array<Object[]>}` - after: list of mention suggestions `{Object[]}` The change resulted in wrongly thinking that wrapping the list of suggestions in a list was pointless, thus simplifying it as a simple list of mention suggestions. However, because of this change, it has become much harder to mention employees and followers of documents from the chatter: it now always fetches all partner suggestions at all time, whereas before it was suggesting followers, then employees, and finally all partners based on the input of the user. In fact, there was a purpose of using a list of list of prefetched mention suggestions, which is to group suggestions by "priority": followers first, then employees, and all partners as a last resort. This commit re-introduces prefetched mention suggestions as a list of list of partners, so that it re-becomes easier to mention followers and partners of a document from the chatter. Task-ID 1910111
2019-01-21[IMP] mail: chatter channel notificationDemaret Rivarola Johan
Ability to notify the channel but do not add the channel as a follower. Faster than mentioning every member of the channel. Also, clean the rendering of the mention suggestions name to avoid having escaped char in the UI. Task id : 1859802 Closes #25887
2019-01-10[Generic] unaccent searchmgh-odoo
- added unaccent search on POS customer/partner and product - moved unaccent from "mail.utils" to "web.utils" - added more character to make function accurate We might use str.normalize(from ES6) but the problem is str.normalize method can not consider some double characters i.e. accented character when normalized it returns 2 normal characters and normalize method returns single character, so here custom unaccent method is used to normalize the string What we can improve here: We can use str.normalize method and check if string is still have unaccented charaters that we can call our unaccent method but this unaccent method is also working and performing well closes odoo/odoo#27671
2019-04-23[IMP] mail: prevent message loss during connection issueJulien Giannone
Before the changes, when a message was posted (on Discuss or in the chat window), the composer was cleared directly as it didn't wait for the rpc response. If there was latency or a connection loss, the message disappeared from the composer but took time to appear in the content window or didn't appear at all and was lost. Now, the composer waits for the rpc response and then is cleared. Task #1957856 closes odoo/odoo#32422 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2018-11-09[FIX] mail: enable composer after message sentNicolas Lempereur
c5dc0b2f39 disabled send button on composer sent. But this is only needed for chatter composer, other composers directly send the message and are not refreshed asynchronously. So for other composer, the send button worked one time but then was disabled and the only way to sent was ENTER (on basic composer) or CTRL+ENTER (on extended composer). With this fix, disabling the button is done only for chatter composer. Also the behavior of not clearing the message if there was an error is introduced back. Without change in code, added test fails with: "Should keep unsent message in the composer on failure" (result: "") "Send button should be re-enabled on message post failure" (result: true) issue found when checking opw-1904029 closes #28475
2018-11-02[MERGE] forward port branch saas-11.4 up to f6ca72b3ce9Christophe Simonis
2018-08-13[IMP] mail, im_livechat: 'is typing...' indicator on mail channelsAlexandre Kühn
With this commit, most threads show an indicator when a member is typing something. e.g. "Mitchell Stephens is typing..." Supported threads: - DM - (public & private) channels - Livechat (Website & Backend) Unsupported threads: - mailboxes (e.g. 'Inbox') - document thread (= 'Chatter') - support channel (with `im_support` module) Some technical details: - This is a mix between 'start'/'stop' and 'regular notify' strategies. - On typing text in composer: notify 'start typing' to all members of thread. - On clearing text in composer: notify 'stop typing' to all members of thread. - A member can only notify once every 2.5 seconds to the server when he starts or stops typing something (throttled, buffered notify call). - On receiving a message from someone that is typing: determine that he is no longer typing. - On non-empty and unchanged composer text for 5.0 seconds: automatically notifies all members of thread that he is no longer typing anything. (This is like a 'soft / cooperative sender' timeout). - On non-receiving a typing notification of someone after 60 seconds: determine that he is not longer typing something (This is like a 'hard / receiver assumption' timeout). - When some types for more than 50 seconds straight: notify that he is still typing something (again and again every 50 seconds). - When two or more people are typing something (Multi-User channels), it displays at most 2 typing users (ordering rule: longer typers first): "Mitchell Stephens, Marc Brown and more are typing..." - Timing summary: - Usually 2.5 seconds uncertainty. - Up to 5.0 seconds uncertainty on typer inactivity. - Up to 60 seconds uncertainty on typer page reload / browser tab closed / etc. Future Improvements: - Detect page reload or browser tab close with loose of longpolling connection Task-ID 28188
2018-08-10[ADD] mail_bot, im_livechat_mail_bot: add Odoobot, your new best friendXavierDo
Purpose of this commit is to improve onboarding with a wow effect and a bot to test the Discuss app. Otherwise new users have nobody to talk to. Retention will be improved by both increasing interactions and onboarding of Discuss features. This commit adds a simple bot in discuss. It answers some questions, helps users getting their hand on discuss and eases the onboarding. In this version, the flow is quite simple, and only im_livechat adds some logic in order to show canned response. The logic is contained in new modules: mail_bot and im_livechat_mail_bot in order to keep everything well separated. It also allows users to remove the mailbot if they do not want to keep this functionality. Odoobot will only answer if he is in the onboarding conversation (alone with a user in a channel of type chat) or if a user pings odoobot. Odoobot logic applies to both standard chatter / channel messages and also transient messages (like help commands). Specifications * 2 minutes after first sign in, users will receive a direct chat from Odoobot; * make Odoobot an archived partner; * scenario * Odoobot: "Hello, I'm here to help you discover chat features. Try answering me with an emoji :)"; * User: Send emoji * Odoobot: "Great! :) Did you notice that you can also send attachments, like a picture of your cute dog? Try it!" * Odoobot: "Not a cute dog, but you get it :) To access special features, start your sentence with "/" (I.E. /help)"" * User: /help * Auto message then Odoobot: "Wow you're a natural! As a channel usually contain a lot of users, you can grab the attention with a ping. Try to ping me with @Odoobot!" * User: @Odoobot lorem ipsum * if Livechat installed * add 2 demo canned response so it does not look weird (like "Hello, how may I help you?" and "Have a nice day!") * Odoobot: "Perfect! <br> Try to type ":" to use canned responses." * User tries canned * Odoobot: "Good, you can customize your canned responses in the live chat application. <br><br> + réponse suivante" * Odoobot: "There's 3 different ways in Odoo to interact with your colleagues: via this chat window, [img of chat window] via the Discuss application [img of Discuss app + icon on it] or via the chatter [img of the chatter]. Aaaaand that's it! Enjoy discovering Odoo! :)" * random answers to ping/bad answer * "Mmmmh I'm not sure what you mean.. Can you try again?" * "I'm afraid I don't understand. Sorry!" * when someone pings @OdooBot with no reason: Odoobot: Yaaaay that's me! [party emoji] * fun stuff to add for some answer * User: i love you / love * Odoobot: Aaaaaw that's really cute but, you know, bots don't work that way. You're too human for me! Let's keep it professional <3 * User: Fuck * Odoobot: That's not a really nice thing to say, you know? I'm a bot but I have feelings, ok?! </3 This commit is linked to task ID 1838588 and PR #25075.
2018-07-16[MERGE] forward port branch saas-11.4 up to 8285630ad26Christophe Simonis
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.