FIX: Allow non-english usernames in autocomplete

Also add support for username formatters
This commit is contained in:
Robin Ward 2018-08-01 11:52:59 -04:00
parent 0f6dcb8c40
commit 7c950321d1
3 changed files with 5 additions and 11 deletions

View File

@ -2,6 +2,7 @@ import { observes } from "ember-addons/ember-computed-decorators";
import TextField from "discourse/components/text-field";
import userSearch from "discourse/lib/user-search";
import { findRawTemplate } from "discourse/lib/raw-templates";
import { formatUsername } from "discourse/lib/utilities";
export default TextField.extend({
autocorrect: false,
@ -46,11 +47,6 @@ export default TextField.extend({
return usernames;
}
const termRegexp =
currentUser && currentUser.can_send_private_email_messages
? /[^\w.-@]/g
: /[^\w.-]/g;
this.$()
.val(this.get("usernames"))
.autocomplete({
@ -62,7 +58,7 @@ export default TextField.extend({
dataSource(term) {
var results = userSearch({
term: term.replace(termRegexp, ""),
term,
topicId: self.get("topicId"),
exclude: excludedUsernames(),
includeGroups,
@ -72,7 +68,6 @@ export default TextField.extend({
group: self.get("group"),
disallowEmails
});
return results;
},

View File

@ -122,8 +122,7 @@ export default function userSearch(options) {
currentTerm = term;
return new Ember.RSVP.Promise(function(resolve) {
// TODO site setting for allowed regex in username
if (term.match(/[^\w_\-\.@\+]/)) {
if (term.length === 0) {
resolve([]);
return;
}

View File

@ -4,7 +4,7 @@
<li>
<a href title="{{user.name}}">
{{avatar user imageSize="tiny"}}
<span class='username'>{{user.username}}</span>
<span class='username'>{{format-username user.username}}</span>
<span class='name'>{{user.name}}</span>
</a>
</li>
@ -15,7 +15,7 @@
<li>
<a href title="{{email.username}}">
<i class='fa fa-envelope'></i>
<span class='username'>{{email.username}}</span>
<span class='username'>{{format-username email.username}}</span>
</a>
</li>
{{/each}}