mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Allow non-english usernames in autocomplete
Also add support for username formatters
This commit is contained in:
parent
0f6dcb8c40
commit
7c950321d1
@ -2,6 +2,7 @@ import { observes } from "ember-addons/ember-computed-decorators";
|
|||||||
import TextField from "discourse/components/text-field";
|
import TextField from "discourse/components/text-field";
|
||||||
import userSearch from "discourse/lib/user-search";
|
import userSearch from "discourse/lib/user-search";
|
||||||
import { findRawTemplate } from "discourse/lib/raw-templates";
|
import { findRawTemplate } from "discourse/lib/raw-templates";
|
||||||
|
import { formatUsername } from "discourse/lib/utilities";
|
||||||
|
|
||||||
export default TextField.extend({
|
export default TextField.extend({
|
||||||
autocorrect: false,
|
autocorrect: false,
|
||||||
@ -46,11 +47,6 @@ export default TextField.extend({
|
|||||||
return usernames;
|
return usernames;
|
||||||
}
|
}
|
||||||
|
|
||||||
const termRegexp =
|
|
||||||
currentUser && currentUser.can_send_private_email_messages
|
|
||||||
? /[^\w.-@]/g
|
|
||||||
: /[^\w.-]/g;
|
|
||||||
|
|
||||||
this.$()
|
this.$()
|
||||||
.val(this.get("usernames"))
|
.val(this.get("usernames"))
|
||||||
.autocomplete({
|
.autocomplete({
|
||||||
@ -62,7 +58,7 @@ export default TextField.extend({
|
|||||||
|
|
||||||
dataSource(term) {
|
dataSource(term) {
|
||||||
var results = userSearch({
|
var results = userSearch({
|
||||||
term: term.replace(termRegexp, ""),
|
term,
|
||||||
topicId: self.get("topicId"),
|
topicId: self.get("topicId"),
|
||||||
exclude: excludedUsernames(),
|
exclude: excludedUsernames(),
|
||||||
includeGroups,
|
includeGroups,
|
||||||
@ -72,7 +68,6 @@ export default TextField.extend({
|
|||||||
group: self.get("group"),
|
group: self.get("group"),
|
||||||
disallowEmails
|
disallowEmails
|
||||||
});
|
});
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -122,8 +122,7 @@ export default function userSearch(options) {
|
|||||||
currentTerm = term;
|
currentTerm = term;
|
||||||
|
|
||||||
return new Ember.RSVP.Promise(function(resolve) {
|
return new Ember.RSVP.Promise(function(resolve) {
|
||||||
// TODO site setting for allowed regex in username
|
if (term.length === 0) {
|
||||||
if (term.match(/[^\w_\-\.@\+]/)) {
|
|
||||||
resolve([]);
|
resolve([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href title="{{user.name}}">
|
<a href title="{{user.name}}">
|
||||||
{{avatar user imageSize="tiny"}}
|
{{avatar user imageSize="tiny"}}
|
||||||
<span class='username'>{{user.username}}</span>
|
<span class='username'>{{format-username user.username}}</span>
|
||||||
<span class='name'>{{user.name}}</span>
|
<span class='name'>{{user.name}}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href title="{{email.username}}">
|
<a href title="{{email.username}}">
|
||||||
<i class='fa fa-envelope'></i>
|
<i class='fa fa-envelope'></i>
|
||||||
<span class='username'>{{email.username}}</span>
|
<span class='username'>{{format-username email.username}}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
Loading…
Reference in New Issue
Block a user