[IMP] mail: group mailFailures by type in systray
We want to add new kinds of failures to the list in the systray, such as Snailmail or SMS failures. Until now, failures linked to documents of the same model were grouped together in the systray. Different types of failures should not be grouped in a single line so we add a '_failureType' variable to mailFailures and group them only if their type is the same. closes odoo/odoo#29855
This commit is contained in:
@@ -13,6 +13,7 @@ var MailFailure = Class.extend(Mixins.EventDispatcherMixin, ServicesMixin, {
|
||||
/**
|
||||
* @param {mail.Manager} parent
|
||||
* @param {Object} data
|
||||
* @param {string} data.failure_type
|
||||
* @param {string} data.last_message_date
|
||||
* @param {integer} data.message_id
|
||||
* @param {string} data.model
|
||||
@@ -29,6 +30,7 @@ var MailFailure = Class.extend(Mixins.EventDispatcherMixin, ServicesMixin, {
|
||||
|
||||
this._documentID = data.res_id;
|
||||
this._documentModel = data.model;
|
||||
this._failureType = data.failure_type || 'mail';
|
||||
this._lastMessageDate = moment(); // by default: current datetime
|
||||
this._messageID = data.message_id;
|
||||
this._modelName = data.model_name;
|
||||
@@ -62,6 +64,14 @@ var MailFailure = Class.extend(Mixins.EventDispatcherMixin, ServicesMixin, {
|
||||
getDocumentID: function () {
|
||||
return this._documentID;
|
||||
},
|
||||
/**
|
||||
* Get the type of failure of this mail failure.
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
getFailureType: function () {
|
||||
return this._failureType;
|
||||
},
|
||||
/**
|
||||
* Get the ID of the message that this mail failure is related to.
|
||||
*
|
||||
|
||||
@@ -676,8 +676,8 @@ var MailManager = AbstractService.extend({
|
||||
},
|
||||
/**
|
||||
* Get the previews of the mail failures
|
||||
* Mail failures of a same model are grouped together, so that there are few
|
||||
* preview items on the messaging menu in the systray.
|
||||
* Mail failures of a same model with the same type are grouped together, so
|
||||
* that there are few preview items on the messaging menu in the systray.
|
||||
*
|
||||
* To determine whether this is a model preview or a document preview review
|
||||
* the documentID is omitted for a model preview, whereas it is set for a
|
||||
@@ -696,10 +696,11 @@ var MailManager = AbstractService.extend({
|
||||
_.each(this._mailFailures, function (failure) {
|
||||
var unreadCounter = 1;
|
||||
var isSameDocument = true;
|
||||
var sameModelItem = _.find(items, function (item) {
|
||||
var sameModelAndTypeItem = _.find(items, function (item) {
|
||||
if (
|
||||
item.failure.isLinkedToDocument() &&
|
||||
(item.failure.getDocumentModel() === failure.getDocumentModel())
|
||||
(item.failure.getDocumentModel() === failure.getDocumentModel()) &&
|
||||
(item.failure.getFailureType() === failure.getFailureType())
|
||||
) {
|
||||
isSameDocument = item.failure.getDocumentID() === failure.getDocumentID();
|
||||
return true;
|
||||
@@ -707,10 +708,10 @@ var MailManager = AbstractService.extend({
|
||||
return false;
|
||||
});
|
||||
|
||||
if (failure.isLinkedToDocument() && sameModelItem) {
|
||||
unreadCounter = sameModelItem.unreadCounter + 1;
|
||||
isSameDocument = sameModelItem.isSameDocument && isSameDocument;
|
||||
var index = _.findIndex(items, sameModelItem);
|
||||
if (failure.isLinkedToDocument() && sameModelAndTypeItem) {
|
||||
unreadCounter = sameModelAndTypeItem.unreadCounter + 1;
|
||||
isSameDocument = sameModelAndTypeItem.isSameDocument && isSameDocument;
|
||||
var index = _.findIndex(items, sameModelAndTypeItem);
|
||||
items[index] = {
|
||||
unreadCounter: unreadCounter,
|
||||
failure: failure,
|
||||
|
||||
Reference in New Issue
Block a user