mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-04 04:59:40 +00:00
add optional parameters to limit autocompletion to specific group
This commit is contained in:
parent
328ecb22d8
commit
718ea926d8
4 changed files with 20 additions and 3 deletions
|
|
@ -55,7 +55,7 @@
|
|||
import tierNPC from 'assets/svg/tier-npc.svg';
|
||||
|
||||
export default {
|
||||
props: ['label', 'group', 'placeholder'],
|
||||
props: ['label', 'group', 'placeholder', 'autocompleteContext'],
|
||||
components: {
|
||||
communityGuidelines,
|
||||
chatMessage,
|
||||
|
|
@ -92,7 +92,7 @@
|
|||
autocompleteOptions: {
|
||||
values: debounce(async (text, cb) => {
|
||||
if (text.length > 0) {
|
||||
let suggestions = await axios.get(`/api/v4/members/find/${text}`);
|
||||
let suggestions = await axios.get(`/api/v4/members/find/${text}?context=${this.autocompleteContext}&id=${this.group._id}`);
|
||||
cb(suggestions.data.data);
|
||||
} else {
|
||||
cb([]);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
chat(
|
||||
:label="$t('chat')",
|
||||
:group="group",
|
||||
:autocompleteContext="autocompleteContext"
|
||||
:placeholder="!isParty ? $t('chatPlaceholder') : $t('partyChatPlaceholder')",
|
||||
@fetchRecentMessages="fetchRecentMessages()"
|
||||
)
|
||||
|
|
@ -368,6 +369,9 @@ export default {
|
|||
showNoNotificationsMessage () {
|
||||
return this.group.memberCount > this.$store.state.constants.LARGE_GROUP_COUNT_MESSAGE_CUTOFF;
|
||||
},
|
||||
autocompleteContext () {
|
||||
return this.isParty ? 'party' : 'guild';
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
if (this.isParty) this.searchId = 'party';
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
chat(
|
||||
:label="$t('tavernChat')",
|
||||
:group="group",
|
||||
:autocompleteContext="'tavern'"
|
||||
:placeholder="$t('tavernCommunityGuidelinesPlaceholder')",
|
||||
@fetchRecentMessages="fetchRecentMessages()"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,20 @@ api.getUsernameAutocompletes = {
|
|||
return;
|
||||
}
|
||||
|
||||
let query = {'auth.local.lowerCaseUsername': {$regex: `^${username}.*`}, 'flags.verifiedUsername': true, 'preferences.searchableUsername': {$ne: false}};
|
||||
|
||||
let context = req.query.context;
|
||||
let id = req.query.id;
|
||||
if (context && id) {
|
||||
if (context === 'party') {
|
||||
query['party._id'] = id;
|
||||
} else if (context === 'guild') {
|
||||
query.guilds = id;
|
||||
}
|
||||
}
|
||||
|
||||
let members = await User
|
||||
.find({'auth.local.lowerCaseUsername': {$regex: `^${username}.*`}, 'flags.verifiedUsername': true, 'preferences.searchableUsername': {$ne: false}})
|
||||
.find(query)
|
||||
.select(['profile.name', 'contributor', 'auth.local.username'])
|
||||
.limit(20)
|
||||
.exec();
|
||||
|
|
|
|||
Loading…
Reference in a new issue