1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
odoo.define('mail/static/src/components/chat_window_header/chat_window_header.js', function (require) {
'use strict';
const components = {
ThreadIcon: require('mail/static/src/components/thread_icon/thread_icon.js'),
};
const useShouldUpdateBasedOnProps = require('mail/static/src/component_hooks/use_should_update_based_on_props/use_should_update_based_on_props.js');
const useStore = require('mail/static/src/component_hooks/use_store/use_store.js');
const { Component } = owl;
class ChatWindowHeader extends Component {
/**
* @override
*/
constructor(...args) {
super(...args);
useShouldUpdateBasedOnProps();
useStore(props => {
const chatWindow = this.env.models['mail.chat_window'].get(props.chatWindowLocalId);
const thread = chatWindow && chatWindow.thread;
return {
chatWindow,
chatWindowHasShiftLeft: chatWindow && chatWindow.hasShiftLeft,
chatWindowHasShiftRight: chatWindow && chatWindow.hasShiftRight,
chatWindowName: chatWindow && chatWindow.name,
isDeviceMobile: this.env.messaging.device.isMobile,
thread,
threadLocalMessageUnreadCounter: thread && thread.localMessageUnreadCounter,
threadMassMailing: thread && thread.mass_mailing,
threadModel: thread && thread.model,
};
});
}
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* @returns {mail.chat_window}
*/
get chatWindow() {
return this.env.models['mail.chat_window'].get(this.props.chatWindowLocalId);
}
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* @private
* @param {MouseEvent} ev
*/
_onClick(ev) {
const chatWindow = this.chatWindow;
this.trigger('o-clicked', { chatWindow });
}
/**
* @private
* @param {MouseEvent} ev
*/
_onClickClose(ev) {
ev.stopPropagation();
if (!this.chatWindow) {
return;
}
this.chatWindow.close();
}
/**
* @private
* @param {MouseEvent} ev
*/
_onClickExpand(ev) {
ev.stopPropagation();
this.chatWindow.expand();
}
/**
* @private
* @param {MouseEvent} ev
*/
_onClickShiftLeft(ev) {
ev.stopPropagation();
this.chatWindow.shiftLeft();
}
/**
* @private
* @param {MouseEvent} ev
*/
_onClickShiftRight(ev) {
ev.stopPropagation();
this.chatWindow.shiftRight();
}
}
Object.assign(ChatWindowHeader, {
components,
defaultProps: {
hasCloseAsBackButton: false,
isExpandable: false,
},
props: {
chatWindowLocalId: String,
hasCloseAsBackButton: Boolean,
isExpandable: Boolean,
},
template: 'mail.ChatWindowHeader',
});
return ChatWindowHeader;
});
|