summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2020-03-11 09:38:29 +0000
committerJulien Mougenot <jum@odoo.com>2020-03-13 14:08:33 +0000
commite68d3bb09d1f844387ceb20aa76022ace48507d9 (patch)
treed238fa35dcb11e5628112377a9daf569405ca74b /addons/mail/static/src
parent18e5416636b19b0953b1e6e26bfaeab1ebecce4c (diff)
[REF] *: Adapt all modules to new control panel
Adaptation of the code throughout all modules to properly instantiate the newly refactored control panel and update it accordingly. Part of task 2196029 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/js/custom_filter_item.js22
-rw-r--r--addons/mail/static/src/js/discuss.js83
-rw-r--r--addons/mail/static/src/js/filter_menu.js16
-rw-r--r--addons/mail/static/src/js/views/activity/activity_controller.js9
4 files changed, 66 insertions, 64 deletions
diff --git a/addons/mail/static/src/js/custom_filter_item.js b/addons/mail/static/src/js/custom_filter_item.js
new file mode 100644
index 00000000000..b828d0f44f6
--- /dev/null
+++ b/addons/mail/static/src/js/custom_filter_item.js
@@ -0,0 +1,22 @@
+odoo.define('mail.CustomFilterItem', function (require) {
+ "use strict";
+
+ const CustomFilterItem = require('web.CustomFilterItem');
+ const utils = require('web.utils');
+
+ utils.patch(CustomFilterItem, 'mail.CustomFilterItem', {
+
+ /**
+ * With the `mail` module installed, we want to filter out some of the
+ * available fields in 'Add custom filter' menu (@see CustomFilterItem).
+ * @override
+ */
+ _validateField(field) {
+ return this._super(...arguments) &&
+ field.relation !== 'mail.message' &&
+ field.name !== 'message_ids';
+ },
+ });
+
+ return CustomFilterItem;
+});
diff --git a/addons/mail/static/src/js/discuss.js b/addons/mail/static/src/js/discuss.js
index 8a4606cc814..79a13c307c8 100644
--- a/addons/mail/static/src/js/discuss.js
+++ b/addons/mail/static/src/js/discuss.js
@@ -243,7 +243,6 @@ var Discuss = AbstractAction.extend({
custom_events: _.extend({}, AbstractAction.prototype.custom_events, {
discard_extended_composer: '_onDiscardExtendedComposer',
message_moderation: '_onMessageModeration',
- search: '_onSearch',
update_moderation_buttons: '_onUpdateModerationButtons',
}),
events: {
@@ -292,7 +291,7 @@ var Discuss = AbstractAction.extend({
this._throttledUpdateThreads = _.throttle(
this._updateThreads.bind(this), 100, { leading: false });
- this.controlPanelParams.modelName = 'mail.message';
+ this.controlPanelModelConfig.modelName = 'mail.message';
this.call('mail_service', 'getMailBus').on('messaging_ready', this, this._onMessagingReady);
},
/**
@@ -313,7 +312,7 @@ var Discuss = AbstractAction.extend({
*/
do_show: function () {
this._super.apply(this, arguments);
- this._updateControlPanel();
+ this.updateControlPanel();
this.action_manager.do_push_state({
action: this.action.id,
active_id: this._thread.getID(),
@@ -332,6 +331,7 @@ var Discuss = AbstractAction.extend({
* @override
*/
on_attach_callback: function () {
+ this._super();
this.call('mail_service', 'getMailBus').trigger('discuss_open', true);
if (this._thread) {
this._threadWidget.scrollToPosition(this._threadsScrolltop[this._thread.getID()]);
@@ -342,6 +342,7 @@ var Discuss = AbstractAction.extend({
* @override
*/
on_detach_callback: function () {
+ this._super();
this.call('mail_service', 'getMailBus').trigger('discuss_open', false);
this._threadsScrolltop[this._thread.getID()] = this._threadWidget.getScrolltop();
},
@@ -937,9 +938,7 @@ var Discuss = AbstractAction.extend({
* @param {integer} threadID a thread with such ID
* @returns {Promise}
*/
- _setThread: function (threadID) {
- var self = this;
-
+ _setThread: async function (threadID) {
this.$('.o_out_of_office').remove();
// Store scroll position and composer state of the previous thread
this._storeThreadState();
@@ -960,36 +959,39 @@ var Discuss = AbstractAction.extend({
this._basicComposer.setThread(this._thread);
this._extendedComposer.setThread(this._thread);
- return this._fetchAndRenderThread().then(function () {
- // Mark thread's messages as read and clear needactions
- if (self._thread.getType() !== 'mailbox') {
- self._thread.markAsRead();
- }
- // Restore scroll position and composer of the new current thread
- self._restoreThreadState();
+ await this._fetchAndRenderThread();
+ // Mark thread's messages as read and clear needactions
+ if (this._thread.getType() !== 'mailbox') {
+ this._thread.markAsRead();
+ }
+ // Restore scroll position and composer of the new current thread
+ this._restoreThreadState();
- // Update control panel before focusing the composer, otherwise
- // focus is on the searchview
- self._setTitle('#' + self._thread.getName());
- self._updateControlPanel();
- self._updateControlPanelButtons(self._thread);
+ // Update control panel before focusing the composer, otherwise
+ // focus is on the searchview
+ await this.updateControlPanel({
+ title: '#' + this._thread.getName(),
+ cp_content: {
+ $buttons: this.$buttons,
+ },
+ });
+ this._updateControlPanelButtons(this._thread);
- // Display and focus the adequate composer, and unselect possibly
- // selected message to prevent sending messages as reply to that
- // message
- self._unselectMessage();
+ // Display and focus the adequate composer, and unselect possibly
+ // selected message to prevent sending messages as reply to that
+ // message
+ this._unselectMessage();
- if (self._thread.hasOutOfOffice()) {
- const $outOfOffice = $(QWeb.render('mail.thread.OutOfOffice', {
- thread: self._thread
- }));
- $outOfOffice.prependTo(self.$('.o_mail_discuss_content'));
- }
+ if (this._thread.hasOutOfOffice()) {
+ const $outOfOffice = $(QWeb.render('mail.thread.OutOfOffice', {
+ thread: this._thread
+ }));
+ $outOfOffice.prependTo(this.$('.o_mail_discuss_content'));
+ }
- self.action_manager.do_push_state({
- action: self.action.id,
- active_id: self._thread.getID(),
- });
+ this.action_manager.do_push_state({
+ action: this.action.id,
+ active_id: this._thread.getID(),
});
},
/**
@@ -1098,16 +1100,6 @@ var Discuss = AbstractAction.extend({
}
},
/**
- * @private
- */
- _updateControlPanel: function () {
- this.updateControlPanel({
- cp_content: {
- $buttons: this.$buttons,
- },
- });
- },
- /**
* Updates the control panel buttons visibility based on thread type
*
* @private
@@ -1530,11 +1522,10 @@ var Discuss = AbstractAction.extend({
},
/**
* @private
- * @param {OdooEvent} ev
+ * @param {Object} searchQuery
*/
- _onSearch: function (ev) {
- ev.stopPropagation();
- this.domain = ev.data.domain;
+ _onSearch: function (searchQuery) {
+ this.domain = searchQuery.domain;
if (this._thread) {
// initially (when _onSearch is called manually), there is no
// thread set yet, so don't try to fetch and render the thread as
diff --git a/addons/mail/static/src/js/filter_menu.js b/addons/mail/static/src/js/filter_menu.js
deleted file mode 100644
index dbf2428bda9..00000000000
--- a/addons/mail/static/src/js/filter_menu.js
+++ /dev/null
@@ -1,16 +0,0 @@
-odoo.define('mail.FilterMenu', function (require) {
-"use strict";
-
-var FilterMenu = require('web.FilterMenu');
-
-FilterMenu.include({
- init: function () {
- this._super.apply(this, arguments);
- //remove messages from custom filters
- this.fields = _.pick(this.fields, function (field, name) {
- return field.relation !== 'mail.message' && name !== 'message_ids';
- });
- },
-});
-
-});
diff --git a/addons/mail/static/src/js/views/activity/activity_controller.js b/addons/mail/static/src/js/views/activity/activity_controller.js
index 8de28d65cc9..106c5ee90f1 100644
--- a/addons/mail/static/src/js/views/activity/activity_controller.js
+++ b/addons/mail/static/src/js/views/activity/activity_controller.js
@@ -33,13 +33,18 @@ var ActivityController = BasicController.extend({
this._super.apply(this, arguments);
this.title = params.title;
},
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
/**
* Overridden to remove the pager as it makes no sense in this view.
*
* @override
*/
- renderPager: function () {
- return Promise.resolve();
+ _getPagingInfo: function () {
+ return null;
},
//--------------------------------------------------------------------------