mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 13:13:39 +08:00
Merge pull request #1988 from ligthyear/fix-system-group-aliases
Fix group aliases causing private messages to not be created
This commit is contained in:
commit
b9ce9a3f54
|
@ -89,7 +89,7 @@ $.fn.autocomplete = function(options) {
|
|||
if (options.transformComplete) { transformedItem = options.transformComplete(transformedItem); }
|
||||
// dump what we have in single mode, just in case
|
||||
if (options.single) { inputSelectedItems = []; }
|
||||
if (!_.isArray(transformedItem)) { transformed = [transformedItem || item]; }
|
||||
transformed = _.isArray(transformedItem) ? transformedItem : [transformedItem || item];
|
||||
|
||||
var divs = transformed.map(function(itm) {
|
||||
var d = $("<div class='item'><span>" + itm + "<a class='remove' href='#'><i class='fa fa-times'></i></a></span></div>");
|
||||
|
|
|
@ -4,6 +4,14 @@ Discourse.UserSelector = Discourse.TextField.extend({
|
|||
var userSelectorView = this,
|
||||
selected = [];
|
||||
|
||||
function excludedUsernames() {
|
||||
var exclude = selected;
|
||||
if (userSelectorView.get('excludeCurrentUser')) {
|
||||
exclude = exclude.concat([Discourse.User.currentProp('username')]);
|
||||
}
|
||||
return exclude;
|
||||
}
|
||||
|
||||
$(this.get('element')).val(this.get('usernames')).autocomplete({
|
||||
template: Discourse.UserSelector.templateFunction(),
|
||||
|
||||
|
@ -12,14 +20,10 @@ Discourse.UserSelector = Discourse.TextField.extend({
|
|||
allowAny: this.get('allowAny'),
|
||||
|
||||
dataSource: function(term) {
|
||||
var exclude = selected;
|
||||
if (userSelectorView.get('excludeCurrentUser')) {
|
||||
exclude = exclude.concat([Discourse.User.currentProp('username')]);
|
||||
}
|
||||
return Discourse.UserSearch.search({
|
||||
term: term,
|
||||
topicId: userSelectorView.get('topicId'),
|
||||
exclude: exclude,
|
||||
exclude: excludedUsernames(),
|
||||
include_groups: userSelectorView.get('include_groups')
|
||||
});
|
||||
},
|
||||
|
@ -28,7 +32,11 @@ Discourse.UserSelector = Discourse.TextField.extend({
|
|||
if (v.username) {
|
||||
return v.username;
|
||||
} else {
|
||||
return v.usernames;
|
||||
var excludes = excludedUsernames();
|
||||
return v.usernames.filter(function(item){
|
||||
// include only, those not found in the exclude list
|
||||
return excludes.indexOf(item) === -1;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user