diff --git a/addons/mail/static/src/components/message_action_list/message_action_list.xml b/addons/mail/static/src/components/message_action_list/message_action_list.xml index 158d0ab2cc5..b3612fb4751 100644 --- a/addons/mail/static/src/components/message_action_list/message_action_list.xml +++ b/addons/mail/static/src/components/message_action_list/message_action_list.xml @@ -4,15 +4,24 @@
- - - - - + + + + + + + + +
diff --git a/addons/mail/static/src/models/message_action_list.js b/addons/mail/static/src/models/message_action_list.js index 315184af9fa..12eff4fcc4e 100644 --- a/addons/mail/static/src/models/message_action_list.js +++ b/addons/mail/static/src/models/message_action_list.js @@ -65,6 +65,13 @@ registerModel({ markEventHandled(ev, 'MessageActionList.replyTo'); this.messageView.replyTo(); }, + /** + * @private + * @param {MouseEvent} ev + */ + onClickToggleCompact(ev) { + this.update({ isCompact: !this.isCompact }); + }, /** * @private * @param {MouseEvent} ev @@ -72,6 +79,24 @@ registerModel({ onClickToggleStar(ev) { this.message.toggleStar(); }, + /** + * @private + * @returns {integer|FieldCommand} + */ + _computeActionsCount() { + if (this.message){ + const actions = [ + this.hasMarkAsReadIcon, + this.hasReplyIcon, + this.message.canBeDeleted, + this.message.canBeDeleted, + this.message.canStarBeToggled, + this.message.hasReactionIcon, + ] + return actions.filter(Boolean).length; + } + return clear(); + }, /** * @private * @returns {string} @@ -79,6 +104,17 @@ registerModel({ _computeAddReactionText() { return this.env._t("Add a Reaction"); }, + /** + * @private + * @returns {boolean} + */ + _computeHasCompactIcon() { + const COMPACT_THRESHOLD = 2; + const viewer = this.messageView && this.messageView.messageListViewMessageViewItemOwner && this.messageView.messageListViewMessageViewItemOwner.messageListViewOwner.threadViewOwner.threadViewer; + if (viewer && viewer.chatWindow) { + return this.actionsCount > COMPACT_THRESHOLD; + } + }, /** * @private * @returns {boolean} @@ -110,6 +146,10 @@ registerModel({ * States the reference to the reaction action in the component. */ actionReactionRef: attr(), + actionsCount: attr({ + compute: '_computeActionsCount', + readonly: true, + }), addReactionText: attr({ compute: '_computeAddReactionText', }), @@ -117,6 +157,10 @@ registerModel({ inverse: 'messageActionListOwnerAsDeleteConfirm', isCausal: true, }), + hasCompactIcon: attr({ + compute: '_computeHasCompactIcon', + readonly: true, + }), /** * Determines whether this message action list has mark as read icon. */ @@ -129,6 +173,9 @@ registerModel({ hasReplyIcon: attr({ compute: '_computeHasReplyIcon', }), + isCompact: attr({ + default: true, + }), /** * States the message on which this action message list operates. */