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:
Régis Hanol 2014-02-24 10:49:42 +01:00
commit b9ce9a3f54
2 changed files with 15 additions and 7 deletions

View File

@ -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>");

View File

@ -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;
});
}
},