Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search full name #4624

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"Accounts_AllowedDomainsList_Description": "Comma-separated list of allowed domains",
"Accounts_AllowEmailChange": "Allow Email Change",
"Accounts_AllowPasswordChange": "Allow Password Change",
"Accounts_AllowSearchByName": "Allow user search by name",
"Accounts_AllowUserAvatarChange": "Allow User Avatar Change",
"Accounts_AllowUsernameChange": "Allow Username Change",
"Accounts_AllowUserProfileChange": "Allow User Profile Change",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/server/startup/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RocketChat.settings.addGroup 'Accounts', ->
@add 'Accounts_ShowFormLogin', true, { type: 'boolean', public: true }
@add 'Accounts_EmailOrUsernamePlaceholder', '', { type: 'string', public: true, i18nLabel: 'Placeholder_for_email_or_username_login_field' }
@add 'Accounts_PasswordPlaceholder', '', { type: 'string', public: true, i18nLabel: 'Placeholder_for_password_login_field' }
@add 'Accounts_AllowSearchByName', false, { type: 'boolean', public: true }

@section 'Registration', ->
@add 'Accounts_RequireNameForSignUp', true, { type: 'boolean', public: true }
Expand Down
8 changes: 8 additions & 0 deletions packages/rocketchat-theme/assets/stylesheets/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,10 @@ textarea[disabled] {
padding: 8px 5px;
font-size: 12px;
cursor: pointer;
font-weight: 300;
strong {
font-weight: normal;
}
}

label.required:after {
Expand Down Expand Up @@ -2285,6 +2289,10 @@ label.required:after {
line-height: 32px;
cursor: pointer;
user-select: none;
font-weight: 300;
strong {
font-weight: normal;
}
}

.popup-user-avatar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ input.search {
&.selected {
background-color: @tertiary-background-color;
color: @primary-font-color;
strong {
color: @primary-font-color;
}
}
strong {
color: @primary-font-color;
}
}

Expand Down Expand Up @@ -755,6 +761,12 @@ a.github-fork {
&.selected {
background-color: #4CAEEB;
color: #FFF;
strong {
color: #FFF;
}
}
strong {
color: @primary-font-color;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ getUsersFromServer = (filter, records, cb) =>
_id: result.username
username: result.username
status: 'offline'
name: result.name
sort: 3

records = _.sortBy(records, 'sort')
Expand Down Expand Up @@ -80,6 +81,7 @@ Template.messagePopupConfig.helpers
_id: item.username
username: item.username
status: item.status
name: item.name
sort: 1

# Get users of room
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-ui/views/app/spotlight/spotlight.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ getFromServer = (filter, records, cb) =>
server.push({
_id: user._id
t: 'd',
name: user.username
name: user.username,
fullName: user.name
})

if results?.rooms?.length > 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template name="spotlightTemplate">
<i class="{{icon}} {{userStatus}}"></i>
{{name}}
<strong>{{name}}</strong> {{fullName}}
{{#if unread}}
<span>{{unread}}</span>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-ui/views/app/userSearch.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template name="userSearch">
<i class="icon-at status-{{status}}"></i> {{username}}{{#if name}} - <strong>{{name}}</strong>{{/if}}
<i class="icon-at status-{{status}}"></i> <strong>{{username}}</strong> {{name}}
</template>
<template name="userSearchEmpty">
<p>{{_ "Nothing_found"}}.</p>
Expand Down
5 changes: 4 additions & 1 deletion server/publications/spotlight.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ Meteor.methods
regex = new RegExp s.trim(s.escapeRegExp(text)), "i"

if type.users is true and RocketChat.authz.hasPermission this.userId, 'view-d-room'
result.users = RocketChat.models.Users.findByActiveUsersUsernameExcept(text, usernames, { limit: 5, fields: { username: 1, status: 1 }, sort: { username: 1 } }).fetch()
if RocketChat.settings.get('Accounts_AllowSearchByName')
result.users = RocketChat.models.Users.findActiveByUsernameOrNameRegexWithExceptions(text, usernames, { limit: 5, fields: { username: 1, status: 1, name: 1 }, sort: { username: 1 } }).fetch()
else
result.users = RocketChat.models.Users.findByActiveUsersUsernameExcept(text, usernames, { limit: 5, fields: { username: 1, status: 1 }, sort: { username: 1 } }).fetch()

if type.rooms is true and RocketChat.authz.hasPermission this.userId, 'view-c-room'
username = RocketChat.models.Users.findOneById(this.userId, { username: 1 }).username
Expand Down
9 changes: 7 additions & 2 deletions server/publications/userAutocomplete.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Meteor.publish 'userAutocomplete', (selector) ->

options =
fields:
name: 1
username: 1
status: 1
sort:
Expand All @@ -18,7 +17,13 @@ Meteor.publish 'userAutocomplete', (selector) ->

exceptions = selector.exceptions or []

cursorHandle = RocketChat.models.Users.findActiveByUsernameOrNameRegexWithExceptions(selector.term, exceptions, options).observeChanges
if RocketChat.settings.get('Accounts_AllowSearchByName')
options.fields.name = 1
find = RocketChat.models.Users.findActiveByUsernameOrNameRegexWithExceptions(selector.term, exceptions, options)
else
find = RocketChat.models.Users.findByActiveUsersUsernameExcept(selector.term, exceptions, options)

cursorHandle = find.observeChanges
added: (_id, record) ->
pub.added("autocompleteRecords", _id, record)

Expand Down