Commit Graph
100 Commits
Author SHA1 Message Date
Aaron Bohy 52f55ed493 [FIX] Packaging: deb: include missing font files in builds 2016-02-08 14:44:08 +01:00
Aaron Bohy 4010c09e68 [FIX] mail: automatically open DM and livechat on new message
When a new message arrives in a DM or a livechat, the channel is automatically
open in a chat window if we aren't currently in Discuss.

Don't apply this behavior in mobile and we probably don't want to see a full
screen chat window everytime someone sends us a message.
2016-02-08 08:47:10 +01:00
Aaron Bohy ad02d23bf3 [FIX] mail: hide chat windows in discuss
Thus also remove the 'Detach' button in Discuss's control panel as we can now
directly detach channels with the messaging menu.

Also removed unused handler on 'messages_read' since rev. 30c26d7.
2016-02-08 08:29:53 +01:00
Aaron Bohy 5ba53f3b11 [FIX] mail: display user status in chat windows 2016-02-08 08:29:53 +01:00
Aaron Bohy 79a8eeb17d [FIX] mail: unread counter on new message in non pinned DM
When a new message arrived in a non pinned DM, the unread counter was
incremented twice ; once because the channel info (along with its unread
counter) was fetched from the server as the channel wasn't in the JS cache yet,
and once when adding the message in the JS.

With this rev., we only increment the unread counter when a new message arrives
if its channel is already in the JS cache.
2016-02-08 08:29:53 +01:00
Aaron Bohy bc2d86e00f [FIX] mail: correctly compute unread messages
Two problems occured:
 - when the user hadn't seen any messages of a channel, the seen_message_id
   was null and doing seen_message_id < msg.id to retrieve all messages
   received after the last one seen didn't return any message (null < x is
   always false)

 - messages sent by visitor on the livechat doesn't have any author_id, so,
   again, doing msg.author_id != partner_id is always false, and as a
   consequence, server-side, the messages sent by visitors were always
   considered as read
2016-02-08 08:29:52 +01:00
Aaron Bohy 2b43624666 [FIX] mail: don't display subject of messages written in a chatter
This was working fine until rev. 4bab99bd which accidentaly changes the
condition.
2016-02-08 08:29:52 +01:00
Aaron Bohy 377bcd202f [FIX] mail: overlapping calls to get_channel_preview
Problem occured when the first call to get_channel_preview was directly
followed by others, before the channels_preview_def was resolved. In that case,
the other calls all returned an empty array, as only the channels_preview
array was only filled with the RPC result for the first call to
get_channel_preview (the one which initiated the RPC).
2016-02-08 08:29:52 +01:00
Aaron Bohy 021f9aeec7 [FIX] mail: systray items must wait for chat_manager
Those items might have been rendered and inserted into the DOM before the chat
manager initialization was completed. As those items rely on chat manager's
data, they should wait for it before executing their action (inbox redirection
and channels preview display).
2016-02-08 08:29:52 +01:00
Aaron Bohy 017c4b0a4d [FIX] mail: keep expanded messages expanded after refresh
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-02 08:49:54 +01:00
Aaron Bohy 0de35ffa7f [FIX] mail,web: don't block chat windows when blocking ui
One will still be able to chat in chat windows during long RPCs...
2016-02-01 11:31:36 +01:00
Aaron Bohy db4cb5b74e [FIX] mail: set tabindex of composer's elements
Also focus the subject's input by default in extended composer.
2016-02-01 11:31:09 +01:00
Aaron Bohy 4bab99bdaf [FIX] mail: don't notify 'join/left' messages
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-02-01 11:31:09 +01:00
Aaron Bohy ef77e6821a [FIX] mail: systray: move Inbox counter to its own item
Clicking on that item redirects to the Inbox in Discuss.

The messaging menu's counter is now the number of conversations (public or
private channels, dm and livechat) in which there is at least one unread
message. Moreover, it is emphasized when one of those conversations is a chat.

Also make mass-mailing channels available through the messaging menu (for
consistency as its counter takes those channels into account) and allow to open
them in chat windows without input.
2016-02-01 11:31:09 +01:00
Aaron Bohy 5e79439dee [FIX] mail: chatter: keep mentions
Message's body is kept when switching from 'New message' to 'Log a note' since
rev. f35b48aa. However, mentionned partners or channels were lost. This rev.
makes sure to preserve both message's body and mentions when switching between
composers.
2016-01-29 13:21:02 +01:00
Aaron Bohy c04103f4da [FIX] mail: various UI fixes/improvements
- 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-29 13:21:02 +01:00
Aaron Bohy 1c4d888e80 [FIX] crm: translation of action's name 'Your pipeline'
... displayed in the breadcrumb. Term wasn't translated due to missing context.

opw-666577
2016-01-26 11:13:48 +01:00
Aaron Bohy 16a3a4b7fe [FIX] im_livechat,mail: various livechat fixes
- prevent concurrent opening of the chat window
- take into account the placeholder value of the livechat session record
- don't send welcome message if empty
2016-01-25 15:47:25 +01:00
Aaron Bohy fc42880da2 [FIX] mail: restrict mention suggestions to channel members
Problem is that when someone is mentionned in a channel he doesn't belong to
(public, private or DM whatever), the message only appears in its Inbox and
he can't know where it comes from nor reply. This is thus very confusing.

With this rev., in Discuss, one can only mention members of the channels.
In the chatter, anyone can be mentionned like before, as when the message
arrives in the Inbox, there is a link to the associated document.
2016-01-25 15:46:56 +01:00
Aaron Bohy da2cbae8f8 [FIX] mail: synchronize last_message_seen_id between tabs
When using multi tabs or browsers, the 'New messages' separator in threads was
sometimes wrongly displayed (displayed over messages already seen in another
tab or browser).
2016-01-25 15:46:56 +01:00
Aaron Bohy 6cc8d32d60 [FIX] mail: automatically consider messages sent as read
Problem was that since rev. 617968c61, we consider sent messages as read client
side. This has been done to avoid to indicate that a channel has unread
messages e.g. when this channel is a follower of a chatter in which we wrote
a message.

This change has as consequence that we don't perform the 'channel_seen' RPC for
messages sent. At each refresh, the server sends information about pinned
channels, especially the unread counter, which was thus sometimes incorrect.

This rev. simply doesn't take messages we wrote into account when computing
the message_unread_counter field.

Also correctly display the 'New messages' separator in threads, by automatically
skipping messages we wrote (i.e. it is now displayed above the first message m
with m.id > last_message_seen_id and such that we aren't the author of m).
2016-01-25 15:46:55 +01:00
Aaron Bohy f35b48aa90 [FIX] mail: don't erase textarea's content on 'New message' click
Also mute the 'New message' button when the composer is open as the only
primary action should be to send the message.
2016-01-25 15:46:55 +01:00
Aaron Bohy 302885b860 [FIX] mail: various ui fixes
- limit partner search to 10 in new message's chat window to prevent overflow
- prevent negative needaction counters (may occur in multi-tab, with
  needactions received during an inactivity period)
- remove <pre> tag when computing messages' preview for the messaging dropdown
  as they break the layout and add 'overflow: hidden' on o_mail_channel_preview
  just in case
- rename 'New message' button in Inbox into 'Send mail' as it was confusing,
  and adapt .pot file accordingly
- focus on composer when opening a chat window
- break lines in threads to avoid horizontal scrollbar (credit goes to qsm)
- correctly apply rules on <p> in threads

opw-667235
2016-01-25 15:46:55 +01:00
Aaron Bohy 5b338b665e [FIX] im_livechat: external loader: server_url undefined
Since rev. 100d604, the web.session module is always loaded in external pages,
even if no operator is available. Thus, server_url should always be computed.
2016-01-19 15:20:38 +01:00
Aaron Bohy de9c2135a6 [FIX] im_livechat,mail: external lib: missing dependency
@navbar-height was used in chat_window.less since rev. 8397abd but wasn't
defined in the external_lib bundle (light bundle to embed im_livechat in
external pages).

This rev. also fixes some glitches of the chat window due to missing
font-awesome, and global rule 'box-sizing: border-box' on all elements.
2016-01-19 15:20:37 +01:00
Aaron Bohy fc8a4b5ede [FIX] web: view manager: overlapping switches between views
The problem occured when the user quickly clicked several times on the view
switcher or the breadcrumbs. The function switch_mode() of the view manager
was called once per click. This function's role is to prepare the requested
view, and once it is ready, to remove the former one from the DOM and insert
the new one instead. It is thus asynchronous as it waits for the
fields_view_get and search_read RPCs' response.

Unfortunately, when those calls to switch_mode() overlapped, the former view
reference was lost and it was thus never removed, producing a weird situation
where two views were displayed one above the other. This may happen when a
view takes a while to load, or simply when the user double-clicks on the
breadcrumbs or view switcher.

This rev. makes sure that calls to switch_mode() can never overlap by refusing
any other call when there is still one processing.
We also added a protection against breadcrumbs and view switcher double-clicks.

opw 658924
2016-01-18 14:01:21 +01:00
Aaron Bohy 206cc91a63 [FIX] web: view_manager: restore internal state on switch view failure
When an error occured when switching from a view to another (e.g. switching
to a form view for an id that doesn't exist, by editing the url), active_view
and view_stack were updated even though the switch failed. The view manager
thus lost the reference to the real current active view, which couldn't be
detached anymore. This resulted in two views being displayed at the same time
if the user kept navigating through this view manager.

This is a backport of odoo/enterprise@0b1aafa6b and odoo/enterprise@8e691be.
2016-01-18 14:01:21 +01:00
Aaron Bohy e5e31a0519 [FIX] mail: heart emoji not correctly replaced
Fixes #10445
2016-01-15 13:18:13 +01:00
Aaron Bohy 7e3c6bd366 [FIX] mail: composer: emojis not displayed in basic composer
Two composers are appended to the client action: a basic composer and an
extended one used in mass mailing channels. Emojis are rendered in a container,
and when the user clicks on the emojis button, this container is shown.

The problem came from the fact that this container has the same classname in
both composers, so for both composers, the emojis were rendered in the same
container, producing an empty container for one of the two composers
(in this case, the basic one).
2016-01-15 13:18:13 +01:00
Aaron Bohy 617968c61b [FIX] mail: don't mark as unread messages we wrote
in the client action (bold channel name in the sidebar)
in chat windows (number of unread messages written in header)
2016-01-15 13:18:13 +01:00
Aaron Bohy c304e2ce95 [FIX] im_livechat: chat_window: scrollBottom() and feedback
The function scrollBottom has been removed at rev. 30c26d7 as the scroll logic
has been moved to the thread, to make it common for the client action and chat
windows.

Moreover, the o_chat_content div has been removed from the chat window layout
at the same commit, we thus now directly replace the thread's $el by the
feedback and fix less rules

Also adapt the behavior of the livechat's chat window as done for the backend
at 30c26d7:
  - scroll to bottom on message sent
  - increment unread messages counter if the chat window is folded or if the
    thread is not scrolled to bottom
  - reset the unread counter on scroll to bottom)
2016-01-14 14:49:58 +01:00
Aaron Bohy 8397abd871 [IMP] mail: make chat windows somehow usable in mobile 2016-01-14 11:22:26 +01:00
Aaron Bohy 54396cfa41 [FIX] im_livechat,mail: don't automatically detach chat channels
This reverts commit a8239cd as the navbar dropdown recently introduced now
offers a quick access to channels without coming back in the Discuss App.

Moreover, this commit emphasizes the notifications navbar icon when there are
unread messages (or at least, it mutes it when there isn't).
2016-01-14 11:22:26 +01:00
Aaron Bohy 916d90af35 [IMP] mail: open dm shortcut from in navbar dropdown
Allows to directly open a dm channel from a chat window, without coming back
to Discuss.
2016-01-14 11:22:26 +01:00
Aaron Bohy b3868a613c [IMP] mail: needaction/unread messages counters
Some UI changes:
  - Unread messages in chat are now displayed as needactions in the Discuss's
sidebar (badge with counter of unread messages, instead of simply bolding the
channel name).
  - The counter displayed in the navbar is now the sum of needactions and total
of unread messages in chat.
  - The counter displayed next to Inbox is still the needaction counter.

For consistency between tabs/browsers/devices, the channel_seen info is now
broadcasted, meaning that every tab/browser/device will be noticed.

Also now correctly increment the unread counter of a channel if the received
message is a needaction.
2016-01-14 11:22:25 +01:00
Aaron Bohy d93231afe2 [IMP] mail: navbar: messaging menu
The navbar notification is now a dropdown containing a preview of all pinned
channels (except Inbox and Starred), channels with unread messages being on the
top.

It allows to quickly detach a channel without going back to Discuss.

The channels preview fetching is performed only once, and it is done in
background without blocking the whole UI (using shadow option or session.rpc()).

Also fixes a synchronization problem between server and client about the folded
state of channels (the info wasn't stored client side, so it produced weird
situations, e.g. unfolding a channel didn't actually unfold it).
2016-01-14 11:22:25 +01:00
Aaron Bohy 0301735354 [IMP] mail: move 'New message' button from navbar to Inbox 2016-01-14 11:22:25 +01:00
Aaron Bohy 18fccd9d6c [IMP] mail: put chat windows in a dropdown in case of overflow
Former algorithm to display chat windows was pretty basic: each window was
positionned 5 pixels to the left of the previous one, starting from the bottom
right corner of the screen. Thus, when there were too many chat windows to fit
in the screen, they overflowed to the left.

This rev. handles this case by hidding overflowing chat windows and making them
available in a dropdown positionned 5 pixels to the left of the last visible
chat window.
2016-01-14 11:22:25 +01:00
Aaron Bohy 37238d343a [FIX] mail: notifications: strip html tags
but keep jumps to line
2016-01-14 11:22:25 +01:00
Aaron Bohy 029c0d5567 [FIX] web: utils: backport of swap() for enterprise compatibility 2016-01-14 11:22:25 +01:00
Aaron Bohy dfdd38e3b2 [FIX] mail: Discuss: don't suggest to join private channels
Problem was that administrators have access to every channels, even private
channels they are not registered to, because when trying to join an existing
channel, the autocomplete proposed every channels accessible for the user, but
didn't filter private ones.

This rev. makes sure to only suggest non-private channels.

Also prevent '|' domain injection to disable filters (odoo/odoo@44e65e72d3)
by using expression.py to build domain.
2016-01-08 14:32:51 +01:00
Aaron Bohy 0fbc128033 [FIX] mail: followers: subtypes: correctly notify channels
Except for messages, activities on a document like internal notes posted
trigger notifications to partners and channels following the corresponding
activity's subtype.

Rev. 69ed801 rightly re-introduces a filter on followers to prevent notifying
more partners than necessary. Unfortunately, this filter doesn't take into
account channels, which are thus automatically removed from followers to
notify, whatever the subtypes they follow, e.g. internal notes on a document
don't appear in channels following the 'Note' subtype of this document.

This commit makes sure that channels always pass through that filter, but warns
users that public channels should probably not following internal subtypes.

Also makes the edit subtypes dialog html valid (li's must be inside, e.g., ul).
2016-01-08 14:32:51 +01:00
Aaron Bohy c4240b547f [FIX] mail: chatter composer: full composer button
The chatter composer extends the basic composer to, among other things, add
a button to open the full composer next to the button to add an attachment.

In a recent commit, the basic composer template has been slightly changed and
the buttons have been extracted in a sub-template, which seems to break the
template inheritance (the xpath refers to one of those buttons).

This solution simply removes the sub-template and duplicates the code.
2015-12-29 15:59:54 +01:00
Aaron Bohy 3f370651c7 [FIX] im_livechat,mail: don't translate html data-type argument
as it is only there for a technical purpose (used in JS to bind event handlers)
2015-12-29 15:59:54 +01:00
Aaron Bohy 97a61f9e76 [FIX] bus,im_livechat: away status after 30 minutes of inactivity
Also, away users aren't considered as available for the livechat anymore.
2015-12-29 09:41:18 +01:00
Aaron Bohy 1d371e94f6 [FIX] im_livechat: channel info: available key
should be the length of the recordset of connected users, not the recordset
itself, which is always evaluated as True (thus, the im_livechat script was
always embedded in the html pages).
2015-12-29 09:41:18 +01:00
Aaron Bohy 21e2e85790 [FIX] bus,im_livechat: correctly detect livechat availability 2015-12-28 12:48:46 +01:00
Aaron Bohy 30003dbce3 [FIX] im_livechat,mail: various ui fixes/improvements
im_livechat:
  - feedback message wording
  - livechat_channel form view typo

mail:
  - channel form view: email_send field label wording and layout
  - notifications preview extended
  - client action mass mailing composer fine tuning
  - client action mass mailing channels tooltip
  - client action idle bullet color
2015-12-28 10:19:22 +01:00
Aaron Bohy f6c20fa4b3 [FIX] bus,mail: user presence
Commit 5d1b323. re-enabled the user presence updates and notifications.
Unfortunately, it showed poor performance due to the high frequency of bus
notifications triggered on our instance (~600k users).

In this rev., we don't trigger notifications on presence changes anymore, but
we rather send the presence of users we have a DM open with, at the end of each
poll period. For performance reasons, we ensure not to do that more than once
every 30 seconds.

We also refined the detection of the 'away' status client side. 'Last presence'
timestamps are stored in the local storage, and the current inactivity period
is sent at each poll. Those presence timestamps now rely on browser activity
detection (click, keypress... events) rather than on the focus on Odoo tabs.

Finally, we removed the no more necessary cron introduced in 5d1b323.
2015-12-24 12:59:46 +01:00
Aaron Bohy d8605b7993 [FIX] im_livechat: matching rule in cache
The problem was that the matching rule was evaluated before sending the html
page, and the script was inserted in the page according to the matching rule
(it wasn't inserted if the rule was 'hide_button'). However, the matching rule
wasn't re-evaluated if the page was already in the cache. The page content thus
might depend on a matching rule computed for someone else in that case.

Rather than inserting the script according to the matching rule, we insert it
only if there is an operator available. We then ask for the matching rule in
the livechat widget, by RPC, and we reject its willStart deferred if the rule
says so. We also re-check for operator availability in the same RPC.
2015-12-24 12:59:46 +01:00
Aaron Bohy 26b00a844a [FIX] mail: client action: traceback on composer focus
wrong copy-paste introduced in c4fb2b50e0.
2015-12-24 09:05:28 +01:00
Aaron Bohy 9cbab8a04b [FIX] bus: bus_check_disconnect_cron xml_id
Copy-paste error...
2015-12-16 16:31:08 +01:00
Aaron Bohy 5d1b3232fc [FIX] bus,mail: user presence
Before this rev., no notification was sent on the bus when the user presence
changed. Thus, the bullets displayed in Discuss were never updated and stayed
as they were on the initialilization of the chat_manager (on webclient launch).

This rev. makes the bus.presence notifications work, and handles them client
side.

Moreover, the disconnections detection is now performed at each poll (with a
maximum of 1 per minute), instead of randomly (1/100 chance) at each poll, as
it scales better than the former solution. We also added a cron that performs
this check every 5 minutes. It is needed to detect that the last connected user
just disconnected (useful for visitors in the website, trying to talk with a
livechat operator).

Also, the 'away' status is now handled client side, as it makes more sense
that way (being away at each poll, e.g. every 50seconds, during 10 minutes
doesn't mean that we didn't come back between two polls).

Finaly, in bus.js, CrossTabBus, we moved the code writing in/reading the local
storage after the tab registration as this code depends on the fact that the
tab is the master tab or not (and this is known only once the tab is
registered).

This rev. was necessary in stable because the livechat uses the user status to
detect if there is an operator available, and this was often inaccurate.
Moreover, it improves the user experience of the chat in the backend.
2015-12-16 15:48:43 +01:00
Aaron Bohy 89ba0a811b [FIX] mail: traceback on new msg in unpinned closed livechat
The traceback ocurred when the operator closed a livechat channel chat window,
and then unpinned it from the sidebar in Discuss. Then, if the visitor sent
him a message, the channel was automatically re-pinned to the operator, who
received two notifications: the first one being the new channel info and the
second one the message itself.

The channel fold_state being 'closed', the window manager was trying to close
it again, which produces the traceback as the channel didn't exist in the JS
cache anymore (it was re-added to the cache when processing the message
notification, so just after).

Anyway, closing this channel was useless as, even if it was in the cache, it
would already been closed. So this rev. simply checks whether or not the
channel is in the cache before trying to close it.
2015-12-16 15:48:43 +01:00
Aaron Bohy c58c8f4bd2 [FIX] im_livechat: use correct url to find rules that apply
The problem was that, when calling 'match_rules()' from the loader template,
we compared the wrong url with the url regexp defined in rules. Indeed, we used
the url of the page we were leaving, not the one we were going to.

We thus need to know if we are coming from the controller, or from the loader
template directly as the way to get the correct url differs.

Courtesy of JEM
2015-12-16 15:48:43 +01:00
Aaron Bohy 0c92788d88 [FIX] im_livechat: various fixes
- use channel configuration for the auto_popup
- clear auto_popup timeout when chat open to prevent opening the chat twice
  if the user opens it himself before the end of the timeout
- don't send message when no feedback given
2015-12-16 15:48:43 +01:00
Aaron Bohy 2b99a36921 [FIX] mail: sent messages are plaintext
The problem was that users couldn't write characters like <, > in their
messages because the messages are html (e.g. '3 < 5' resulted in '3' because
this wasn't html valid so the second part was trimmed).

Because of mentions, we can't force messages to be plaintext (mentions are
processed and replaced by html links before the message is stored in DB).

The solution is to escape them just before processing the mentions. In the case
of chat windows, we must be careful because chat windows are also used for the
livechat, for which messages are plaintext. So the escaping should be done for
chat windows in the backend, but not in the livechat.
2015-12-16 15:48:42 +01:00
Aaron Bohy f5e4fbb20c [FIX] mail: correctly redirect to channels
Clicking on a channel link should open that channel in Discuss, not the channel
form view.
2015-12-16 15:48:42 +01:00
Aaron Bohy 17896a92da [FIX] mail: various ui improvements/fixes
* chat windows:
  - input was kicked out of the window on chrome 43
  - don't animate if folded by default (e.g. after a refresh)
  - width and height 100% like in the frontend
  - z-index to make sure that they are over bootstrap active btn,
    but below notifications, and modals

* chatter:
  - internal note: send button renammed to 'Log'
  - send button is the first button again
  - remove annoying form view widget's tooltip

* client action: focus on composer on channel change
2015-12-15 10:01:21 +01:00
Aaron Bohy 1029571c35 [FIX] im_livechat: various fixes
- Don't display livechat button if no operator available
- Livechat windows persistence through website pages
- Auto popup feature re-introduced (inadvertently removed at rev. f23f57cc)
- Operators that are 'away' are available, as 'away' means that the focus isn't
  on the Odoo tab for at least 10 minutes, but the user is still connected.
- Avoid duplicated messages when the visitor is a connected user
- Unfold livechat window on first 'close' click as the event is intercepted to
  ask the user feedback before actually closing the window
2015-12-15 10:01:20 +01:00
Aaron Bohy 9585e630df [FIX] board: open kanban card from dashboard
The Kanban view has been refactored recently, and the communication mechanism
between the view and its cards changed. The cards now communicate with the
view by triggering_up custom events.

The code in dashboard overrides the function open_record of the Kanban view to
allowing opening a record by clicking on a card directly from the dashboard.
Unfortunately, this code hasn't been adapted after the Kanban refactoring.
2015-12-11 17:48:11 +01:00
Aaron Bohy e47d4c61d2 [FIX] mail: client action layout: scrollbar in the sidebar
There was a weird bug on chrome when there was a scrollbar in the sidebar, as
the right part of the client action overlapped that scrollbar. The problem was
seemingly linked to the use of flex, which is removed by this rev.

Courtesy of QSM
2015-12-11 17:48:11 +01:00
Aaron Bohy ad14862907 [FIX] mail: various ui improvements/fixes
- 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-09 11:20:25 +01:00
Aaron Bohy 6cf8ebab3d [FIX] mail: escape user and channel names to prevent xss
However, users shouldn't be allowed to have xss in their name, imo.
2015-12-09 11:16:24 +01:00
Aaron Bohy 085f6e0e68 [FIX] mail: multiple clicks on navbar needactions icon
Clicking on this icon redirects to the client action (for now at least). By
quickly clicking several times on it, we try to restore the scroll position of
a channel that not yet exists. This rev. prevents from getting a traceback in
that case.
2015-12-09 11:16:24 +01:00
Aaron Bohy 51461d591d [FIX] bus,mail: edit title and play sound on new message
Concerns only chat messages.
2015-12-08 16:30:37 +01:00
Aaron Bohy 8b216f1b9f [FIX] mail: thread: oe_mail_expand: execute handler once
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-08 10:01:18 +01:00
Aaron Bohy 3f1ef1f11d [FIX] im_livechat: prevent starting multiple poll
bus.poll() should be a private function, as it initializes a new longpolling.
Only bus.start_polling() should be called as it prevents running multiple
polls concurrently.

On the website, bus.poll() was called each time the user clicked on the
livechat button, blocking the whole UI if the user clicked 6 times in a row on
that button, as only 6 RPCs can be done concurrently.

A consequence of this fix is that the poll isn't restarted if the user opens
a new livechat session just after closing one, so the messages sent through
that session are delayed (~50 seconds). To circumvent this situation, we simply
don't restore the livechat button after closing a livechat session (the button
re-appears anyway at the next click, or after a refresh).
2015-12-07 16:32:28 +01:00
Aaron Bohy 169f819ab1 [FIX] mail: read more: prevent default
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 16:32:27 +01:00
Aaron Bohy 88c5a90677 [FIX] mail: allow users to unsubscribe from private channels
Before this rev., only the root user was allowed to do so, because some
operations were performed on the channel just after the user had been
unsubscribed (to trigger the unsubscribe notification on the bus, and to post
the 'left channel' message).
2015-12-07 16:32:27 +01:00
Aaron Bohy 77acb57e55 [FIX] mail: correctly increment channels' unread counter
When several channels followed the same document, and a message was sent in
this document, the unread counter of each channel was incremented by the number
of following channels (because as many notifications were sent on the bus, and
for each notification, we incremented the unread_counter of the channels in
which the corresponding message is posted).

This rev. makes sure to only increment the unread counter once, if the message
is not yet in the JS cache, i.e. if this is the first notification we receive
for this message.
2015-12-07 16:32:27 +01:00
Aaron Bohy f09ca9c777 [FIX] mail: followers: display followers and fetch subtypes
This commit fixes two bugs on followers:
- when landing on a form view, the followers' dropdown is now correctly filled
- when editing the subtypes of a follower while not being ourself a follower,
  the subtypes are now correctly displayed in the modal.
2015-12-03 16:13:40 +01:00
Aaron Bohy 5fdfd38b7e [FIX] im_livechat: don't remove empty sessions created recently
The 'cron_remove_empty_session' is performed every day and removes livechat
channels that contain no message.

The problem was that the cron might have been executed between the moment a
public user clicked on the livechat button, creating a new empty channel, and
the moment this user sent the first message through that channel. If that
happenned, the message was sent in an unexisting channel, and obviously never
received by the operator.

This fix makes sure that removed empty channels haven't been created or
modified within the last hour.
2015-12-03 11:21:47 +01:00
Aaron Bohy 8017a9569c [FIX] mail: ondelete cascade on mail_channel_partner relation
The problem occurred when the im_livechat cron 'cron_remove_empty_session'
removed empty livechat channels (a public user clicked on the livechat button,
creating a new channel, but never sent any message in it). The empty channel
was deleted by the cron, but the two records in the mail_channel_partner
relation table (linking the channel with the public user and the livechat
operator) wasn't removed, and the value of their field 'channel_id' was None.

When this happenned, it broke the SQL query of 'channel_search_to_join()', the
RPC call performed when clicking on '+' new to public channels in the client
action, resulting in no result displayed in the dropdown.

With this fix, records in the relation table are automatically deleted when
their corresponding channel or partner is deleted.
2015-12-03 11:21:47 +01:00
Aaron Bohy 7bea8412c5 [FIX] mail: href of mention links in sent messages
Those messages can be read from the client action interface, where the onclick
redirection is properly handled, but they are also sent by email. The
generated links should thus have a correct href.
2015-12-03 11:21:47 +01:00
Aaron Bohy e7cb3dcaa8 [FIX] mail: don't redirect to user's own partner form view
Clicking on the author of a message opens a DM with the corresponding user if
there is one, and opens the corresponding partner's form view otherwise.

When the author is the current user, obviously we don't want to open a DM with
ourself, but we probably don't want to open our partner form view either, which
was exactly the behavior before this rev.
2015-12-03 11:21:47 +01:00
Aaron Bohy 33ac65c805 [FIX] mail: redirection handling in chat windows
- clicking on a channel mention (or a user) from a chat window opens a new chat
  window for that channel
- clicking on any other link in a chat window correctly opens the corresponding
  document

2 minor changes were required:
- use do_show() instead of on_reverse_breadcrumb() to update control panel and
  url in client action, as other actions can be stacked over the client action,
  e.g. by clicking on a document link in a chat window. In that case, the
  on_reverse_breadcrumb callback wouldn't be set, and thus the control panel and
  url wouldn't be updated by coming back to client action using the breadcrumbs.
- channel_join() now checks whether or not the channel has already been joined
  (i.e. if it is in the JS cache) before performing the RPC. This check was
  performed by each caller, so this simplifies the code.
2015-12-03 11:21:47 +01:00
Aaron Bohy db8203c27a [FIX] base,hr,mail: prefetch mention suggestions
The purpose of this commit is to improve the overall performance of the mention
mechanism of the client action and chatter composer, by pre-fetching some data.

First, the employees are fetched at chat initialization (basically, at web
client initialization), if hr is installed.

Second, when focusing on the composer of a channel, the members of this channel
are fetched. In the case of a chatter, the members are already known as they
are the followers of the document.

When the user types a mention, we first display suggestions from the pre-fetched
partners, and we only perform an RPC when there are no more result matching the
search string. This RPC searches among user, and then partners if there aren't
enough matches.

A few side changes occurred:
  - auto_join set to True on user_ids field of res.partner to boost the query
    that searches partners that are users
  - the '/mail/read_followers' route now returns follower's email as well, as
    we need it for the mention;
  - a partner can now be mentionned several times in the same message;
  - mentionned partner previsualization has been removed, mainly because of
    the previous point, but also because it simplifies the code;
2015-11-27 11:47:34 +01:00
Aaron Bohy 0413cc9641 [FIX] web: display pager in SelectCreateDialog 2015-11-25 16:23:44 +01:00
Aaron Bohy 5616027190 [FIX] im_livechat,mail: unread counter in chat windows
Synchronize the unread counter between chat windows, client action and the
actual value stored in DB. This adds robustness to the counter displayed in
chat window, and allows to synchronize the client action with the chat windows
when marking messages as read.
2015-11-23 16:29:08 +01:00
Aaron Bohy faf5cea948 [FIX] mail: various UI improvements
- emoji are no more clickable in threads (they are only in the popover)
- correctly update channel needaction counter
- don't display 'New message' notification when the channel in detached
- display in the ui channels that send emails and other channels
- prevent notifications in mass mailing channels
- increase bottom padding in client action thread
2015-11-23 16:29:08 +01:00
Aaron Bohy a8239cd2ae [FIX] im_livechat,mail: detach chat on the receiver side
This commit concerns DM and livechat channels. Those channels are now
automatically detached on the receiver side. This allows users to directly
reply to DM's or livechats without coming back to the client action.

Note that they aren't detached if the user previously manually closed the
channel's chat window.
2015-11-20 15:48:03 +01:00
Aaron Bohy c2dfea5cc9 [FIX] mail: correctly load livechat channels
The livechat channels returned by the chat_manager's initial RPC were ignored.
Livechat channels thus weren't persistent in the client action.

This rev. cleans the returned object 'channel_slots' so that it only contains
arrays of channels. The additional mapping and partners array were useless as
the information they contained was directly stored in the DM channels.

We now simply iterate on each array returned and add each channel it contains,
including livechat channels.
2015-11-20 15:48:03 +01:00
Aaron Bohy 1dfd1bd7a3 [FIX] mail: correctly pin DM's on message post
DM channels are supposed to be pinned on each partner's side when a message
is post in the DM. This didn't work because we checked if the channel is a DM
by comparing its type to 'direct_message', which is not a valid channel type.

Also stop marking the DM as pinned in channel_join_and_get_info() as it is now
useless.
2015-11-20 15:48:02 +01:00
Aaron Bohy c470e0bf85 [FIX] mail: only open DM on first message received
instead of directly, when the other user opens the DM on its side.
2015-11-20 15:48:02 +01:00
Aaron Bohy 3c0c354e19 [FIX] web: list_view: display nocontent helper after delete
if there are no more records to display
2015-11-20 09:43:58 +01:00
Aaron Bohy cdc71ba9a7 [FIX] im_livechat: rating shortcodes' type is image
...and not text, which is the default value. Otherwise, they are evaluated
server-side and the produced html is escaped in the body. Smileys are thus
not displayed.
2015-11-19 08:16:56 +01:00
Aaron Bohy d519ce5596 [FIX] mail: channels: don't send email by default
Disable this option by default as it might be very costly on channels with a
lot of members. Should be manually set to true on massmailing channels.
2015-11-19 08:16:56 +01:00
Aaron Bohy 0cd10f9af8 [FIX] mail: chatter: undefined variable 'event' on firefox
Variable 'event' is magically defined on some browsers like chrome, but not on
firefox. Anyway, those preventDefault() were useless as they are performed
beforehand.
2015-11-17 15:49:43 +01:00
Aaron Bohy eae08d39d6 [FIX] mail: mark as read: notify correct partner
When calling 'set_message_done' on a message which is a needaction for several
partners, the method was executed as root. This was an issue for the triggered
notification, as it was thus always sent to the admin.

For example, when Demo user marked such a message as read, he never received
the notification, but the Admin did, and its notification counter weirdly
decreased, while the one of Demo user remained the same.
2015-11-17 10:06:18 +01:00
Aaron Bohy a537a8466c [FIX] mail: close livechat conversations without unsubscribing
The problem occured when the user in the backend (client action) closed the
livechat before the user in the frontend, because we performed the wrong RPC,
and the backend user was removed from the partners following the discussion.
Thus, the messages sent from that point by the frontend user were never
received.

When closing a DM or livechat, we should call 'channel_pin', when unsubscribing
from a channel, we should call 'action_unfollow'.
2015-11-17 10:06:18 +01:00
Aaron Bohy 4ce2d6f7c3 [FIX] im_livechat: MailChannel inheritance
Commit 2bb55ec adds argument extra_info to the signature of channel_info() in
mail addon. However, this method is inherited from the im_livechat addon, and
its signature hadn't been adapted, causing tracebacks when im_livechat was
installed and channel_info() was called with an extra_info.
2015-11-17 10:06:18 +01:00
Aaron Bohy c51af45384 [FIX] mail: various UI improvements
- vertically center date and messages separators in threads
- remove notifications in DM and livechat
- order mail demo data so that messages appear ordered (they are ordered by id)
- make sure that DM are pinned (they weren't on the receiver side)
- don't display DM until a message has been sent
- validate message body
- undo snackbar fine tuning
- fix Firefox scroll bug on sidebar rendering (the scroll position was often
  lost when the sidebar was re-rendered, seemingly because the width of the
  thread changed for a brief moment)
2015-11-17 10:06:18 +01:00
Aaron Bohy 2c60b1bc2d [FIX] bus: correctly detect master tabs
The problem was that the tab_manager compared its last heartbeat value with an
old value stored in the local storage (when being elicted master, the tab
writes a new heartbeat in the locat storage).

This solution makes sure to compare the actual value in the local storage with
the heartbeat value stored in the tab_manager.
2015-11-16 09:51:08 +01:00
Aaron Bohy 196e1322f2 [FIX] mail: needactions: mark as (un)read
Marking a message as read in the inbox doesn't remove needactions on all
channels anymore.

When joining a channel (other than the inbox) in which there are needactions,
those needactions are automatically marked as read and removed from the inbox.
When the user clicked on Undo in the snackbar, the messages weren't correctly
re-inserted in the inbox (in the JS cache).
2015-11-16 09:51:08 +01:00
Aaron Bohy 77e54d2987 [FIX] mail: chatter: follower subtype: check checkbox on unfollow cancel
When unfollowing the last followed subtype, a confirm dialog is shown to the
user to confirm that it will unfollow the document. If he clicked on 'Cancel',
the unchecked subtype wasn't correctly re-checked.
2015-11-12 12:02:46 +01:00
Aaron Bohy 5264ccf0d0 [IMP] mail: needactions and messages read
Mainly concern the client action:
	- Display needactions per channels
	- For all channels except Inbox, clear needactions when opening the channel
	- Add snackbar to undo needactions clearing
	- Display a separator between read and unread messages in threads
	- Fix active channel (for Inbox and Starred) display in sidebar

Various minor changes in chat_manager:
	- Code refactoring of bus notification handler
	- get_channel() don't fallback anymore on first channel
2015-11-12 08:51:56 +01:00
Aaron Bohy dbc1061854 [FIX] mail: load more messages: correct search domain
The problem was that the load more feature didn't return directly preceeding
messages in the thread but rather older messages.
2015-11-12 08:51:56 +01:00
Aaron Bohy de665f4b6d [FIX] mail: mail_message: needaction_partner_ids wording
The 'string' attribute for both needaction_partner_ids and needaction fields
was 'Need Action'. This was problematic for example in the custom filters of the
searchview as it looked like the same field was appearing twice.

Update mail.pot as well.
2015-11-04 16:31:44 +01:00
Aaron Bohy 9c04a9e68b [FIX] mail: needactions: send mentionned partners on message post
When posting a message, the ids of mentionned partners are specified in the
partner_ids array. This has been broken in commit 388f7a7d, my bad.
2015-11-04 16:31:44 +01:00