[IMP] mail: chatter channel notification
Ability to notify the channel but do not add the channel as a follower. Faster than mentioning every member of the channel. Also, clean the rendering of the mention suggestions name to avoid having escaped char in the UI. Task id : 1859802 Closes #25887
This commit is contained in:
committed by
David Beguin
parent
a3daff6bc1
commit
e2f20ffa93
@@ -416,6 +416,7 @@ var BasicComposer = Widget.extend({
|
|||||||
attachment_ids: _.pluck(this.get('attachment_ids'), 'id'),
|
attachment_ids: _.pluck(this.get('attachment_ids'), 'id'),
|
||||||
partner_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelection('@'), 'id')),
|
partner_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelection('@'), 'id')),
|
||||||
canned_response_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelections()[':'], 'id')),
|
canned_response_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelections()[':'], 'id')),
|
||||||
|
channel_ids: _.uniq(_.pluck(this._mentionManager.getListenerSelection('#'), 'id')),
|
||||||
command: commands.length > 0 ? commands[0].name : undefined,
|
command: commands.length > 0 ? commands[0].name : undefined,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -52,10 +52,8 @@ var MentionManager = Widget.extend({
|
|||||||
getListenerSelection: function (delimiter) {
|
getListenerSelection: function (delimiter) {
|
||||||
var listener = _.findWhere(this._listeners, { delimiter: delimiter });
|
var listener = _.findWhere(this._listeners, { delimiter: delimiter });
|
||||||
if (listener) {
|
if (listener) {
|
||||||
var inputMentions = this._composer
|
var escapedVal = _.escape(this._composer.$input.val());
|
||||||
.$input
|
var inputMentions = escapedVal.match(new RegExp(delimiter+'[^ ]+(?= | )', 'g'));
|
||||||
.val()
|
|
||||||
.match(new RegExp(delimiter+'[^ ]+(?= | )', 'g'));
|
|
||||||
return this._validateSelection(listener.selection, inputMentions);
|
return this._validateSelection(listener.selection, inputMentions);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
@@ -315,7 +313,10 @@ var MentionManager = Widget.extend({
|
|||||||
}
|
}
|
||||||
if (suggestions.length) {
|
if (suggestions.length) {
|
||||||
this.$el.html(QWeb.render(this._activeListener.suggestionTemplate, {
|
this.$el.html(QWeb.render(this._activeListener.suggestionTemplate, {
|
||||||
suggestions: suggestions,
|
suggestions: _.map(suggestions, function (suggestion) {
|
||||||
|
// mention manager stores escaped suggestion names
|
||||||
|
return _.extend({}, suggestion, { name: _.unescape(suggestion.name) });
|
||||||
|
})
|
||||||
}));
|
}));
|
||||||
this.$el
|
this.$el
|
||||||
.addClass('show')
|
.addClass('show')
|
||||||
@@ -384,8 +385,9 @@ var MentionManager = Widget.extend({
|
|||||||
if (!substitution) {
|
if (!substitution) {
|
||||||
// no substitution string given, so use the mention name instead
|
// no substitution string given, so use the mention name instead
|
||||||
// replace white spaces with non-breaking spaces to facilitate
|
// replace white spaces with non-breaking spaces to facilitate
|
||||||
// mentions detection in text
|
// mentions detection in text.
|
||||||
selectedSuggestion.name = selectedSuggestion.name.replace(/ /g, NON_BREAKING_SPACE);
|
// mention manager stores escaped suggestion names
|
||||||
|
selectedSuggestion.name = _.unescape(selectedSuggestion.name.replace(/ /g, NON_BREAKING_SPACE));
|
||||||
substitution = this._activeListener.delimiter + selectedSuggestion.name;
|
substitution = this._activeListener.delimiter + selectedSuggestion.name;
|
||||||
}
|
}
|
||||||
var getMentionIndex = function (matches, cursorPosition) {
|
var getMentionIndex = function (matches, cursorPosition) {
|
||||||
|
|||||||
@@ -344,6 +344,9 @@ var Thread = AbstractThread.extend(ServicesMixin, {
|
|||||||
body = this._generateEmojis(body);
|
body = this._generateEmojis(body);
|
||||||
var messageData = {
|
var messageData = {
|
||||||
partner_ids: data.partner_ids,
|
partner_ids: data.partner_ids,
|
||||||
|
channel_ids: _.map(data.channel_ids, function (channelID) {
|
||||||
|
return [4, channelID, false];
|
||||||
|
}),
|
||||||
body: body,
|
body: body,
|
||||||
attachment_ids: data.attachment_ids,
|
attachment_ids: data.attachment_ids,
|
||||||
canned_response_ids: data.canned_response_ids,
|
canned_response_ids: data.canned_response_ids,
|
||||||
|
|||||||
Reference in New Issue
Block a user