mirror of https://github.com/OCA/social.git
[FIX] mail_activity_done: Added the changes to avoid the linter warnings
parent
80eb0afecd
commit
c5f8d88d9a
|
@ -1,12 +1,11 @@
|
||||||
//Copyright 2018-20 ForgeFlow <http://www.forgeflow.com>
|
// Copyright 2018-20 ForgeFlow <http://www.forgeflow.com>
|
||||||
//License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
|
// License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
|
||||||
|
|
||||||
odoo.define('mail.Activity.done', function(require) {
|
odoo.define('mail.Activity.done', function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var mailUtils = require('mail.utils');
|
var mailUtils = require('mail.utils');
|
||||||
var core = require('web.core');
|
var core = require('web.core');
|
||||||
var utils = require('mail.utils');
|
|
||||||
var time = require('web.time');
|
var time = require('web.time');
|
||||||
var mail_activity = require('mail.Activity');
|
var mail_activity = require('mail.Activity');
|
||||||
|
|
||||||
|
@ -15,51 +14,61 @@ odoo.define('mail.Activity.done', function(require) {
|
||||||
|
|
||||||
// We are forced here to override the method, as there is no possibility
|
// We are forced here to override the method, as there is no possibility
|
||||||
// to inherit it.
|
// to inherit it.
|
||||||
var setDelayLabel = function(activities) {
|
var setDelayLabel = function (activities) {
|
||||||
var today = moment().startOf('day');
|
var today = moment().startOf('day');
|
||||||
_.each(activities, function(activity) {
|
_.each(activities, function (activity) {
|
||||||
var to_display = '';
|
var to_display = '';
|
||||||
var deadline = moment(activity.date_deadline).startOf('day');
|
var deadline = moment(activity.date_deadline).startOf('day');
|
||||||
var diff = deadline.diff(today, 'days', true); // true means no rounding
|
// On next line, true means no rounding
|
||||||
if(diff === 0){
|
var diff = deadline.diff(today, 'days', true);
|
||||||
|
if (diff === 0) {
|
||||||
to_display = _t('Today');
|
to_display = _t('Today');
|
||||||
}else{
|
} else {
|
||||||
if(diff < 0){ // overdue
|
// This block is for overdue
|
||||||
if(diff === -1){
|
if (diff < 0) { // eslint-disable-line no-lonely-if
|
||||||
|
if (diff === -1) {
|
||||||
to_display = _t('Yesterday');
|
to_display = _t('Yesterday');
|
||||||
}else{
|
} else {
|
||||||
to_display = _.str.sprintf(_t('%d days overdue'), Math.abs(diff));
|
to_display = _.str.sprintf(
|
||||||
|
_t('%d days overdue'), Math.abs(diff)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}else{ // due
|
// This block is for due
|
||||||
if(diff === 1){
|
} else {
|
||||||
|
if (diff === 1) { // eslint-disable-line no-lonely-if
|
||||||
to_display = _t('Tomorrow');
|
to_display = _t('Tomorrow');
|
||||||
}else{
|
} else {
|
||||||
to_display = _.str.sprintf(_t('Due in %d days'), Math.abs(diff));
|
to_display = _.str.sprintf(
|
||||||
|
_t('Due in %d days'), Math.abs(diff)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activity.label_delay = to_display;
|
activity.label_delay = to_display;
|
||||||
});
|
});
|
||||||
// We do not want to show the activities that have been completed.
|
// We do not want to show the activities that have been completed.
|
||||||
var open_activities = _.filter(activities, function(activity){
|
var open_activities = _.filter(activities, function (activity) {
|
||||||
return activity.done !== true
|
return activity.done !== true;
|
||||||
});
|
});
|
||||||
return open_activities;
|
return open_activities;
|
||||||
};
|
};
|
||||||
|
|
||||||
var Activity = mail_activity.include({
|
mail_activity.include({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @override
|
* @override
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_render: function () {
|
_render: function () {
|
||||||
_.each(this._activities, function (activity) {
|
_.each(this._activities, function (activity) {
|
||||||
var note = mailUtils.parseAndTransform(activity.note || '', mailUtils.inline);
|
var note = mailUtils.parseAndTransform(
|
||||||
|
activity.note || '', mailUtils.inline);
|
||||||
var is_blank = (/^\s*$/).test(note);
|
var is_blank = (/^\s*$/).test(note);
|
||||||
if (!is_blank) {
|
if (is_blank) {
|
||||||
activity.note = mailUtils.parseAndTransform(activity.note, mailUtils.addLink);
|
|
||||||
} else {
|
|
||||||
activity.note = '';
|
activity.note = '';
|
||||||
|
} else {
|
||||||
|
activity.note = mailUtils.parseAndTransform(
|
||||||
|
activity.note, mailUtils.addLink);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var activities = setDelayLabel(this._activities);
|
var activities = setDelayLabel(this._activities);
|
||||||
|
|
Loading…
Reference in New Issue