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
|
odoo.define('snailmail/static/src/components/message/message.js', function (require) {
'use strict';
const components = {
Message: require('mail/static/src/components/message/message.js'),
SnailmailErrorDialog: require('snailmail/static/src/components/snailmail_error_dialog/snailmail_error_dialog.js'),
SnailmailNotificationPopover: require('snailmail/static/src/components/snailmail_notification_popover/snailmail_notification_popover.js'),
};
const { patch } = require('web.utils');
const { useState } = owl;
Object.assign(components.Message.components, {
SnailmailErrorDialog: components.SnailmailErrorDialog,
SnailmailNotificationPopover: components.SnailmailNotificationPopover,
});
patch(components.Message, 'snailmail/static/src/components/message/message.js', {
/**
* @override
*/
_constructor() {
this._super(...arguments);
this.snailmailState = useState({
// Determine if the error dialog is displayed.
hasDialog: false,
});
},
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* @override
*/
_onClickFailure() {
if (this.message.message_type === 'snailmail') {
/**
* Messages from snailmail are considered to have at most one
* notification. The failure type of the whole message is considered
* to be the same as the one from that first notification, and the
* click action will depend on it.
*/
switch (this.message.notifications[0].failure_type) {
case 'sn_credit':
// URL only used in this component, not received at init
this.env.messaging.fetchSnailmailCreditsUrl();
this.snailmailState.hasDialog = true;
break;
case 'sn_error':
this.snailmailState.hasDialog = true;
break;
case 'sn_fields':
this.message.openMissingFieldsLetterAction();
break;
case 'sn_format':
this.message.openFormatLetterAction();
break;
case 'sn_price':
this.snailmailState.hasDialog = true;
break;
case 'sn_trial':
// URL only used in this component, not received at init
this.env.messaging.fetchSnailmailCreditsUrlTrial();
this.snailmailState.hasDialog = true;
break;
}
} else {
this._super(...arguments);
}
},
//--------------------------------------------------------------------------
// Handlers
//--------------------------------------------------------------------------
/**
* @private
*/
_onDialogClosedSnailmailError() {
this.snailmailState.hasDialog = false;
},
});
});
|