summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/thread.js
diff options
context:
space:
mode:
authorMathieu Duckaerts-Antoine <dam@odoo.com>2018-05-24 15:27:28 +0200
committerThibault Delavallée <tde@odoo.com>2018-06-06 16:01:33 +0200
commit299ebb2cdf63de2e3967da0d2f3e7effd239812b (patch)
treef2681c0fc1e283acdfd5942392db8f17ddc7801d /addons/mail/static/src/js/thread.js
parenteeab18d753db21bca0636836c40df91268549390 (diff)
[IMP] mail: add moderation on channels
Purpose of this commit is to allow moderation on incoming messages in discussion channels. On some channels on which moderation is required messages should be in a pending moderation stage. Moderators can accept or refuse messages as well as always allow or ban messages coming from a given set of emails. Channels now have an option to be moderated. Moderators can be added on channels. They have access to a specific UI in Discuss to see and take action on messages waiting for moderation. Concerning mail.thread message that are pending moderation are not notified. It means nobody receives a notification about them. Moderation process calls the notification once the message is validated. Various features included in this commit : * a model is added to store the decision about emails, allow or ban; * access rights are updated so that only moderators can modify moderation fields on message; * specific bus notifications are send to moderated people as well as to moderators on incoming emails as well as when a decision is taken; * options are added on channels to send explanations to moderated emails; * options are added on channels to write and send guidelines explaining why and how moderation is performed; * a reminder is send daily to moderators with remaining messages to moderate; * discuss UI is adapted and a new channel is added below Inbox and Starred giving access to moderation tools; * chanenl UI is adapted allowing to moderate directly inside channels; This commit is linked to task ID 29521. Closes #21921.
Diffstat (limited to 'addons/mail/static/src/js/thread.js')
-rw-r--r--addons/mail/static/src/js/thread.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/addons/mail/static/src/js/thread.js b/addons/mail/static/src/js/thread.js
index f34823ff9fc..39d179a715a 100644
--- a/addons/mail/static/src/js/thread.js
+++ b/addons/mail/static/src/js/thread.js
@@ -38,6 +38,8 @@ var Thread = Widget.extend({
var message_id = $(event.currentTarget).data('message-id');
this.trigger("mark_as_read", message_id);
},
+ "click .o_thread_message_moderation": "_onClickMessageModeration",
+ "change .moderation_checkbox": "_onChangeModerationCheckbox",
"click .o_thread_message_star": function (event) {
var message_id = $(event.currentTarget).data('message-id');
this.trigger("toggle_star_status", message_id);
@@ -141,7 +143,6 @@ var Thread = Widget.extend({
}
prev_msg = msg;
});
-
this.$el.html(QWeb.render('mail.ChatThread', {
messages: msgs,
options: options,
@@ -313,6 +314,15 @@ var Thread = Widget.extend({
destroy: function () {
clearInterval(this.update_timestamps_interval);
},
+ /**
+ * Toggle all the moderation checkboxes in the thread
+ *
+ * @param {boolean} checked if true, check the boxes,
+ * otherwise uncheck them.
+ */
+ toggleModerationCheckboxes: function (checked) {
+ this.$('.moderation_checkbox').prop('checked', checked);
+ },
//--------------------------------------------------------------------------
// Private
@@ -387,6 +397,23 @@ var Thread = Widget.extend({
attachmentViewer.appendTo($('body'));
}
},
+ /**
+ * @private
+ * @param {MouseEvent} ev
+ */
+ _onChangeModerationCheckbox: function (ev) {
+ this.trigger_up('update_moderation_buttons');
+ },
+ /**
+ * @private
+ * @param {MouseEvent} ev
+ */
+ _onClickMessageModeration: function (ev) {
+ var $button = $(ev.currentTarget);
+ var messageID = $button.data('message-id');
+ var decision = $button.data('decision');
+ this.trigger_up('message_moderation', { messageID: messageID, decision: decision });
+ },
});
Thread.ORDER = ORDER;