[IMP] mail, *: remove legacy code from activity systray

* = calendar, crm, im_livechat, mass_mailing_sms, note, test_discuss_full,
    test_mail

task-2920645

closes odoo/odoo#96114

Related: odoo/enterprise#29794
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2022-07-27 02:18:15 +02:00
parent 0099b8ee36
commit b401ba6e2d
52 changed files with 1038 additions and 1022 deletions
@@ -0,0 +1,17 @@
/** @odoo-module **/
import { addFields, addRecordMethods } from '@mail/model/model_core';
import { attr } from '@mail/model/model_field';
import '@mail/models/activity_group'; // ensure the model definition is loaded before the patch
addRecordMethods('ActivityGroup', {
_computeIsNote() {
return this.irModel.model === 'note.note';
},
});
addFields('ActivityGroup', {
isNote: attr({
compute: '_computeIsNote',
}),
});
@@ -0,0 +1,112 @@
/** @odoo-module **/
import { addFields, addRecordMethods, patchRecordMethods } from '@mail/model/model_core';
import { attr } from '@mail/model/model_field';
import { clear } from '@mail/model/model_field_command';
import '@mail/models/activity_menu_view'; // ensure the model definition is loaded before the patch
const { DateTime } = luxon;
addRecordMethods('ActivityMenuView', {
/**
* @param {MouseEvent} ev
*/
onClickAddNote(ev) {
this.update({
addingNoteDoFocus: true,
isAddingNote: true,
});
},
/**
* @param {MouseEvent} ev
*/
onClickSaveNote(ev) {
this.saveNote();
},
onComponentUpdate() {
if (this.addingNoteDoFocus && this.noteInputRef.el) {
this.noteInputRef.el.focus();
this.update({ addingNoteDoFocus: clear() });
}
},
/**
* @param {DateTime|string} date
*/
onDateTimeChanged(date) {
this.update({ addingNoteDate: date ? date : clear() });
},
/**
* @param {KeyboardEvent} ev
*/
onKeydownNoteInput(ev) {
if (ev.key === 'Enter') {
this.saveNote();
}
},
async saveNote() {
const note = this.noteInputRef.el.value.trim();
if (!note) {
return;
}
this.update({ isAddingNote: false });
await this.messaging.rpc({
route: '/note/new',
params: {
'note': note,
'date_deadline': this.addingNoteDate ? this.addingNoteDate : new DateTime.local(),
},
});
this.fetchData();
},
/**
* @private
* @returns {string}
*/
_computeAddingNoteDatePlaceholder() {
return this.env._t("Today");
},
});
patchRecordMethods('ActivityMenuView', {
/**
* @override
*/
close() {
this.update({
addingNoteDoFocus: clear(),
isAddingNote: false,
});
this._super();
},
/**
* @override
*/
_onClickCaptureGlobal(ev) {
if (ev.target.closest('.bootstrap-datetimepicker-widget')) {
return;
}
this._super(ev);
},
/**
* @override
*/
_sortActivityGroups(ev) {
const res = this._super();
res.unshift(['truthy-first', 'isNote']);
return res;
},
});
addFields('ActivityMenuView', {
addingNoteDate: attr(),
addingNoteDoFocus: attr({
default: false,
}),
addingNoteDatePlaceholder: attr({
compute: '_computeAddingNoteDatePlaceholder',
}),
isAddingNote: attr({
default: false,
}),
noteInputRef: attr(),
});